8000 Revert "fix(b-form-tags): unit tests" · bootstrap-vue/bootstrap-vue@f3e1001 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3e1001

Browse files
committed
Revert "fix(b-form-tags): unit tests"
This reverts commit 20ebc04.
1 parent 20ebc04 commit f3e1001

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

src/components/form-tags/form-tags.spec.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { createContainer, waitNT, waitRAF } from '../../../tests/utils'
33
import { BFormTags } from './form-tags'
44

55
describe('form-tags', () => {
6-
it('has expected default structure', async () => {
6+
it('has div as root element', async () => {
77
const wrapper = mount(BFormTags)
8-
98
expect(wrapper.element.tagName).toBe('DIV')
9+
1010
expect(wrapper.classes()).toContain('b-form-tags')
1111
expect(wrapper.classes()).toContain('form-control')
1212
expect(wrapper.attributes('role')).toBe('group')
@@ -21,7 +21,6 @@ describe('form-tags', () => {
2121
value: ['apple', 'orange']
2222
}
2323
})
24-
2524
expect(wrapper.element.tagName).toBe('DIV')
2625

2726
const $tags = wrapper.findAll('.b-form-tag')
@@ -50,10 +49,12 @@ describe('form-tags', () => {
5049
value: ['apple', 'orange']
5150
}
5251
})
53-
5452
expect(wrapper.element.tagName).toBe('DIV')
5553

56-
await wrapper.setProps({ value: ['pear'] })
54+
await wrapper.setProps({
55+
value: ['pear']
56+
})
57+
5758
expect(wrapper.vm.tags).toEqual(['pear'])
5859

5960
wrapper.destroy()
@@ -71,14 +72,13 @@ describe('form-tags', () => {
7172
}
7273
}
7374
})
74-
75+
expect(wrapper.element.tagName).toBe('DIV')
7576
await waitNT(wrapper.vm)
7677
await waitRAF()
7778

78-
expect(wrapper.element.tagName).toBe('DIV')
79-
8079
expect(scope).toBeDefined()
8180
expect(typeof scope).toBe('object')
81+
8282
expect(Array.isArray(scope.tags)).toBe(true)
8383
expect(scope.tags).toEqual(['apple', 'orange'])
8484
expect(typeof scope.addTag).toBe('function')
@@ -104,11 +104,11 @@ describe('form-tags', () => {
104104
name: 'foo'
105105
}
106106
})
107-
108107
expect(wrapper.element.tagName).toBe('DIV')
109108

110109
const $hidden = wrapper.findAll('input[type=hidden]')
111110
expect($hidden.length).toBe(2)
111+
112112
expect($hidden.at(0).attributes('value')).toEqual('apple')
113113
expect($hidden.at(0).attributes('name')).toEqual('foo')
114114
expect($hidden.at(1).attributes('value')).toEqual('orange')
@@ -123,12 +123,13 @@ describe('form-tags', () => {
123123
value: ['apple', 'orange']
124124
}
125125
})
126-
127126
expect(wrapper.element.tagName).toBe('DIV')
127+
128128
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
129129
expect(wrapper.vm.newTag).toEqual('')
130130

131131
const $input = wrapper.find('input')
132+
132133
expect($input.exists()).toBe(true)
133134
expect($input.element.value).toBe('')
134135
expect($input.element.type).toBe('text')
@@ -163,13 +164,14 @@ describe('form-tags', () => {
163164
value: ['apple', 'orange', 'pear', 'peach']
164165
}
165166
})
166-
167167
expect(wrapper.element.tagName).toBe('DIV')
168+
168169
expect(wrapper.vm.tags).toEqual(['apple', 'orange', 'pear', 'peach'])
169170
expect(wrapper.vm.newTag).toEqual('')
170171

171172
let $tags = wrapper.findAll('.badge')
172173
expect($tags.length).toBe(4)
174+
173175
expect($tags.at(1).attributes('title')).toEqual('orange')
174176

