10000 update to support new @vue/test-utils · vuejs/vue-jest@456831d · GitHub
[go: up one dir, main page]

Skip to content

Commit 456831d

Browse files
author
Justin Helmer
committed
update to support new @vue/test-utils
1 parent d9f9336 commit 456831d

15 files changed

+47
-48
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"author": "Edd Yerburgh",
3131
"license": "MIT",
3232
"devDependencies": {
33+
"@vue/test-utils": "^1.0.0-beta.25",
3334
"babel-core": "^6.25.0",
3435
"babel-jest": "^20.0.3",
3536
"babel-plugin-istanbul": "^4.1.4",
@@ -49,8 +50,7 @@
4950
"stylus": "^0.54.5",
5051
"typescript": "^2.5.2",
5152
"vue": "^2.4.2",
52-
"vue-template-compiler": "^2.4.2",
53-
"vue-test-utils": "git+https://github.com/vuejs/vue-test-utils.git"
53+
"vue-template-compiler": "^2.4.2"
5454
},
5555
"peerDependencies": {
5656
"babel-core": "^6.25.0 || ^7.0.0-0",

test/FunctionalSFC.spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { shallow } from 'vue-test-utils'
1+
import { shallowMount } from '@vue/test-utils'
22
import FunctionalSFC from './resources/FunctionalSFC.vue'
33

44
let wrapper
55
const clickSpy = jest.fn()
66
beforeEach(() => {
7-
wrapper = shallow(FunctionalSFC, {
7+
wrapper = shallowMount(FunctionalSFC, {
88
context: {
99
props: { msg: { id: 1, title: 'foo' }, onClick: clickSpy }
1010
}
@@ -22,12 +22,11 @@ describe('Processes .vue file with functional template', () => {
2222
})
2323

2424
it('is functional', () => {
25-
// note: for new version of @vue/vue-utils we can use wrapper.isFunctionalComponent for this
26-
expect(wrapper.vm._vnode.fnOptions.functional).toBe(true)
25+
expect(wrapper.isFunctionalComponent).toBe(true)
2726
})
2827

2928
it('handles slot', () => {
30-
wrapper = shallow(FunctionalSFC, {
29+
wrapper = shallowMount(FunctionalSFC, {
3130
context: {
3231
props: { msg: { id: 1, title: '' }},
3332
children: ['this is a slot']

test/FunctionalSFCParent.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mount } from 'vue-test-utils'
1+
import { mount } from '@vue/test-utils'
22
import FunctionalSFCParent from './resources/FunctionalSFCParent.vue'
33

44
test('processes .vue file with functional template from parent', () => {

test/NoScript.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mount } from 'vue-test-utils'
1+
import { mount } from '@vue/test-utils'
22
import NoScript from './resources/NoScript.vue'
33

44
describe('NoScript', () => {

test/RenderFunction.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { shallow } from 'vue-test-utils'
1+
import { shallowMount } from '@vue/test-utils'
22
import RenderFunction from './resources/RenderFunction.vue'
33

44
test('processes .vue file with no template', () => {
5-
const wrapper = shallow(RenderFunction)
5+
const wrapper = shallowMount(RenderFunction)
66

77
expect(wrapper.is('section')).toBe(true)
88
})

test/TypeScript.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { shallow } from 'vue-test-utils'
1+
import { shallowMount } from '@vue/test-utils'
22
import { resolve } from 'path'
33
import TypeScript from './resources/TypeScript.vue'
44
import jestVue from '../vue-jest'
@@ -10,14 +10,14 @@ beforeEach(() => {
1010
})
1111

1212
test('processes .vue files', () => {
13-
shallow(TypeScript)
13+
shallowMount(TypeScript)
1414
})
1515

1616
test('processes .vue files without .babelrc', () => {
1717
const babelRcPath = resolve(__dirname, '../.babelrc')
1818
const tempPath = resolve(__dirname, '../.renamed')
1919
renameSync(babelRcPath, tempPath)
20-
shallow(TypeScript)
20+
shallowMount(TypeScript)
2121
renameSync(tempPath, babelRcPath)
2222
})
2323

test/coffee.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { shallow, mount } from 'vue-test-utils'
1+
import { shallowMount, mount } from '@vue/test-utils'
22
import Coffee from './resources/Coffee.vue'
33
import CoffeeScript from './resources/CoffeeScript.vue'
44
import CoffeeES6 from './resources/CoffeeES6.vue'
@@ -20,19 +20,19 @@ describe('Test CoffeeScript - coffee.spec.js', () => {
2020
})
2121

2222
test('processes .vue file with lang set to coffee', () => {
23-
shallow(Coffee)
23+
shallowMount(Coffee)
2424
})
2525

2626
test('processes .vue file with lang set to coffeescript', () => {
27-
shallow(CoffeeScript)
27+
shallowMount(CoffeeScript)
2828
})
2929

3030
test('processes .vue file with lang set to coffee (ES6)', () => {
31-
shallow(CoffeeES6)
31+
shallowMount(CoffeeES6)
3232
})
3333

3434
test('processes .vue file with lang set to coffeescript (ES6)', () => {
35-
shallow(CoffeeScriptES6)
35+
shallowMount(CoffeeScriptES6)
3636
})
3737

3838
test('processes .vue file with lang set to coffeescript (ES6)', () => {

test/css.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { shallow } from 'vue-test-utils'
1+
import { shallowMount } from '@vue/test-utils'
22
import Css from './resources/Css.vue'
33

44
describe('processes .vue file with Css style', () => {
55
let wrapper
66
beforeAll(() => {
7-
wrapper = shallow(Css)
7+
wrapper = shallowMount(Css)
88
})
99

1010
it('should bind from style tags with named module', () => {

test/jade.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { shallow } from 'vue-test-utils'
1+
import { shallowMount } from '@vue/test-utils'
22
import Jade from './resources/Jade.vue'
33

44
test('processes .vue file with jade template', () => {
5-
const wrapper = shallow(Jade)
5+
const wrapper = shallowMount(Jade)
66
expect(wrapper.is('div')).toBe(true)
77
expect(wrapper.classes()).toContain('jade')
88
})

test/less.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { shallow } from 'vue-test-utils'
1+
import { shallowMount } from '@vue/test-utils'
22
import Less from './resources/Less.vue'
33
import LessModule from './resources/LessModule.vue'
44

55
describe('processes .vue file with Less style', () => {
66
it('does not error on less', () => {
7-
const wrapper = shallow(Less)
7+
const wrapper = shallowMount(Less)
88
expect(wrapper.classes()).toContain('testLess')
99
})
1010

1111
it('does not error on less module', () => {
12-
expect(() => shallow(LessModule)).not.toThrow()
12+
expect(() => shallowMount(LessModule)).not.toThrow()
1313
})
1414
})

0 commit comments

Comments
 (0)
0