Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 6109d43

Browse files
author
cristijora
committedMay 4, 2017
Add sample unit test
1 parent 1aed1da commit 6109d43

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed
 

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"start": "node build/dev-server.js",
1010
"build": "cross-env FULL_BUNDLE=false webpack --progress --config webpack.build.config.js",
1111
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
12+
"unit:watch": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --watch",
1213
"e2e": "node test/e2e/runner.js",
1314
"test": "npm run unit && npm run e2e",
1415
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"

‎test/unit/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ testsContext.keys().forEach(testsContext)
99
// require all src files except main.js for coverage.
1010
// you can also change this to match only the subset of files that
1111
// you want coverage for.
12-
const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
12+
const srcContext = require.context('../../src', true, /^\.\/(?!main\.js$).+\.(js|vue)$/i)
1313
srcContext.keys().forEach(srcContext)

‎test/unit/specs/FormWizard.spec.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Vue from 'vue'
2+
import VueFormWizard from './../../../src/components/FormWizard.vue'
3+
import TabContent from './../../../src/components/TabContent.vue'
4+
5+
function init () {
6+
Vue.component('form-wizard', VueFormWizard)
7+
Vue.component('tab-content', TabContent)
8+
}
9+
10+
describe('FormWizard.vue', () => {
11+
beforeEach(() => {
12+
init()
13+
})
14+
it('should render correct contents', (done) => {
15+
const vm = new Vue({
16+
template: `<form-wizard ref="wizard">
17+
<tab-content>First</tab-content>
18+
<tab-content>Second</tab-content>
19+
</form-wizard>`
20+
}).$mount()
21+
22+
let wizard = vm.$children[0]
23+
let wizardComp = vm.$refs.wizard
24+
expect(wizard.$children.length).to.equal(2)
25+
expect(wizardComp.activeTabIndex).to.equal(0)
26+
done()
27+
})
28+
})

‎test/unit/specs/Hello.spec.js

-11
This file was deleted.

0 commit comments

Comments
 (0)