This repository has been archived by the owner on Jun 10, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathToolbar.spec.js
127 lines (114 loc) · 3.46 KB
/
Toolbar.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import Toolbar from 'src/Toolbar/Toolbar'
import ToolbarRow from 'src/Toolbar/ToolbarRow'
import ToolbarSection from 'src/Toolbar/ToolbarSection'
import {
createVM,
dataPropagationTest,
nextTick,
} from '../helpers'
describe('Toolbar', function () {
it('keeps original tag data', dataPropagationTest(Toolbar))
it('has default icon', function () {
const vm = createVM(this, function (h) {
return (
<Toolbar ref='toolbar'>
</Toolbar>
)
})
vm.$refs.toolbar.$el.should.have.class('mdc-toolbar')
vm.$('.mdc-toolbar__menu').should.have.text('menu')
})
it('can set the title', function () {
const vm = createVM(this, function (h) {
return (
<Toolbar ref='toolbar' title='My Title'>
</Toolbar>
)
})
vm.$('.mdc-toolbar__title').should.have.text('My Title')
})
it('can set the icon', function () {
const vm = createVM(this, function (h) {
return (
<Toolbar ref='toolbar' icon='star'>
</Toolbar>
)
})
vm.$('.mdc-toolbar__menu').should.have.text('star')
})
it('emits when clicking the menu', function (done) {
const spy = sinon.spy()
const vm = createVM(this, function (h) {
return (
<Toolbar ref='toolbar' onMenu={spy}>
</Toolbar>
)
})
spy.should.have.not.been.called
vm.$('.mdc-toolbar__menu').click()
nextTick().then(() => {
spy.should.have.been.called
}).then(done)
})
it('aligns start by default', function () {
const vm = createVM(this, function (h) {
return (
<Toolbar ref='toolbar'>
</Toolbar>
)
})
vm.$('.mdc-toolbar__section')
.should.have.class('mdc-toolbar__section--align-start')
.and.not.have.class('mdc-toolbar__section--align-end')
})
it('can accomodate more sections')
describe('ToolbarSection', function () {
it('keeps original tag data', dataPropagationTest(ToolbarSection))
it('aligns start by default', function () {
const vm = createVM(this, function (h) {
return (
<ToolbarSection ref='toolbar'>Content</ToolbarSection>
)
})
vm.$('.mdc-toolbar__section')
.should.have.class('mdc-toolbar__section--align-start')
.and.have.text('Content')
.and.not.have.class('mdc-toolbar__section--align-end')
})
it('can align center', function () {
const vm = createVM(this, function (h) {
return (
<ToolbarSection align='center' ref='toolbar'>
</ToolbarSection>
)
})
vm.$('.mdc-toolbar__section')
.should.not.have.class('mdc-toolbar__section--align-start')
.and.not.have.class('mdc-toolbar__section--align-end')
})
it('can align end', function () {
const vm = createVM(this, function (h) {
return (
<ToolbarSection align='end' ref='toolbar'>
</ToolbarSection>
)
})
vm.$('.mdc-toolbar__section')
.should.have.class('mdc-toolbar__section--align-end')
.and.not.have.class('mdc-toolbar__section--align-start')
})
it('shrinks', function () {
const vm = createVM(this, function (h) {
return (
<ToolbarSection shrink ref='toolbar'>
</ToolbarSection>
)
})
vm.$('.mdc-toolbar__section')
.should.have.class('mdc-toolbar__section--shrink-to-fit')
})
})
describe('ToolbarRow', function () {
it('keeps original tag data', dataPropagationTest(ToolbarRow))
})
})