This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import getUrls from 'get-urls'; | |
import linkifyHtml from 'linkifyjs/html'; | |
import PropTypes from 'prop-types'; | |
import { | |
PostMediaContainer, | |
PostTextContainer, | |
} from './components'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import renderer from 'react-test-renderer'; | |
import AboutUs from './AboutUs'; | |
it('renders correctly', () => { | |
const tree = renderer.create(<AboutUs />).toJSON(); | |
expect(tree).toMatchSnapshot(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import './AboutUs.css'; | |
const AboutUs = () => | |
<div className="AboutUs"> | |
<div className="flex-module"> | |
<h3> | |
<span className="AboutUs-title">About</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('openCloudinaryUploadWidget test suite', () => { | |
beforeEach(() => { | |
jest.resetModules(); | |
}); | |
it('returns url if successful', async () => { | |
const result = [{ secure_url: 'http://cloudinary/img/123.png' }]; | |
global.cloudinary = { | |
openUploadWidget: (params, cb) => { | |
cb(null, result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cloudinary = global.cloudinary; | |
export default function openCloudinaryUploadWidget() { | |
return new Promise((resolve, reject) => { | |
cloudinary.openUploadWidget({ | |
cloud_name: process.env.REACT_APP_CLOUDINARY_CLOUD_NAME, | |
upload_preset: process.env.REACT_APP_CLOUDINARY_UPLOAD_PRESET, | |
tags: ['profile_pic'], | |
}, (error, result) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('replaceUrlsWithLinks test suite', () => { | |
it('replaces single url with anchor links', () => { | |
const text = 'Search http://google.com'; | |
const url = ['http://google.com']; | |
const expected = `Search <a href=${url}>${url}</a>`; | |
expect(replaceUrlsWithLinks(text, url)).toEqual(expected); | |
}); | |
it('replaces multiple urls in a text with anchor links', () => { | |
const text = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function replaceUrlsWithLinks(text, urls) { | |
let result = text; | |
urls.forEach((url) => { | |
result = result.replace(url, `<a href=${url}>${url}</a>`); | |
}); | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_list_template(recipient_id, elements, buttons): | |
""" | |
Returns a list template for detail view | |
recipient_id: integer | |
elements: list of elements to be injected into template | |
buttons: list of buttons to be injected into template | |
""" | |
template = copy.deepcopy(message_templates.LIST_TEMPLATE) | |
template['recipient']['id'] = recipient_id | |
payload_section = template['message']['attachment']['payload'] |