Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

Commit e5ca922

Browse files
committed
refactor(test): create helper function
1 parent fa8e371 commit e5ca922

File tree

6 files changed

+23
-44
lines changed

6 files changed

+23
-44
lines changed

__tests__/layouts/default.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { createLocalVue, mount, RouterLinkStub } from '@vue/test-utils'
2-
import Buefy from 'buefy'
1+
import { mount, RouterLinkStub } from '@vue/test-utils'
32

3+
import { createVue } from '~/__tests__/utils'
44
import DefaultLayout from '~/layouts/default.vue'
55

66
type MenuItem = {
77
title: string
88
subMenu: { name: string; href: string }[]
99
}
1010

11-
const localVue = createLocalVue()
12-
localVue.use(Buefy)
11+
const localVue = createVue()
1312

1413
describe('layouts/default.vue', () => {
1514
test('renders correctly', () => {

__tests__/pages/index.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1-
import {
2-
createLocalVue,
3-
mount,
4-
RouterLinkStub,
5-
shallowMount,
6-
Wrapper
7-
} from '@vue/test-utils'
8-
import Buefy from 'buefy'
1+
import { mount, RouterLinkStub, shallowMount, Wrapper } from '@vue/test-utils'
92

3+
import { createVue } from '~/__tests__/utils'
104
import Index from '~/pages/index.vue'
115
import { Software } from '~/types/software'
126

137
type SoftListData = Omit<Software, 'difficultyNames' | 'region'> & {
148
region: string
159
}
1610

17-
const localVue = createLocalVue()
18-
localVue.use(Buefy)
11+
const localVue = createVue()
1912

2013
describe('pages/index.vue', () => {
2114
let wrapper: Wrapper<Index>

__tests__/pages/series/_id/index.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import {
2-
createLocalVue,
3-
mount,
4-
RouterLinkStub,
5-
shallowMount,
6-
Wrapper
7-
} from '@vue/test-utils'
8-
import Buefy from 'buefy'
1+
import { mount, RouterLinkStub, shallowMount, Wrapper } from '@vue/test-utils'
92

3+
import { createVue } from '~/__tests__/utils'
104
import SeriesDetail from '~/pages/series/_id/index.vue'
115
import type { Software } from '~/types/software'
126
import type { Chart, PlayStyle, Song } from '~/types/song'
@@ -20,8 +14,7 @@ type SongListData = Omit<Song, 'series' | 'charts'> & {
2014
charts: Partial<Record<PlayStyle, ChartInfo[]>>
2115
}
2216

23-
const localVue = createLocalVue()
24-
localVue.use(Buefy)
17+
const localVue = createVue()
2518

2619
describe('pages/series/_id/index.vue', () => {
2720
let wrapper: Wrapper<SeriesDetail>

__tests__/pages/song/_id.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import {
2-
createLocalVue,
3-
mount,
4-
RouterLinkStub,
5-
shallowMount,
6-
Wrapper
7-
} from '@vue/test-utils'
8-
import Buefy from 'buefy'
1+
import { mount, RouterLinkStub, shallowMount, Wrapper } from '@vue/test-utils'
92

3+
import { createVue } from '~/__tests__/utils'
104
import SongDetail from '~/pages/song/_id.vue'
115
import { Chart, Song } from '~/types/song'
126

@@ -19,8 +13,7 @@ type SongInfo = Omit<Song, 'series' | 'charts'> & {
1913
seriesList: string[]
2014
}
2115

22-
const localVue = createLocalVue()
23-
localVue.use(Buefy)
16+
const localVue = createVue()
2417

2518
describe('pages/song/_id.vue', () => {
2619
let wrapper: Wrapper<SongDetail>

__tests__/pages/song/index.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
import {
2-
createLocalVue,
3-
mount,
4-
RouterLinkStub,
5-
shallowMount,
6-
Wrapper
7-
} from '@vue/test-utils'
8-
import Buefy from 'buefy'
1+
import { mount, RouterLinkStub, shallowMount, Wrapper } from '@vue/test-utils'
92
import { MetaInfo } from 'vue-meta'
103

4+
import { createVue } from '~/__tests__/utils'
115
import SongList from '~/pages/song/index.vue'
126
import { Song } from '~/types/song'
137

148
type SongListData = Omit<Song, 'series' | 'charts'> & {
159
seriesList: string[]
1610
}
1711

18-
const localVue = createLocalVue()
19-
localVue.use(Buefy)
12+
const localVue = createVue()
2013

2114
describe('pages/song/index.vue', () => {
2215
let wrapper: Wrapper<SongList>

__tests__/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createLocalVue } from '@vue/test-utils'
2+
import Buefy from 'buefy'
3+
4+
export function createVue() {
5+
const localVue = createLocalVue()
6+
localVue.use(Buefy)
7+
return localVue
8+
}

0 commit comments

Comments
 (0)