-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtaskState.test.js
More file actions
37 lines (33 loc) · 1.23 KB
/
taskState.test.js
File metadata and controls
37 lines (33 loc) · 1.23 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
import '@testing-library/jest-dom/extend-expect'
import taskDispatch, {taskEvent} from './taskDispatch';
import createSample from '../test-util/sample';
import createTaskConnected from './taskConnected';
import createConnectedTester from '../test-util/connectedTester';
import {taskReducers} from './taskState';
const createTester = ({fetchSpecs, uri, initialState}) => {
const connected = createTaskConnected({})
const tester = createConnectedTester({connected, uri, fetchSpecs, initialState})
return tester
}
describe('task state', () => {
test('fetch tasks success', async () => {
// given
const sample = createSample()
const profile = sample.profile()
const task1 = sample.task({profile: profile.id})
const task2 = sample.task({profile: profile.id})
const task3 = sample.task({profile: profile.id})
const tasks = [task1, task2, task3]
const event = taskDispatch.fetchTasksSuccess({profile, tasks})
const reducer = taskReducers[taskEvent.FETCH_TASKS_SUCCESS]
// when
const actual = reducer({}, event)
// then
expect(actual).toEqual({
task: {
profile,
tasks
}
})
})
})