forked from zoltantothcom/Design-Patterns-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBar.test.js
More file actions
63 lines (56 loc) · 1.82 KB
/
ProgressBar.test.js
File metadata and controls
63 lines (56 loc) · 1.82 KB
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
61
62
63
import React from 'react';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import 'jest-styled-components';
import { ThemeProvider } from 'styled-components';
import { Provider } from 'react-redux';
import configureMockStore from 'redux-mock-store';
import { themeCommon } from '../../src/styles/themes/theme.common';
import ProgressBar from '../../src/components/ProgressBar';
const mockStore = configureMockStore();
const store = mockStore({
progress: {
answers: [
{ uuid: 1, answered: true, correct: true },
{ uuid: 2, answered: true, correct: true },
{ uuid: 3, answered: true, correct: true },
{ uuid: 4, answered: true, correct: false }
],
remaining: [
{ uuid: 5, answered: false, correct: null },
{ uuid: 6, answered: false, correct: null },
{ uuid: 7, answered: false, correct: null },
{ uuid: 8, answered: false, correct: null }
]
}
});
describe('<ProgressBar /> component', () => {
let result;
beforeEach(() => {
// the wrapper DIV added to get rid of iterator key warning
result = shallow(
<div key="unique">
<Provider store={store}>
<ThemeProvider theme={themeCommon}>
<ProgressBar />
</ThemeProvider>
</Provider>
</div>
);
});
it('renders without crashing', () => {
expect(result).toBeTruthy();
});
it('shows the number of steps', () => {
const tree = renderer.create(result).toJSON();
expect(tree.children[0].children.length).toBe(8);
});
it('has styled-component rendered classes', () => {
const tree = renderer.create(result).toJSON();
expect(tree.children[0].props.className).toBeDefined();
});
it('matches the snapshot', () => {
const tree = renderer.create(result).toJSON();
expect(tree).toMatchSnapshot();
});
});