mirror of
https://github.com/tenrok/vue-form-wizard.git
synced 2026-06-24 07:40:34 +03:00
Add sample unit test
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
"start": "node build/dev-server.js",
|
"start": "node build/dev-server.js",
|
||||||
"build": "cross-env FULL_BUNDLE=false webpack --progress --config webpack.build.config.js",
|
"build": "cross-env FULL_BUNDLE=false webpack --progress --config webpack.build.config.js",
|
||||||
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
|
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
|
||||||
|
"unit:watch": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --watch",
|
||||||
"e2e": "node test/e2e/runner.js",
|
"e2e": "node test/e2e/runner.js",
|
||||||
"test": "npm run unit && npm run e2e",
|
"test": "npm run unit && npm run e2e",
|
||||||
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
|
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
|
||||||
|
|||||||
+1
-1
@@ -9,5 +9,5 @@ testsContext.keys().forEach(testsContext)
|
|||||||
// require all src files except main.js for coverage.
|
// require all src files except main.js for coverage.
|
||||||
// you can also change this to match only the subset of files that
|
// you can also change this to match only the subset of files that
|
||||||
// you want coverage for.
|
// you want coverage for.
|
||||||
const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
|
const srcContext = require.context('../../src', true, /^\.\/(?!main\.js$).+\.(js|vue)$/i)
|
||||||
srcContext.keys().forEach(srcContext)
|
srcContext.keys().forEach(srcContext)
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import VueFormWizard from './../../../src/components/FormWizard.vue'
|
||||||
|
import TabContent from './../../../src/components/TabContent.vue'
|
||||||
|
|
||||||
|
function init () {
|
||||||
|
Vue.component('form-wizard', VueFormWizard)
|
||||||
|
Vue.component('tab-content', TabContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('FormWizard.vue', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
init()
|
||||||
|
})
|
||||||
|
it('should render correct contents', (done) => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: `<form-wizard ref="wizard">
|
||||||
|
<tab-content>First</tab-content>
|
||||||
|
<tab-content>Second</tab-content>
|
||||||
|
</form-wizard>`
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
let wizard = vm.$children[0]
|
||||||
|
let wizardComp = vm.$refs.wizard
|
||||||
|
expect(wizard.$children.length).to.equal(2)
|
||||||
|
expect(wizardComp.activeTabIndex).to.equal(0)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import Vue from 'vue'
|
|
||||||
import Hello from '@/components/Hello'
|
|
||||||
|
|
||||||
describe('Hello.vue', () => {
|
|
||||||
it('should render correct contents', () => {
|
|
||||||
const Constructor = Vue.extend(Hello)
|
|
||||||
const vm = new Constructor().$mount()
|
|
||||||
expect(vm.$el.querySelector('.hello h1').textContent)
|
|
||||||
.to.equal('Welcome to Your Vue.js App')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user