-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-weight-list.js
43 lines (37 loc) · 1000 Bytes
/
test-weight-list.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 assert from 'assert-element'
import {fromJS} from 'immutable'
import test from 'ava'
import Weight from '../../src/components/weight'
import WeightList from '../../src/components/weight-list'
test('should render a list of weights', () => {
const component = {
context: {
weights: fromJS([
{name: 'squats'},
{name: 'bench press'}
])
},
dispatch() {}
}
const weightList = WeightList(component)
assert.isNode(weightList, 'div')
assert.hasChildren(weightList, 2)
})
test('should dispatch REMOVE_WEIGHT', t => {
let removeCalled = false
const component = {
context: {
weights: fromJS([
{name: 'squats'},
{name: 'bench press'}
])
},
dispatch({index, type}) {
removeCalled = index === 1 && type === 'REMOVE_WEIGHT'
}
}
const weightList = WeightList(component)
const benchPress = Weight(weightList.children[1])
benchPress.children[1].attributes.onClick()
t.truthy(removeCalled)
})