mirror of
https://github.com/tenrok/vue-form-wizard.git
synced 2026-06-22 09:30:32 +03:00
Migrate tests to vue-test-utils
This commit is contained in:
+1
-1
@@ -30,7 +30,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "^6.7.2",
|
"autoprefixer": "^6.7.2",
|
||||||
"avoriaz": "^4.1.0",
|
|
||||||
"babel-core": "^6.22.1",
|
"babel-core": "^6.22.1",
|
||||||
"babel-eslint": "^7.1.1",
|
"babel-eslint": "^7.1.1",
|
||||||
"babel-loader": "^6.2.10",
|
"babel-loader": "^6.2.10",
|
||||||
@@ -95,6 +94,7 @@
|
|||||||
"vue-router": "^2.5.1",
|
"vue-router": "^2.5.1",
|
||||||
"vue-style-loader": "^2.0.0",
|
"vue-style-loader": "^2.0.0",
|
||||||
"vue-template-compiler": "^2.4.2",
|
"vue-template-compiler": "^2.4.2",
|
||||||
|
"vue-test-utils": "^1.0.0-beta.1",
|
||||||
"webpack": "^2.2.1",
|
"webpack": "^2.2.1",
|
||||||
"webpack-bundle-analyzer": "^2.2.1",
|
"webpack-bundle-analyzer": "^2.2.1",
|
||||||
"webpack-dev-middleware": "^1.10.0",
|
"webpack-dev-middleware": "^1.10.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueFormWizard from './../../../src/index'
|
import VueFormWizard from './../../../src/index'
|
||||||
import {TabContent as WizardTab, WizardStep, FormWizard} from './../../../src/index'
|
import {TabContent as WizardTab, WizardStep, FormWizard} from './../../../src/index'
|
||||||
import {mount} from 'avoriaz'
|
import {mount} from 'vue-test-utils'
|
||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
|
|
||||||
Vue.use(VueFormWizard)
|
Vue.use(VueFormWizard)
|
||||||
@@ -35,11 +35,11 @@ describe('FormWizard.vue', () => {
|
|||||||
it('renders steps', (done) => {
|
it('renders steps', (done) => {
|
||||||
const wizard = mount(twoStepWizard)
|
const wizard = mount(twoStepWizard)
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const steps = wizard.find(WizardStep)
|
const steps = wizard.findAll(WizardStep)
|
||||||
const firsStep = steps[0]
|
const firsStep = steps.at(0)
|
||||||
expect(steps.length).to.equal(3)
|
expect(steps.length).to.equal(3)
|
||||||
expect(firsStep.hasClass('active'))
|
expect(firsStep.hasClass('active'))
|
||||||
const stepTitle = firsStep.find('.stepTitle')[0]
|
const stepTitle = firsStep.find('.stepTitle')
|
||||||
expect(stepTitle.is('span')).to.equal(true)
|
expect(stepTitle.is('span')).to.equal(true)
|
||||||
const stepText = stepTitle.text().trim()
|
const stepText = stepTitle.text().trim()
|
||||||
expect(stepText).to.equal('Personal details')
|
expect(stepText).to.equal('Personal details')
|
||||||
@@ -49,7 +49,7 @@ describe('FormWizard.vue', () => {
|
|||||||
it('renders tabs', (done) => {
|
it('renders tabs', (done) => {
|
||||||
const wizard = mount(twoStepWizard)
|
const wizard = mount(twoStepWizard)
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const tabs = wizard.find(WizardTab)
|
const tabs = wizard.findAll(WizardTab)
|
||||||
expect(tabs.length).to.equal(3)
|
expect(tabs.length).to.equal(3)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
@@ -57,9 +57,9 @@ describe('FormWizard.vue', () => {
|
|||||||
it('displays only one tab', (done) => {
|
it('displays only one tab', (done) => {
|
||||||
const wizard = mount(twoStepWizard)
|
const wizard = mount(twoStepWizard)
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const tabs = wizard.find(WizardTab)
|
const tabs = wizard.findAll(WizardTab).wrappers
|
||||||
const activeTabs = tabs.filter((tab) => tab.data().active)
|
const activeTabs = tabs.filter((tab) => tab.vm.active)
|
||||||
const inactiveTabs = tabs.filter((tab) => !tab.data().active)
|
const inactiveTabs = tabs.filter((tab) => !tab.vm.active)
|
||||||
expect(activeTabs.length).to.equal(1)
|
expect(activeTabs.length).to.equal(1)
|
||||||
|
|
||||||
inactiveTabs.forEach((tab) => {
|
inactiveTabs.forEach((tab) => {
|
||||||
@@ -71,21 +71,21 @@ describe('FormWizard.vue', () => {
|
|||||||
it('starts at a given index', (done) => {
|
it('starts at a given index', (done) => {
|
||||||
const wizard = mount(twoStepWizard)
|
const wizard = mount(twoStepWizard)
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const tabs = wizard.find(WizardTab)
|
const tabs = wizard.findAll(WizardTab)
|
||||||
const activeTab = tabs[startIndex]
|
const activeTab = tabs.at(startIndex)
|
||||||
expect(activeTab.data().active).to.equal(true)
|
expect(activeTab.vm.active).to.equal(true)
|
||||||
const formWizard = wizard.find(FormWizard)[0]
|
const formWizard = wizard.find(FormWizard)
|
||||||
expect(formWizard.data().activeTabIndex).to.equal(startIndex)
|
expect(formWizard.vm.activeTabIndex).to.equal(startIndex)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('next tab is called', (done) => {
|
it('next tab is called', (done) => {
|
||||||
const wizard = mount(twoStepWizard)
|
const wizard = mount(twoStepWizard)
|
||||||
const nextTabHandler = sinon.stub()
|
const nextTabHandler = sinon.stub()
|
||||||
const formWizard = wizard.find(FormWizard)[0]
|
const formWizard = wizard.find(FormWizard)
|
||||||
formWizard.setMethods({nextTab: nextTabHandler})
|
formWizard.setMethods({nextTab: nextTabHandler})
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const nextButton = wizard.find('.wizard-footer-right span')[0]
|
const nextButton = wizard.find('.wizard-footer-right span')
|
||||||
nextButton.trigger('click')
|
nextButton.trigger('click')
|
||||||
expect(nextTabHandler.called).to.equal(true)
|
expect(nextTabHandler.called).to.equal(true)
|
||||||
done()
|
done()
|
||||||
|
|||||||
@@ -5978,6 +5978,12 @@ vue-template-es2015-compiler@^1.2.2:
|
|||||||
version "1.5.3"
|
version "1.5.3"
|
||||||
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545"
|
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545"
|
||||||
|
|
||||||
|
vue-test-utils@^1.0.0-beta.1:
|
||||||
|
version "1.0.0-beta.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/vue-test-utils/-/vue-test-utils-1.0.0-beta.1.tgz#a3c6450d64f084190b92b22f84626e53191ba32b"
|
||||||
|
dependencies:
|
||||||
|
lodash "^4.17.4"
|
||||||
|
|
||||||
vue@^2.4.2:
|
vue@^2.4.2:
|
||||||
version "2.4.2"
|
version "2.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.2.tgz#a9855261f191c978cc0dc1150531b8d08149b58c"
|
resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.2.tgz#a9855261f191c978cc0dc1150531b8d08149b58c"
|
||||||
|
|||||||
Reference in New Issue
Block a user