Skip to content

fix: update to support new @vue/test-utils #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"author": "Edd Yerburgh",
"license": "MIT",
"devDependencies": {
"@vue/test-utils": "^1.0.0-beta.25",
"babel-core": "^6.25.0",
"babel-jest": "^20.0.3",
"babel-plugin-istanbul": "^4.1.4",
Expand All @@ -49,8 +50,7 @@
"stylus": "^0.54.5",
"typescript": "^2.5.2",
"vue": "^2.4.2",
"vue-template-compiler": "^2.4.2",
"vue-test-utils": "git+https://github.com/vuejs/vue-test-utils.git"
"vue-template-compiler": "^2.4.2"
},
"peerDependencies": {
"babel-core": "^6.25.0 || ^7.0.0-0",
Expand Down
9 changes: 4 additions & 5 deletions test/FunctionalSFC.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import FunctionalSFC from './resources/FunctionalSFC.vue'

let wrapper
const clickSpy = jest.fn()
beforeEach(() => {
wrapper = shallow(FunctionalSFC, {
wrapper = shallowMount(FunctionalSFC, {
context: {
props: { msg: { id: 1, title: 'foo' }, onClick: clickSpy }
}
Expand All @@ -22,12 +22,11 @@ describe('Processes .vue file with functional template', () => {
})

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

it('handles slot', () => {
wrapper = shallow(FunctionalSFC, {
wrapper = shallowMount(FunctionalSFC, {
context: {
props: { msg: { id: 1, title: '' }},
children: ['this is a slot']
Expand Down
2 changes: 1 addition & 1 deletion test/FunctionalSFCParent.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount } from 'vue-test-utils'
import { mount } from '@vue/test-utils'
import FunctionalSFCParent from './resources/FunctionalSFCParent.vue'

test('processes .vue file with functional template from parent', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/NoScript.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount } from 'vue-test-utils'
import { mount } from '@vue/test-utils'
import NoScript from './resources/NoScript.vue'

describe('NoScript', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/RenderFunction.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import RenderFunction from './resources/RenderFunction.vue'

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

expect(wrapper.is('section')).toBe(true)
})
6 changes: 3 additions & 3 deletions test/TypeScript.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import { resolve } from 'path'
import TypeScript from './resources/TypeScript.vue'
import jestVue from '../vue-jest'
Expand All @@ -10,14 +10,14 @@ beforeEach(() => {
})

test('processes .vue files', () => {
shallow(TypeScript)
shallowMount(TypeScript)
})

test('processes .vue files without .babelrc', () => {
const babelRcPath = resolve(__dirname, '../.babelrc')
const tempPath = resolve(__dirname, '../.renamed')
renameSync(babelRcPath, tempPath)
shallow(TypeScript)
shallowMount(TypeScript)
renameSync(tempPath, babelRcPath)
})

Expand Down
10 changes: 5 additions & 5 deletions test/coffee.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shallow, mount } from 'vue-test-utils'
import { shallowMount, mount } from '@vue/test-utils'
import Coffee from './resources/Coffee.vue'
import CoffeeScript from './resources/CoffeeScript.vue'
import CoffeeES6 from './resources/CoffeeES6.vue'
Expand All @@ -20,19 +20,19 @@ describe('Test CoffeeScript - coffee.spec.js', () => {
})

test('processes .vue file with lang set to coffee', () => {
shallow(Coffee)
shallowMount(Coffee)
})

test('processes .vue file with lang set to coffeescript', () => {
shallow(CoffeeScript)
shallowMount(CoffeeScript)
})

test('processes .vue file with lang set to coffee (ES6)', () => {
shallow(CoffeeES6)
shallowMount(CoffeeES6)
})

test('processes .vue file with lang set to coffeescript (ES6)', () => {
shallow(CoffeeScriptES6)
shallowMount(CoffeeScriptES6)
})

test('processes .vue file with lang set to coffeescript (ES6)', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/css.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import Css from './resources/Css.vue'

describe('processes .vue file with Css style', () => {
let wrapper
beforeAll(() => {
wrapper = shallow(Css)
wrapper = shallowMount(Css)
})

it('should bind from style tags with named module', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/jade.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import Jade from './resources/Jade.vue'

test('processes .vue file with jade template', () => {
const wrapper = shallow(Jade)
const wrapper = shallowMount(Jade)
expect(wrapper.is('div')).toBe(true)
expect(wrapper.classes()).toContain('jade')
})
6 changes: 3 additions & 3 deletions test/less.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import Less from './resources/Less.vue'
import LessModule from './resources/LessModule.vue'

describe('processes .vue file with Less style', () => {
it('does not error on less', () => {
const wrapper = shallow(Less)
const wrapper = shallowMount(Less)
expect(wrapper.classes()).toContain('testLess')
})

it('does not error on less module', () => {
expect(() => shallow(LessModule)).not.toThrow()
expect(() => shallowMount(LessModule)).not.toThrow()
})
})
6 changes: 3 additions & 3 deletions test/postcss.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import PostCss from './resources/PostCss.vue'
import PostCssModule from './resources/PostCssModule.vue'

describe('processes .vue file with PostCSS style', () => {
it('does not error on pcss/postcss', () => {
const wrapper = shallow(PostCss)
const wrapper = shallowMount(PostCss)
expect(wrapper.classes()).toContain('testPcss')
})

it('does not error on pcss/postcss module', () => {
expect(() => shallow(PostCssModule)).not.toThrow()
expect(() => shallowMount(PostCssModule)).not.toThrow()
})
})
4 changes: 2 additions & 2 deletions test/pug.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import { resolve } from 'path'
import Pug from './resources/Pug.vue'
import jestVue from '../vue-jest'
import { readFileSync } from 'fs'

test('processes .vue file with pug template', () => {
const wrapper = shallow(Pug)
const wrapper = shallowMount(Pug)
expect(wrapper.is('div')).toBe(true)
expect(wrapper.classes()).toContain('pug')
})
Expand Down
14 changes: 7 additions & 7 deletions test/sass.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { shallow, mount } from 'vue-test-utils'
import { shallowMount, mount } from '@vue/test-utils'
import Sass from './resources/Sass.vue'
import SassModule from './resources/SassModule.vue'
import SassModuleFunctional from './resources/SassModuleFunctional.vue'

describe('processes .vue file with sass style', () => {
it('does not error on sass', () => {
expect(() => shallow(Sass)).not.toThrow()
expect(() => shallowMount(Sass)).not.toThrow()
})
it('does not error on sass module', () => {
expect(() => shallow(SassModule)).not.toThrow()
expect(() => shallowMount(SassModule)).not.toThrow()
})
it('does not error on sass module when functional', () => {
expect(() => mount(SassModuleFunctional)).not.toThrow()
Expand All @@ -20,7 +20,7 @@ describe('processes .vue files which combine sass and modules', () => {
let functionalWrapper

beforeEach(() => {
wrapper = shallow(SassModule)
wrapper = shallowMount(SassModule)
functionalWrapper = mount(SassModuleFunctional)
})

Expand All @@ -42,7 +42,7 @@ describe('processes .vue files which combine sass and modules', () => {
describe('entrypoint: direct import in SFC', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(SassModule)
wrapper = shallowMount(SassModule)
})
it('does inject classes from directly imported files by relative path', () => {
expect(wrapper.vm.$style.directImportClass).toBeDefined()
Expand All @@ -69,7 +69,7 @@ describe('processes .vue files which combine sass and modules', () => {
describe('entrypoint: import inside previously imported stylesheet', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(SassModule)
wrapper = shallowMount(SassModule)
})
it('does inject classes from imports within sass files by relative path', () => {
expect(wrapper.vm.$style.sassImportClass).toBeDefined()
Expand All @@ -96,7 +96,7 @@ describe('processes .vue files which combine sass and modules', () => {
describe('multiple modules', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(SassModule)
wrapper = shallowMount(SassModule)
})
it('does inject classes from sass if multiple modules are present', () => {
expect(wrapper.vm.$style.directImportSecondClass).toBeDefined()
Expand Down
14 changes: 7 additions & 7 deletions test/scss.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { shallow, mount } from 'vue-test-utils'
import { shallowMount, mount } from '@vue/test-utils'
import Scss from './resources/Scss.vue'
import ScssModule from './resources/ScssModule.vue'
import ScssModuleFunctional from './resources/ScssModuleFunctional.vue'

describe('processes .vue file with scss style', () => {
it('does not error on scss', () => {
expect(() => shallow(Scss)).not.toThrow()
expect(() => shallowMount(Scss)).not.toThrow()
})
it('does not error on scss module', () => {
expect(() => shallow(ScssModule)).not.toThrow()
expect(() => shallowMount(ScssModule)).not.toThrow()
})
it('does not error on scss module when functional', () => {
expect(() => mount(ScssModuleFunctional)).not.toThrow()
Expand All @@ -20,7 +20,7 @@ describe('processes .vue files which combine scss and modules', () => {
let functionalWrapper

beforeEach(() => {
wrapper = shallow(ScssModule)
wrapper = shallowMount(ScssModule)
functionalWrapper = mount(ScssModuleFunctional)
})

Expand All @@ -42,7 +42,7 @@ describe('processes .vue files which combine scss and modules', () => {
describe('entrypoint: direct import in SFC', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(ScssModule)
wrapper = shallowMount(ScssModule)
})
it('does inject classes from directly imported files by relative path', () => {
expect(wrapper.vm.$style.directImportClass).toBeDefined()
Expand All @@ -69,7 +69,7 @@ describe('processes .vue files which combine scss and modules', () => {
describe('entrypoint: import inside previously imported stylesheet', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(ScssModule)
wrapper = shallowMount(ScssModule)
})
it('does inject classes from imports within scss files by relative path', () => {
expect(wrapper.vm.$style.scssImportClass).toBeDefined()
Expand All @@ -96,7 +96,7 @@ describe('processes .vue files which combine scss and modules', () => {
describe('multiple modules', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(ScssModule)
wrapper = shallowMount(ScssModule)
})
it('does inject classes from scss if multiple modules are present', () => {
expect(wrapper.vm.$style.directImportSecondClass).toBeDefined()
Expand Down
6 changes: 3 additions & 3 deletions test/stylus.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shallow } from 'vue-test-utils'
import { shallowMount } from '@vue/test-utils'
import Stylus from './resources/Stylus.vue'
import StylusRelative from './resources/StylusRelative.vue'
import { resolve } from 'path'
Expand All @@ -8,7 +8,7 @@ import jestVue from '../vue-jest'
describe('processes .vue file with Stylus style', () => {
let wrapper
beforeAll(() => {
wrapper = shallow(Stylus)
wrapper = shallowMount(Stylus)
})

it('should bind from style tags with named module', () => {
Expand All @@ -24,7 +24,7 @@ describe('processes .vue file with Stylus style', () => {
})

it('should handle relative imports', () => {
expect(() => shallow(StylusRelative)).not.toThrow()
expect(() => shallowMount(StylusRelative)).not.toThrow()
})

it('does not attempty to compile if experimentalStyles flag is passed', () => {
Expand Down