forked from rebassjs/rebass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDropdownMenu.js
79 lines (65 loc) · 2.07 KB
/
DropdownMenu.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
import React from 'react'
import TestUtils from 'react-addons-test-utils'
import expect from 'expect'
import { DropdownMenu, Base } from '../src'
const renderer = TestUtils.createRenderer()
describe('DropdownMenu', () => {
let tree
beforeEach(() => {
renderer.render(<DropdownMenu />)
tree = renderer.getRenderOutput()
})
it('should render', () => {
expect(tree.type).toEqual(Base)
})
it('should have a className', () => {
expect(tree.props.className).toEqual('DropdownMenu')
})
it('should default to display none', () => {
expect(tree.props.baseStyle.display).toEqual('none')
})
it('should anchor to the bottom left', () => {
expect(tree.props.baseStyle.top).toEqual('100%')
expect(tree.props.baseStyle.bottom).toEqual('auto')
expect(tree.props.baseStyle.left).toEqual(0)
expect(tree.props.baseStyle.right).toEqual('auto')
})
context('when open is true', () => {
beforeEach(() => {
renderer.render(<DropdownMenu open />)
tree = renderer.getRenderOutput()
})
it('should not have display set', () => {
expect(tree.props.baseStyle.display).toNotExist()
})
})
context('when top is true', () => {
beforeEach(() => {
renderer.render(<DropdownMenu open top />)
tree = renderer.getRenderOutput()
})
it('should anchor to the top', () => {
expect(tree.props.baseStyle.top).toEqual('auto')
expect(tree.props.baseStyle.bottom).toEqual('100%')
})
})
context('when right is true', () => {
beforeEach(() => {
renderer.render(<DropdownMenu open right />)
tree = renderer.getRenderOutput()
})
it('should anchor to the right', () => {
expect(tree.props.baseStyle.left).toEqual('auto')
expect(tree.props.baseStyle.right).toEqual(0)
})
})
context('when custom styles are set', () => {
beforeEach(() => {
renderer.render(<DropdownMenu style={{ color: 'tomato' }} />)
tree = renderer.getRenderOutput()
})
it('should have a custom color', () => {
expect(tree.props.style.color).toEqual('tomato')
})
})
})