forked from rebassjs/rebass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSequenceMap.spec.js
91 lines (74 loc) · 2.22 KB
/
SequenceMap.spec.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import React from 'react'
import TestUtils from 'react-addons-test-utils'
import expect from 'expect'
import { config, SequenceMap, Base } from '../src'
const renderer = TestUtils.createRenderer()
describe('SequenceMap', () => {
const { colors } = config
let tree
beforeEach(() => {
renderer.render(<SequenceMap />)
tree = renderer.getRenderOutput()
})
it('should render', () => {
expect(tree.type).toEqual(Base)
})
it('should have a className', () => {
expect(tree.props.className).toEqual('SequenceMap')
})
it('should not show steps by default', () => {
expect(tree.props.children).toEqual([])
})
context('when steps are set', () => {
beforeEach(() => {
renderer.render(
<SequenceMap
steps={[
{ children: 'Step One' },
{ children: 'Step Two' },
{ children: 'Step Three' }
]} />
)
tree = renderer.getRenderOutput()
})
it('should have 3 steps', () => {
expect(tree.props.children.length).toEqual(3)
})
it('should not show active steps', () => {
expect(tree.props.children[0].props.style.color).toNotExist()
})
})
context('when active is set', () => {
beforeEach(() => {
renderer.render(
<SequenceMap
steps={[
{ test: 'Hello', children: 'Step One' },
{ children: 'Step Two' },
{ children: 'Step Three' }
]}
active={1} />
)
tree = renderer.getRenderOutput()
})
it('should have 3 steps', () => {
expect(tree.props.children.length).toEqual(3)
})
it('should pass object as props to steps', () => {
expect(tree.props.children[0].props.test).toEqual('Hello')
})
it('should show active steps', () => {
expect(tree.props.children[0].props.style.color).toEqual(colors.primary)
expect(tree.props.children[1].props.style.color).toEqual(colors.primary)
})
})
context('when custom styles are set', () => {
beforeEach(() => {
renderer.render(<SequenceMap style={{ color: 'tomato' }} />)
tree = renderer.getRenderOutput()
})
it('should have a custom color', () => {
expect(tree.props.style.color).toEqual('tomato')
})
})
})