Skip to content

Commit 62ecfed

Browse files
committed
Mark types as deprecated
1 parent 825d77a commit 62ecfed

File tree

5 files changed

+50
-11
lines changed

5 files changed

+50
-11
lines changed

src/__tests__/deprecated-options.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {render} from '..'
2+
3+
beforeEach(() => {
4+
jest.spyOn(console, 'warn').mockImplementation(() => {})
5+
})
6+
7+
afterEach(() => {
8+
console.warn.mockRestore()
9+
})
10+
11+
test('warns on deprecated store option', () => {
12+
const Component = {template: `<div></div>`}
13+
14+
render(Component, {
15+
store: 'anything',
16+
})
17+
18+
expect(console.warn).toHaveBeenCalledTimes(1)
19+
expect(console.warn).toHaveBeenCalledWith(
20+
expect.stringContaining(
21+
`Providing 'store' or 'routes' options is now deprecated`,
22+
),
23+
)
24+
})
25+
26+
test('warns on deprecated routes option', () => {
27+
const Component = {template: `<div></div>`}
28+
29+
render(Component, {
30+
routes: 'anything',
31+
})
32+
33+
expect(console.warn).toHaveBeenCalledTimes(1)
34+
expect(console.warn).toHaveBeenCalledWith(
35+
expect.stringContaining(
36+
`Providing 'store' or 'routes' options is now deprecated`,
37+
),
38+
)
39+
})

src/__tests__/vue-router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import About from './components/Router/About.vue'
1313
test('full app rendering/navigating from base URL', async () => {
1414
// Create a Router instance
1515
// https://next.router.vuejs.org/api/#createrouter
16-
// using the a HTML5 history.
16+
// using a HTML5 history.
1717
// https://next.router.vuejs.org/api/#createwebhistory
1818
const router = createRouter({
1919
history: createWebHistory(),

src/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function render(
2222
if (store || routes) {
2323
console.warn(`Providing 'store' or 'routes' options is now deprecated.
2424
You need to create a router/vuex plugin and provide it through 'global.plugins'.
25-
See here for more information:`)
25+
Check out the test examples on GitHub for further details.`)
2626
}
2727

2828
const wrapper = mount(Component, {

types/index.d.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import {EmitsOptions} from 'vue'
55
import {MountingOptions} from '@vue/test-utils'
6-
import {StoreOptions} from 'vuex'
7-
import {RouteRecordRaw} from 'vue-router'
86
import {queries, EventType, BoundFunctions} from '@testing-library/dom'
97
// eslint-disable-next-line import/no-extraneous-dependencies
108
import {OptionsReceived as PrettyFormatOptions} from 'pretty-format'
@@ -33,8 +31,14 @@ type VueTestUtilsRenderOptions = Omit<
3331
'attachTo' | 'shallow' | 'propsData'
3432
>
3533
type VueTestingLibraryRenderOptions = {
36-
store?: StoreOptions<{}>
37-
routes?: RouteRecordRaw[]
34+
/**
35+
* @deprecated Use `global.plugins` array instead.
36+
*/
37+
store: any
38+
/**
39+
* @deprecated Use `global.plugins` array instead.
40+
*/
41+
routes?: any
3842
container?: Element
3943
baseElement?: Element
4044
}

types/test.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ export function testOptions() {
7777
},
7878
global: {
7979
config: {isCustomElement: _ => true},
80+
plugins: [],
8081
},
81-
store: {
82-
state: {count: 3},
83-
strict: true,
84-
},
85-
routes: [{path: '/', component: () => SomeComponent, name: 'route name'}],
8682
baseElement: document.createElement('div'),
8783
container: document.createElement('div'),
8884
})

0 commit comments

Comments
 (0)