mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
chore(test): upgrade vue test utils to v1 (#7321)
This commit is contained in:
parent
6040257ca3
commit
f1d832018a
@ -10,7 +10,7 @@ const factory = () => shallowMount(Btn, {
|
||||
describe('Btn', () => {
|
||||
test('mounts properly', () => {
|
||||
const wrapper = factory()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
expect(wrapper.vm).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders properly', () => {
|
||||
@ -19,13 +19,11 @@ describe('Btn', () => {
|
||||
})
|
||||
|
||||
test('calls handleClick on click', () => {
|
||||
const handleClickMock = jest.spyOn(Btn.methods, 'handleClick')
|
||||
const wrapper = factory()
|
||||
const handleClickMock = jest.fn()
|
||||
wrapper.setMethods({
|
||||
handleClick: handleClickMock
|
||||
})
|
||||
wrapper.find('button').trigger('click')
|
||||
expect(handleClickMock).toHaveBeenCalled()
|
||||
handleClickMock.mockRestore()
|
||||
})
|
||||
|
||||
test('clicked is true after click', () => {
|
||||
|
@ -4,7 +4,7 @@ import index from './index'
|
||||
describe('index', () => {
|
||||
test('mounts properly', () => {
|
||||
const wrapper = shallowMount(index)
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
expect(wrapper.vm).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders properly', () => {
|
||||
|
@ -8,13 +8,13 @@
|
||||
"post-update": "yarn upgrade --latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/test-utils": "^1.0.0",
|
||||
"browser-env": "^3.2.1",
|
||||
"require-extension-hooks": "^0.3.2",
|
||||
"require-extension-hooks-babel": "^0.1.1",
|
||||
"require-extension-hooks-vue": "^0.4.1",
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.8.0",
|
||||
"vue-test-utils": "^1.0.0-beta.2"
|
||||
"tape": "^4.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt": "latest"
|
||||
|
@ -1,5 +1,5 @@
|
||||
import test from 'tape'
|
||||
import { shallow } from 'vue-test-utils'
|
||||
import { shallow } from '@vue/test-utils'
|
||||
import Index from '../pages/index.vue'
|
||||
|
||||
test('renders Index.vue correctly', (t) => {
|
||||
|
@ -41,8 +41,8 @@
|
||||
"@rollup/plugin-json": "^4.0.3",
|
||||
"@rollup/plugin-node-resolve": "7.0.0",
|
||||
"@rollup/plugin-replace": "^2.3.2",
|
||||
"@vue/server-test-utils": "^1.0.0-beta.33",
|
||||
"@vue/test-utils": "^1.0.0-beta.33",
|
||||
"@vue/server-test-utils": "^1.0.0",
|
||||
"@vue/test-utils": "^1.0.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^26.0.1",
|
||||
"consola": "^2.11.3",
|
||||
|
@ -24,13 +24,11 @@ describe('nuxt-link prefetch', () => {
|
||||
)
|
||||
|
||||
const Component = await importComponent(compiledTemplatePath)
|
||||
const observe = jest.spyOn(Component.methods, 'observe')
|
||||
Component.extends = RouterLinkStub
|
||||
|
||||
const methods = { observe: jest.fn() }
|
||||
|
||||
const wrapper = mount(Component, {
|
||||
propsData: { to: '/link' },
|
||||
methods
|
||||
propsData: { to: '/link' }
|
||||
})
|
||||
|
||||
jest.runAllTimers()
|
||||
@ -41,7 +39,7 @@ describe('nuxt-link prefetch', () => {
|
||||
|
||||
expect(wrapper.props('prefetch')).toBe(false)
|
||||
expect(wrapper.props('noPrefetch')).toBe(false)
|
||||
expect(methods.observe).not.toHaveBeenCalled()
|
||||
expect(observe).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('when router.prefetchLinks is set to false, link with prefetch prop set to true should be prefetched',
|
||||
@ -53,13 +51,11 @@ describe('nuxt-link prefetch', () => {
|
||||
)
|
||||
|
||||
const Component = await importComponent(compiledTemplatePath)
|
||||
const observe = jest.spyOn(Component.methods, 'observe')
|
||||
Component.extends = RouterLinkStub
|
||||
|
||||
const methods = { observe: jest.fn() }
|
||||
|
||||
const wrapper = mount(Component, {
|
||||
propsData: { to: '/link', prefetch: true },
|
||||
methods
|
||||
propsData: { to: '/link', prefetch: true }
|
||||
})
|
||||
|
||||
jest.runAllTimers()
|
||||
@ -70,7 +66,7 @@ describe('nuxt-link prefetch', () => {
|
||||
|
||||
expect(wrapper.props('prefetch')).toBe(true)
|
||||
expect(wrapper.props('noPrefetch')).toBe(false)
|
||||
expect(methods.observe).toHaveBeenCalled()
|
||||
expect(observe).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('when router.prefetchLinks is set to true (default), link with no prop should be prefetched',
|
||||
@ -82,13 +78,11 @@ describe('nuxt-link prefetch', () => {
|
||||
)
|
||||
|
||||
const Component = await importComponent(compiledTemplatePath)
|
||||
const observe = jest.spyOn(Component.methods, 'observe')
|
||||
Component.extends = RouterLinkStub
|
||||
|
||||
const methods = { observe: jest.fn() }
|
||||
|
||||
const wrapper = mount(Component, {
|
||||
propsData: { to: '/link' },
|
||||
methods
|
||||
propsData: { to: '/link' }
|
||||
})
|
||||
|
||||
jest.runAllTimers()
|
||||
@ -99,7 +93,7 @@ describe('nuxt-link prefetch', () => {
|
||||
|
||||
expect(wrapper.props('prefetch')).toBe(true)
|
||||
expect(wrapper.props('noPrefetch')).toBe(false)
|
||||
expect(methods.observe).toHaveBeenCalled()
|
||||
expect(observe).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('when router.prefetchLinks is set to true (default), link with prefetch prop set to false should not be prefetched',
|
||||
@ -111,13 +105,11 @@ describe('nuxt-link prefetch', () => {
|
||||
)
|
||||
|
||||
const Component = await importComponent(compiledTemplatePath)
|
||||
const observe = jest.spyOn(Component.methods, 'observe')
|
||||
Component.extends = RouterLinkStub
|
||||
|
||||
const methods = { observe: jest.fn() }
|
||||
|
||||
const wrapper = mount(Component, {
|
||||
propsData: { to: '/link', prefetch: false },
|
||||
methods
|
||||
propsData: { to: '/link', prefetch: false }
|
||||
})
|
||||
|
||||
jest.runAllTimers()
|
||||
@ -128,7 +120,7 @@ describe('nuxt-link prefetch', () => {
|
||||
|
||||
expect(wrapper.props('prefetch')).toBe(false)
|
||||
expect(wrapper.props('noPrefetch')).toBe(false)
|
||||
expect(methods.observe).not.toHaveBeenCalled()
|
||||
expect(observe).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('when router.prefetchLinks is set to true (default), link with noPrefetch prop should not be prefetched',
|
||||
@ -140,13 +132,11 @@ describe('nuxt-link prefetch', () => {
|
||||
)
|
||||
|
||||
const Component = await importComponent(compiledTemplatePath)
|
||||
const observe = jest.spyOn(Component.methods, 'observe')
|
||||
Component.extends = RouterLinkStub
|
||||
|
||||
const methods = { observe: jest.fn() }
|
||||
|
||||
const wrapper = mount(Component, {
|
||||
propsData: { to: '/link', noPrefetch: true },
|
||||
methods
|
||||
propsData: { to: '/link', noPrefetch: true }
|
||||
})
|
||||
|
||||
jest.runAllTimers()
|
||||
@ -157,7 +147,7 @@ describe('nuxt-link prefetch', () => {
|
||||
|
||||
expect(wrapper.props('prefetch')).toBe(true)
|
||||
expect(wrapper.props('noPrefetch')).toBe(true)
|
||||
expect(methods.observe).not.toHaveBeenCalled()
|
||||
expect(observe).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
/* eslint-enable no-console */
|
||||
|
16
yarn.lock
16
yarn.lock
@ -2372,18 +2372,18 @@
|
||||
optionalDependencies:
|
||||
prettier "^1.18.2"
|
||||
|
||||
"@vue/server-test-utils@^1.0.0-beta.33":
|
||||
version "1.0.0-beta.33"
|
||||
resolved "https://registry.npmjs.org/@vue/server-test-utils/-/server-test-utils-1.0.0-beta.33.tgz#d3e284c0646d404ec6a4192b96ace99dd90a3033"
|
||||
integrity sha512-vXZHy3Wh+Dj4Yn5jGll3m0DYdq3sZVwEsLViP/5CpBYQmqJKn55Y7ZMP07A+dAGcilXwL6MgP5/vCKnQkhUs7Q==
|
||||
"@vue/server-test-utils@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/@vue/server-test-utils/-/server-test-utils-1.0.0.tgz#bef19655157f1fd689ed5cbdf28a6a159b6b8d75"
|
||||
integrity sha512-VCenIoRhPPpdD1UBklqk9LQP9uKVd9Yu6jHxWb5dhGG+SmJp6Z2IQWGefqe/HamNrgCe7rjERZG/569PX3qVUw==
|
||||
dependencies:
|
||||
"@types/cheerio" "^0.22.10"
|
||||
cheerio "^1.0.0-rc.2"
|
||||
|
||||
"@vue/test-utils@^1.0.0-beta.33":
|
||||
version "1.0.0-beta.33"
|
||||
resolved "https://registry.npmjs.org/@vue/test-utils/-/test-utils-1.0.0-beta.33.tgz#627511afbd4307e7557634f860a1b985bd25d9cd"
|
||||
integrity sha512-Xzqoe0lTLn3QRWfjhmKPOXYR86l0Y+g/zPHaheJQOkPLj5ojJl3rG0t4F3kXFWuLD88YzUVRMIBWOG7v9KOJQQ==
|
||||
"@vue/test-utils@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/@vue/test-utils/-/test-utils-1.0.0.tgz#02e81ec674a45c694e95be2e06116a7275819c7b"
|
||||
integrity sha512-lB0xDlOAGrmQZXZEWDbmfTWy2zE1BKfbbyR6dxlgiunm149it1JTghD6zfruBU+ujm7vW8YHWgx62O57VK4JOg==
|
||||
dependencies:
|
||||
dom-event-types "^1.0.0"
|
||||
lodash "^4.17.15"
|
||||
|
Loading…
Reference in New Issue
Block a user