🌐 AI搜索 & 代理 主页
Skip to content

Commit b16514b

Browse files
committed
chore(compat): remove useless localVue usage
Jest resets modules for each test suite. If we are using localVue just to install plugins - it is useless and could be removed
1 parent ac8ebfe commit b16514b

File tree

9 files changed

+38
-73
lines changed

9 files changed

+38
-73
lines changed

src/components/dropdown/dropdown-item.spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import VueRouter from 'vue-router'
2-
import { createLocalVue, mount } from '@vue/test-utils'
2+
import { mount } from '@vue/test-utils'
33
import { waitRAF } from '../../../tests/utils'
4+
import { Vue } from '../../vue'
45
import { BDropdownItem } from './dropdown-item'
56

7+
Vue.use(VueRouter)
8+
69
describe('dropdown-item', () => {
710
it('renders with tag "a" and href="#" by default', async () => {
811
const wrapper = mount(BDropdownItem)
@@ -94,9 +97,6 @@ describe('dropdown-item', () => {
9497

9598
describe('router-link support', () => {
9699
it('works', async () => {
97-
const localVue = createLocalVue()
98-
localVue.use(VueRouter)
99-
100100
const router = new VueRouter({
101101
mode: 'abstract',
102102
routes: [
@@ -124,7 +124,6 @@ describe('dropdown-item', () => {
124124
}
125125

126126
const wrapper = mount(App, {
127-
localVue,
128127
attachTo: document.body
129128
})
130129

src/components/link/link.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import VueRouter from 'vue-router'
22
import { createLocalVue, mount } from '@vue/test-utils'
33
import { BLink } from './link'
4+
import { Vue } from '../../vue'
5+
6+
Vue.use(VueRouter)
47

58
describe('b-link', () => {
69
it('has expected default structure', async () => {
@@ -353,7 +356,6 @@ describe('b-link', () => {
353356
describe('router-link support', () => {
354357
it('works', async () => {
355358
const localVue = createLocalVue()
356-
localVue.use(VueRouter)
357359

358360
const router = new VueRouter({
359361
mode: 'abstract',

src/components/modal/helpers/bv-modal.spec.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { config as vtuConfig, createLocalVue, createWrapper, mount } from '@vue/test-utils'
1+
import { Vue } from '../../../vue'
2+
import { createWrapper, mount } from '@vue/test-utils'
23
import { waitNT, waitRAF } from '../../../../tests/utils'
3-
import { TransitionStub } from '../../../../tests/components'
44
import { ModalPlugin } from '../index'
55

6-
// Stub `<transition>` component
7-
vtuConfig.stubs.transition = TransitionStub
8-
9-
const localVue = createLocalVue()
10-
localVue.use(ModalPlugin)
6+
Vue.use(ModalPlugin)
117

128
describe('$bvModal', () => {
139
it('$bvModal.show() and $bvModal.hide() works', async () => {
@@ -17,8 +13,7 @@ describe('$bvModal', () => {
1713
}
1814
}
1915
const wrapper = mount(App, {
20-
attachTo: document.body,
21-
localVue
16+
attachTo: document.body
2217
})
2318

2419
expect(wrapper.vm).toBeDefined()
@@ -44,7 +39,7 @@ describe('$bvModal', () => {
4439
await waitNT(wrapper.vm)
4540
await waitRAF()
4641

47-
expect($modal.element.style.display).toEqual('')
42+
expect($modal.element.style.display).not.toEqual('none')
4843

4944
wrapper.vm.$bvModal.hide('test1')
5045

@@ -65,8 +60,7 @@ describe('$bvModal', () => {
6560
}
6661
}
6762
const wrapper = mount(App, {
68-
attachTo: document.body,
69-
localVue
63+
attachTo: document.body
7064
})
7165

7266
expect(wrapper.vm).toBeDefined()
@@ -127,8 +121,7 @@ describe('$bvModal', () => {
127121
}
128122
}
129123
const wrapper = mount(App, {
130-
attachTo: document.body,
131-
localVue
124+
attachTo: document.body
132125
})
133126

134127
expect(wrapper.vm).toBeDefined()

src/components/pagination-nav/pagination-nav.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import VueRouter from 'vue-router'
2-
import { createLocalVue, mount } from '@vue/test-utils'
2+
import { mount } from '@vue/test-utils'
33
import { waitNT, waitRAF } from '../../../tests/utils'
4+
import { Vue } from '../../vue'
45
import { BPaginationNav } from './pagination-nav'
56

6-
const localVue = createLocalVue()
7-
localVue.use(VueRouter)
7+
Vue.use(VueRouter)
88

99
// The majority of tests for the core of pagination mixin are performed
1010
// in pagination.spec.js. Here we just test the differences that
@@ -569,7 +569,7 @@ describe('pagination-nav', () => {
569569
const router = new VueRouter({
570570
routes: [{ path: '/', component: FooRoute }, { path: '/:page', component: FooRoute }]
571571
})
572-
const wrapper = mount(App, { localVue, router })
572+
const wrapper = mount(App, { router })
573573

574574
expect(wrapper).toBeDefined()
575575

@@ -630,7 +630,7 @@ describe('pagination-nav', () => {
630630
const router = new VueRouter({
631631
routes: [{ path: '/', component: FooRoute }, { path: '/:page', component: FooRoute }]
632632
})
633-
const wrapper = mount(App, { localVue, router })
633+
const wrapper = mount(App, { router })
634634

635635
expect(wrapper).toBeDefined()
636636

src/components/skeleton/skeleton-icon.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createLocalVue, mount } from '@vue/test-utils'
1+
import { mount } from '@vue/test-utils'
22
import { IconsPlugin } from '../../icons'
3+
import { Vue } from '../../vue'
34
import { BSkeletonIcon } from './skeleton-icon'
45

5-
const localVue = createLocalVue()
6-
localVue.use(IconsPlugin)
6+
Vue.use(IconsPlugin)
77

88
describe('skeleton-icon', () => {
99
it('root element is DIV and contains SVG', async () => {
@@ -40,7 +40,6 @@ describe('skeleton-icon', () => {
4040

4141
it('`icon` prop works', async () => {
4242
const wrapper = mount(BSkeletonIcon, {
43-
localVue,
4443
propsData: {
4544
icon: 'heart'
4645
}
@@ -55,7 +54,6 @@ describe('skeleton-icon', () => {
5554

5655
it('`icon-props` is passed correctly to icon', async () => {
5756
const wrapper = mount(BSkeletonIcon, {
58-
localVue,
5957
propsData: {
6058
icon: 'heart',
6159
iconProps: {

src/components/toast/helpers/bv-toast.spec.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createLocalVue, createWrapper, mount } from '@vue/test-utils'
1+
import { createWrapper, mount } from '@vue/test-utils'
2+
import { Vue } from '../../../vue'
23
import { waitNT, waitRAF } from '../../../../tests/utils'
34
import { ToastPlugin } from '../index'
45

5-
const localVue = createLocalVue()
6-
localVue.use(ToastPlugin)
6+
Vue.use(ToastPlugin)
77

88
describe('$bvToast', () => {
99
it('$bvToast.show() and $bvToast.hide() works', async () => {
@@ -24,8 +24,7 @@ describe('$bvToast', () => {
2424
}
2525
}
2626
const wrapper = mount(App, {
27-
attachTo: document.body,
28-
localVue
27+
attachTo: document.body
2928
})
3029

3130
expect(wrapper.vm).toBeDefined()
@@ -75,8 +74,7 @@ describe('$bvToast', () => {
7574
}
7675
}
7776
const wrapper = mount(App, {
78-
attachTo: document.body,
79-
localVue
77+
attachTo: document.body
8078
})
8179

8280
expect(wrapper.vm).toBeDefined()

src/icons/icons.spec.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { createLocalVue, mount } from '@vue/test-utils'
1+
import { mount } from '@vue/test-utils'
22
import { IconsPlugin } from './index'
33
import { BIcon } from './icon'
44
import { makeIcon } from './helpers/make-icon'
5+
import { Vue } from '../vue'
56

6-
const localVue = createLocalVue()
7-
localVue.use(IconsPlugin)
7+
Vue.use(IconsPlugin)
88

99
describe('icons', () => {
1010
it('b-icon has expected structure', async () => {
1111
const wrapper = mount(BIcon, {
12-
localVue,
1312
propsData: {
1413
icon: 'alarm-fill'
1514
}
@@ -40,7 +39,6 @@ describe('icons', () => {
4039

4140
it('b-icon has expected structure when `stacked` prop is true', async () => {
4241
const wrapper = mount(BIcon, {
43-
localVue,
4442
propsData: {
4543
icon: 'alarm-fill',
4644
stacked: true
@@ -77,7 +75,6 @@ describe('icons', () => {
7775
// As we don't specify a parent instance (which has all the registered
7876
// components for the icons)
7977
const wrapper = mount(BIcon, {
80-
localVue,
8178
propsData: {
8279
icon: ''
8380
}
@@ -99,7 +96,6 @@ describe('icons', () => {
9996
// This test assumes Vue doesn't puke on unknown component names
10097
// As we currently do not check the validity of icon names
10198
const wrapper = mount(BIcon, {
102-
localVue,
10399
propsData: {
104100
icon: undefined
105101
}
@@ -117,7 +113,6 @@ describe('icons', () => {
117113

118114
it('b-icon with unknown icon name renders BIconBlank', async () => {
119115
const wrapper = mount(BIcon, {
120-
localVue,
121116
propsData: {
122117
icon: 'unknown-icon-name'
123118
}
@@ -138,7 +133,6 @@ describe('icons', () => {
138133

139134
it('b-icon variant works', async () => {
140135
const wrapper = mount(BIcon, {
141-
localVue,
142136
propsData: {
143137
icon: 'alarm-fill',
144138
variant: 'danger'
@@ -164,7 +158,6 @@ describe('icons', () => {
164158

165159
it('b-icon font-scale prop works', async () => {
166160
const wrapper = mount(BIcon, {
167-
localVue,
168161
propsData: {
169162
icon: 'alarm-fill',
170163
fontScale: '1.25'
@@ -200,7 +193,6 @@ describe('icons', () => {
200193
}
201194

202195
const wrapper = mount(ParentComponent, {
203-
localVue,
204196
propsData: {
205197
icon: 'fake-icon-test'
206198
}
@@ -221,7 +213,6 @@ describe('icons', () => {
221213

222214
it('b-icon rotate prop works', async () => {
223215
const wrapper = mount(BIcon, {
224-
localVue,
225216
propsData: {
226217
icon: 'alarm-fill',
227218
rotate: '45'
@@ -246,7 +237,6 @@ describe('icons', () => {
246237

247238
it('b-icon scale prop works', async () => {
248239
const wrapper = mount(BIcon, {
249-
localVue,
250240
propsData: {
251241
icon: 'alarm-fill',
252242
scale: '1.5'
@@ -271,7 +261,6 @@ describe('icons', () => {
271261

272262
it('b-icon flip-h prop works', async () => {
273263
const wrapper = mount(BIcon, {
274-
localVue,
275264
propsData: {
276265
icon: 'alarm-fill',
277266
flipH: true
@@ -296,7 +285,6 @@ describe('icons', () => {
296285

297286
it('b-icon flip-v prop works', async () => {
298287
const wrapper = mount(BIcon, {
299-
localVue,
300288
propsData: {
301289
icon: 'alarm-fill',
302290
flipV: true
@@ -321,7 +309,6 @@ describe('icons', () => {
321309

322310
it('b-icon flip-h prop works with flip-v prop', async () => {
323311
const wrapper = mount(BIcon, {
324-
localVue,
325312
propsData: {
326313
icon: 'alarm-fill',
327314
flipH: true,
@@ -347,7 +334,6 @@ describe('icons', () => {
347334

348335
it('b-icon scale prop works with flip-h prop', async () => {
349336
const wrapper = mount(BIcon, {
350-
localVue,
351337
propsData: {
352338
icon: 'alarm-fill',
353339
scale: '1.5',
@@ -373,7 +359,6 @@ describe('icons', () => {
373359

374360
it('b-icon scale prop works with flip-v prop', async () => {
375361
const wrapper = mount(BIcon, {
376-
localVue,
377362
propsData: {
378363
icon: 'alarm-fill',
379364
scale: '1.5',
@@ -399,7 +384,6 @@ describe('icons', () => {
399384

400385
it('b-icon scale prop works with flip-h and flip-v prop', async () => {
401386
const wrapper = mount(BIcon, {
402-
localVue,
403387
propsData: {
404388
icon: 'alarm-fill',
405389
scale: '1.5',
@@ -426,7 +410,6 @@ describe('icons', () => {
426410

427411
it('b-icon shift-h and shift-v props work', async () => {
428412
const wrapper = mount(BIcon, {
429-
localVue,
430413
propsData: {
431414
icon: 'alarm-fill',
432415
shiftH: 8,
@@ -452,7 +435,6 @@ describe('icons', () => {
452435

453436
it('b-icon shift-h and shift-v props work with rotate prop', async () => {
454437
const wrapper = mount(BIcon, {
455-
localVue,
456438
propsData: {
457439
icon: 'alarm-fill',
458440
rotate: 45,
@@ -482,7 +464,6 @@ describe('icons', () => {
482464

483465
it('b-icon animation prop works', async () => {
484466
const wrapper = mount(BIcon, {
485-
localVue,
486467
propsData: {
487468
icon: 'circle-fill',
488469
animation: 'spin'
@@ -501,7 +482,6 @@ describe('icons', () => {
501482

502483
it('b-icon title prop works', async () => {
503484
const wrapper = mount(BIcon, {
504-
localVue,
505485
propsData: {
506486
icon: 'circle-fill',
507487
title: 'Circle'
@@ -523,7 +503,6 @@ describe('icons', () => {
523503

524504
it('b-icon <title> should not render when title is undefined', async () => {
525505
const wrapper = mount(BIcon, {
526-
localVue,
527506
propsData: {
528507
icon: 'circle-fill'
529508
}

0 commit comments

Comments
 (0)