-
Notifications
You must be signed in to change notification settings - Fork 0
/
welcome_page_test.js
53 lines (42 loc) · 1.45 KB
/
welcome_page_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { renderComponent , expect } from '../test_helper';
import WelcomePage from '../../src/WelcomePage';
describe('WelcomePage' , () => {
let component;
beforeEach(() => {
component = renderComponent(WelcomePage);
});
it('renders text ', () => {
expect(component).to.contain('Example list of languages');
});
it('has a list', () => {
const state = {
languages: ['C#', 'C++', 'Rust']
};
component = renderComponent(WelcomePage, null, state);
const $ul = component.find('ul');
expect($ul).to.exist;
const $li = $ul.find('li');
expect($li.length).to.equal(state.languages.length);
state.languages.forEach(language =>
expect($li).to.contain(language)
);
});
it('show text input', () => {
expect(component.find('input:text')).to.exist;
});
it('has a button', () => {
expect(component.find('button')).to.exist;
});
describe('Entering new item' , () => {
beforeEach(() => {
component.find('input:text').simulate('change', 'Whitespace');
});
it('show that text in text input', () => {
expect(component.find('input:text')).to.have.value('Whitespace');
});
it('when submitted, clears the input', () => {
component.simulate('submit');
expect(component.find('input:text')).to.have.value('');
});
});
});