175177
const $btn = $tags.at(1).find('button')
@@ -192,12 +194,13 @@ describe('form-tags', () => {
192194
value: ['apple', 'orange']
193195
}
194196
})
195-
196197
expect(wrapper.element.tagName).toBe('DIV')
198+
197199
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
198200
expect(wrapper.vm.newTag).toEqual('')
199201

200202
const $input = wrapper.find('input')
203+
201204
expect($input.exists()).toBe(true)
202205
expect($input.element.value).toBe('')
203206

@@ -231,12 +234,13 @@ describe('form-tags', () => {
231234
value: ['one', 'two']
232235
}
233236
})
234-
235237
expect(wrapper.element.tagName).toBe('DIV')
238+
236239
expect(wrapper.vm.tags).toEqual(['one', 'two'])
237240
expect(wrapper.vm.newTag).toEqual('')
238241

239242
const $input = wrapper.find('input')
243+
240244
expect($input.exists()).toBe(true)
241245
expect($input.element.value).toBe('')
242246

@@ -291,8 +295,8 @@ describe('form-tags', () => {
291295
value: ['one', 'two']
292296
}
293297
})
294-
295298
expect(wrapper.element.tagName).toBe('DIV')
299+
296300
expect(wrapper.vm.tags).toEqual(['one', 'two'])
297301
expect(wrapper.vm.newTag).toEqual('')
298302
expect(wrapper.vm.duplicateTags).toEqual([])
@@ -302,6 +306,7 @@ describe('form-tags', () => {
302306
expect(wrapper.find('.form-text').exists()).toBe(false)
303307

304308
const $input = wrapper.find('input')
309+
305310
expect($input.exists()).toBe(true)
306311
expect($input.element.value).toBe('')
307312

@@ -460,16 +465,16 @@ describe('form-tags', () => {
460465
value: ['apple', 'orange']
461466
}
462467
})
463-
464468
expect(wrapper.element.tagName).toBe('DIV')
469+
465470
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
466471
expect(wrapper.vm.newTag).toEqual('')
467472

468473
const $input = wrapper.find('input')
474+
const $button = wrapper.find('button.b-form-tags-button')
475+
469476
expect($input.exists()).toBe(true)
470477
expect($input.element.value).toBe('')
471-
472-
const $button = wrapper.find('button.b-form-tags-button')
473478
expect($button.exists()).toBe(true)
474479
expect($button.classes()).toContain('invisible')
475480

@@ -494,18 +499,20 @@ describe('form-tags', () => {
494499
value: ['apple', 'orange']
495500
}
496501
})
497-
502+
expect(wrapper.element.tagName).toBe('DIV')
498503
await waitNT(wrapper.vm)
499504
await waitRAF()
500505

501-
expect(wrapper.element.tagName).toBe('DIV')
502506
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
503507
expect(wrapper.vm.newTag).toEqual('')
508+
504509
expect(wrapper.classes()).not.toContain('focus')
505510

506511
const $input = wrapper.find('input')
512+
507513
expect($input.exists()).toBe(true)
508514
expect($input.element.value).toBe('')
515+
509516
expect(document.activeElement).not.toBe($input.element)
510517

511518
await wrapper.trigger('click')
@@ -545,25 +552,21 @@ describe('form-tags', () => {
545552
value: ['apple', 'orange']
546553
}
547554
})
548-
555+
expect(wrapper.element.tagName).toBe('DIV')
549556
await waitNT(wrapper.vm)
550557
await waitRAF()
551558

552-
expect(wrapper.element.tagName).toBe('DIV')
553559
expect(wrapper.vm.tags).toEqual(['apple', 'orange'])
554560
expect(wrapper.vm.newTag).toEqual('')
555-
expect(wrapper.classes()).toContain('focus')
561+
562+
expect(wrapper.classes()).not.toContain('focus')
556563

557564
const $input = wrapper.find('input')
565+
558566
expect($input.exists()).toBe(true)
559567
expect($input.element.value).toBe('')
560-
expect(document.activeElement).toBe($input.element)
561568

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)
569+
expect(document.activeElement).toBe($input.element)
567570

568571
wrapper.destroy()
569572
})

0 commit comments

Comments
 (0)
0