Merge branch 'master' into fix-nav-width

This commit is contained in:
Kim Gardner
2017-10-05 10:53:43 +01:00
committed by GitHub
15 changed files with 949 additions and 130 deletions
@@ -1,6 +1,5 @@
import React from 'react';
import {shallow} from 'enzyme';
import {expect} from 'chai';
import Markdown from '../Markdown';
const render = (props) => shallow(<Markdown {...props} />);
@@ -9,12 +8,12 @@ describe('Markdown', () => {
it('should convert Markdown to html', () => {
const wrapper = render({content: '*test*'});
const html = wrapper.html();
expect(html).to.contain('<em>');
expect(html).toMatch('<em>');
});
it('should set target="_parent" for links', () => {
const wrapper = render({content: '[link](https://coralproject.net)'});
const html = wrapper.html();
expect(html).to.contain('target="_parent"');
expect(html).toMatch('target="_parent"');
});
});
+1 -1
View File
@@ -13,7 +13,7 @@ import pt_BR from '../../../locales/pt_BR.yml';
// Translations are happening at https://translate.lingohub.com/the-coral-project/dashboard
const defaultLanguage = 'en';
const defaultLanguage = process.env.TALK_DEFAULT_LANG;
const translations = {...en, ...es, ...fr, ...pt_BR};
let lang;
@@ -1,26 +0,0 @@
import React from 'react';
import {shallow} from 'enzyme';
import {expect} from 'chai';
import CommentBox from '../CommentBox';
describe('CommentBox', () => {
let comment;
let render;
beforeEach(() => {
comment = {};
const postItem = (item) => {
comment.posted = item;
return Promise.resolve(4);
};
render = shallow(<CommentBox
postItem={postItem}
updateItem={(e) => comment.text = e.target.value}
item_id={'1'}
comments={['1', '2', '3']}/>);
});
it('should render the CommentBox appropriately', () => {
expect(render.contains('<div class="CommentBox"')).to.be.true;
expect(render.contains('<button class="postCommentButton"')).to.be.true;
});
});
@@ -1,29 +1,36 @@
import React from 'react';
import {shallow} from 'enzyme';
import {expect} from 'chai';
import InfoBox from '../InfoBox';
import renderer from 'react-test-renderer';
const render = (props) => shallow(<InfoBox {...props} />);
describe('InfoBox', () => {
it('renders correctly', () => {
const tree = renderer.create(
<InfoBox content='test' enable/>
).toJSON();
expect(tree).toMatchSnapshot();
});
it('should render hidden InfoBox', () => {
const wrapper = render();
const className = wrapper.prop('className');
expect(className).to.include('-info');
expect(className).to.include('hidden');
expect(className).toMatch('-info');
expect(className).toMatch('hidden');
});
it('should render enabled InfoBox', () => {
const wrapper = render({enable: true});
const className = wrapper.prop('className');
expect(className).to.include('-info');
expect(className).to.not.include('hidden');
expect(className).toMatch('-info');
expect(className).not.toMatch('hidden');
});
it('should render Markdown', () => {
const wrapper = render({content: 'x'});
const Markddown = wrapper.find('Markdown');
expect(Markddown).to.have.length(1);
expect(Markddown.prop('content')).to.equal('x');
expect(Markddown).toHaveLength(1);
expect(Markddown.prop('content')).toEqual('x');
});
});
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`InfoBox renders correctly 1`] = `
<div
className="talk-plugin-infobox-info "
>
<div
dangerouslySetInnerHTML={
Object {
"__html": "<p>test</p>
",
}
}
/>
</div>
`;