@@ -3,10 +3,10 @@ import { createContainer, waitNT, waitRAF } from '../../../tests/utils'
3
3
import { BFormTags } from './form-tags'
4
4
5
5
describe('form-tags', () => {
6
-
it('has div as root element', async () => {
6
+
it('has expected default structure', async () => {
7
7
const wrapper = mount(BFormTags)
8
-
expect(wrapper.element.tagName).toBe('DIV')
9
8
9
+
expect(wrapper.element.tagName).toBe('DIV')
10
10
expect(wrapper.classes()).toContain('b-form-tags')
11
11
expect(wrapper.classes()).toContain('form-control')
12
12
expect(wrapper.attributes('role')).toBe('group')
@@ -21,6 +21,7 @@ describe('form-tags', () => {
21
21
value: ['apple', 'orange']
22
22
}
23
23
})
24
+
24
25
expect(wrapper.element.tagName).toBe('DIV')
25
26
26
27
const $tags = wrapper.findAll('.b-form-tag')
@@ -49,12 +50,10 @@ describe('form-tags', () => {
49
50
value: ['apple', 'orange']
50
51
}
51
52
})
52
-
expect(wrapper.element.tagName).toBe('DIV')
53
53
54
-
await wrapper.setProps({
55
-
value: ['pear']
56
-
})
54
+
expect(wrapper.element.tagName).toBe('DIV')
57
55
56
+
await wrapper.setProps({ value: ['pear'] })
58
57
expect(wrapper.vm.tags).toEqual(['pear'])
59
58
60
59
wrapper.destroy()
@@ -72,13 +71,14 @@ describe('form-tags', () => {
72
71
}
73
72
}
74
73
})
75
-
expect(wrapper.element.tagName).toBe('DIV')
74
+
76
75
await waitNT(wrapper.vm)
77
76
await waitRAF()
78
77
78
+
expect(wrapper.element.tagName).toBe('DIV')
79
+
79
80
expect(scope).toBeDefined()
80
81
expect(typeof scope).toBe('object')
81
-
82
82
expect(Array.isArray(scope.tags)).toBe(true)
83
83
expect(scope.tags).toEqual(['apple', 'orange'])
84
84
expect(typeof scope.addTag).toBe('function')
@@ -104,11 +104,11 @@ describe('form-tags', () => {
104
104
name: 'foo'
105
105
}
106
106
})
107
+
107
108
expect(wrapper.element.tagName).toBe('DIV')
108
109
109
110
const $hidden = wrapper.findAll('input[type=hidden]')
110
111
expect($hidden.length).toBe(2)
111
-
112
112
expect($hidden.at(0).attributes('value')).toEqual('apple')
113
113
expect($hidden.at(0).attributes('name')).toEqual('foo')
114
114
expect($hidden.at(1).attributes('value')).toEqual('orange')
@@ -123,13 +123,12 @@ describe('form-tags', () => {
123
123
value: ['apple', 'orange']
124
124
}
125
125
})
126
-
expect(wrapper.element.tagName).toBe('DIV')
127
126
127
+
expect(wrapper.element.tagName).toBe('DIV')
128
128
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
129
129
expect(wrapper.vm.newTag).toEqual('')
130
130
131
131
const $input = wrapper.find('input')
132
-
133
132
expect($input.exists()).toBe(true)
134
133
expect($input.element.value).toBe('')
135
134
expect($input.element.type).toBe('text')
@@ -164,14 +163,13 @@ describe('form-tags', () => {
164
163
value: ['apple', 'orange', 'pear', 'peach']
165
164
}
166
165
})
167
-
expect(wrapper.element.tagName).toBe('DIV')
168
166
167
+
expect(wrapper.element.tagName).toBe('DIV')
169
168
expect(wrapper.vm.tags).toEqual(['apple', 'orange', 'pear', 'peach'])
170
169
expect(wrapper.vm.newTag).toEqual('')
171
170
172
171
let $tags = wrapper.findAll('.badge')
173
172
expect($tags.length).toBe(4)
174
-
175
173
expect($tags.at(1).attributes('title')).toEqual('orange')
176
174
177
175
const $btn = $tags.at(1).find('button')
@@ -194,13 +192,12 @@ describe('form-tags', () => {
194
192
value: ['apple', 'orange']
195
193
}
196
194
})
197
-
expect(wrapper.element.tagName).toBe('DIV')
198
195
196
+
expect(wrapper.element.tagName).toBe('DIV')
199
197
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
200
198
expect(wrapper.vm.newTag).toEqual('')
201
199
202
200
const $input = wrapper.find('input')
203
-
204
201
expect($input.exists()).toBe(true)
205
202
expect($input.element.value).toBe('')
206
203
@@ -234,13 +231,12 @@ describe('form-tags', () => {
234
231
value: ['one', 'two']
235
232
}
236
233
})
237
-
expect(wrapper.element.tagName).toBe('DIV')
238
234
235
+
expect(wrapper.element.tagName).toBe('DIV')
239
236
expect(wrapper.vm.tags).toEqual(['one', 'two'])
240
237
expect(wrapper.vm.newTag).toEqual('')
241
238
242
239
const $input = wrapper.find('input')
243
-
244
240
expect($input.exists()).toBe(true)
245
241
expect($input.element.value).toBe('')
246
242
@@ -295,8 +291,8 @@ describe('form-tags', () => {
295
291
value: ['one', 'two']
296
292
}
297
293
})
298
-
expect(wrapper.element.tagName).toBe('DIV')
299
294
295
+
expect(wrapper.element.tagName).toBe('DIV')
300
296
expect(wrapper.vm.tags).toEqual(['one', 'two'])
301
297
expect(wrapper.vm.newTag).toEqual('')
302
298
expect(wrapper.vm.duplicateTags).toEqual([])
@@ -306,7 +302,6 @@ describe('form-tags', () => {
306
302
expect(wrapper.find('.form-text').exists()).toBe(false)
307
303
308
304
const $input = wrapper.find('input')
309
-
310
305
expect($input.exists()).toBe(true)
311
306
expect($input.element.value).toBe('')
312
307
@@ -465,16 +460,16 @@ describe('form-tags', () => {
465
460
value: ['apple', 'orange']
466
461
}
467
462
})
468
-
expect(wrapper.element.tagName).toBe('DIV')
469
463
464
+
expect(wrapper.element.tagName).toBe('DIV')
470
465
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
471
466
expect(wrapper.vm.newTag).toEqual('')
472
467
473
468
const $input = wrapper.find('input')
474
-
const $button = wrapper.find('button.b-form-tags-button')
475
-
476
469
expect($input.exists()).toBe(true)
477
470
expect($input.element.value).toBe('')
471
+
472
+
const $button = wrapper.find('button.b-form-tags-button')
478
473
expect($button.exists()).toBe(true)
479
474
expect($button.classes()).toContain('invisible')
480
475
@@ -499,20 +494,18 @@ describe('form-tags', () => {
499
494
value: ['apple', 'orange']
500
495
}
501
496
})
502
-
expect(wrapper.element.tagName).toBe('DIV')
497
+
503
498
await waitNT(wrapper.vm)
504
499
await waitRAF()
505
500
501
+
expect(wrapper.element.tagName).toBe('DIV')
506
502
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
507
503
expect(wrapper.vm.newTag).toEqual('')
508
-
509
504
expect(wrapper.classes()).not.toContain('focus')
510
505
511
506
const $input = wrapper.find('input')
512
-
513
507
expect($input.exists()).toBe(true)
514
508
expect($input.element.value).toBe('')
515
-
516
509
expect(document.activeElement).not.toBe($input.element)
517
510
518
511
await wrapper.trigger('click')
@@ -552,22 +545,26 @@ describe('form-tags', () => {
552
545
value: ['apple', 'orange']
553
546
}
554
547
})
555
-
expect(wrapper.element.tagName).toBe('DIV')
548
+
556
549
await waitNT(wrapper.vm)
557
550
await waitRAF()
558
551
552
+
expect(wrapper.element.tagName).toBe('DIV')
559
553
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
560
554
expect(wrapper.vm.newTag).toEqual('')
561
-
562
-
expect(wrapper.classes()).not.toContain('focus')
555
+
expect(wrapper.classes()).toContain('focus')
563
556
564
557
const $input = wrapper.find('input')
565
-
566
558
expect($input.exists()).toBe(true)
567
559
expect($input.element.value).toBe('')
568
-
569
560
expect(document.activeElement).toBe($input.element)
570
561
562
+
wrapper.vm.blur()
563
+
await waitNT(wrapper.vm)
564
+
await waitRAF()
565
+
expect(wrapper.classes()).not.toContain('focus')
566
+
expect(document.activeElement).not.toBe($input.element)
567
+
571
568
wrapper.destroy()
572
569
})
573
570
})
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4