-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplateStore.test.js
More file actions
42 lines (38 loc) · 875 Bytes
/
templateStore.test.js
File metadata and controls
42 lines (38 loc) · 875 Bytes
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
import {
reset,
action,
asyncAdd1,
asyncSetNum,
multiAction,
} from "./templateStore.js"
it('adds 100 to num', () => {
// arrange
const initialState = reset()
// act
const newState = action()
// assert
expect(newState.num).toBe(initialState.num + 100)
})
it('increases num async', async () => {
const initialState = reset()
const newState = await asyncAdd1()
expect(newState.num).toBeGreaterThan(initialState.num)
})
it('sets num async', async () => {
const testNum = 1337
const {num} = await asyncSetNum(testNum)
expect(num).toEqual(testNum)
})
it('compares two specific states', async () => {
const stateBefore = {
num: 660,
numList: [4, 2],
}
const stateAfter = {
num: 677,
numList: [4, 2, 666, 677]
}
reset(stateBefore)
const newState = await multiAction()
expect(newState).toMatchObject(stateAfter)
})