-
Notifications
You must be signed in to change notification settings - Fork 0
/
WelcomePage.test.js
60 lines (48 loc) · 1.69 KB
/
WelcomePage.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
54
55
56
57
58
59
60
import React from 'react';
import WelcomePage from '../WelcomePage';
import { mountWithRedux } from '../test_helper';
describe('WelcomePage' , () => {
let component;
beforeEach(() => {
component = mountWithRedux(<WelcomePage />);
});
it('renders text ', () => {
expect(component.text()).toContain('Example list of languages');
});
it('has a list', () => {
const state = {
languages: ['C#', 'C++', 'Rust']
};
component = mountWithRedux(<WelcomePage />, state);
const $ul = component.find('ul');
expect($ul.exists()).toBe(true);
const $lis = $ul.find('li');
expect($lis.length).toBe(state.languages.length);
$lis.forEach(($li, index) =>
expect($li.text()).toContain(state.languages[index])
);
});
it('show text input', () => {
// Enzime does not have pseudo-class CSS selector yet
// So we cant use input:text
expect(component.find('input').exists()).toBe(true);
});
it('has a button', () => {
expect(component.find('button').exists()).toBe(true);
});
describe('Entering new item' , () => {
beforeEach(() => {
// see note above about input:text
component.find('input').simulate('change', {
target: { value: 'Whitespace' }
});
});
it('show that text in text input', () => {
expect(component.find('input').prop('value')).toBe('Whitespace');
});
it('when submitted, clears the input', () => {
component.simulate('submit');
expect(component.find('input').prop('value')).toBe('');
});
});
});