-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
reducer.test.ts
34 lines (30 loc) 路 1.04 KB
/
reducer.test.ts
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
import { createStore, Store } from 'redux'
import { Field, typeInput } from './actions'
import reducer, { initialState, MintState } from './reducer'
describe('mint reducer', () => {
let store: Store<MintState>
beforeEach(() => {
store = createStore(reducer, initialState)
})
describe('typeInput', () => {
it('sets typed value', () => {
store.dispatch(typeInput({ field: Field.CURRENCY_A, typedValue: '1.0', noLiquidity: false }))
expect(store.getState()).toEqual({
...initialState,
independentField: Field.CURRENCY_A,
typedValue: '1.0',
otherTypedValue: '',
})
})
it('clears other value', () => {
store.dispatch(typeInput({ field: Field.CURRENCY_A, typedValue: '1.0', noLiquidity: false }))
store.dispatch(typeInput({ field: Field.CURRENCY_B, typedValue: '1.0', noLiquidity: false }))
expect(store.getState()).toEqual({
...initialState,
independentField: Field.CURRENCY_B,
typedValue: '1.0',
otherTypedValue: '',
})
})
})
})