-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathExercise5.test.js
43 lines (33 loc) · 1.07 KB
/
Exercise5.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
import React from 'react'
import { shallow } from 'enzyme'
import { counterIncrement, counterDecrement } from './actions'
import { Counter } from './index'
describe('Counter component connected with redux store', () => {
// A sample test
it('should renders the count', () => {
const props = {
dispatch: jest.fn(),
count: 1
}
const wrapper = shallow(<Counter {...props} />)
expect(wrapper.find('.count').text()).toEqual('1')
})
it('dispatches the right action for incrementing', () => {
const props = {
dispatch: jest.fn(),
count: 3
}
const wrapper = shallow(<Counter {...props} />);
wrapper.find('Button.increment').simulate('click')
expect(props.dispatch).toHaveBeenCalledWith(counterIncrement())
})
it('dispatches the right action for decrementing', () => {
const props = {
dispatch: jest.fn(),
count: 3
}
const wrapper = shallow(<Counter {...props} />)
wrapper.find('Button.decrement').simulate('click')
expect(props.dispatch).toHaveBeenCalledWith(counterDecrement())
})
})