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

Commit 6c9c8a1

Browse files
committed
add test files
1 parent a00a88a commit 6c9c8a1

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

template/test/.eslintrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
},
5+
"globals": {
6+
"expect": true,
7+
"sinon": true
8+
}
9+
}

template/test/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Vue from 'vue';
2+
3+
Vue.config.productionTip = false;
4+
5+
// require all test files (files that ends with .spec.js)
6+
const testsContext = require.context('./specs', true, /\.spec$/);
7+
testsContext.keys().forEach(testsContext);
8+
9+
// require all src files that ends with .js or .vue for coverage.
10+
// you can also change this to match only the subset of files that
11+
// you want coverage for.
12+
const srcContext = require.context('../src', true, /^\.\/.+\.(vue|js)$/);
13+
srcContext.keys().forEach(srcContext);

template/test/specs/Hello.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Vue from 'vue';
2+
import Component from '@/components/{{ name }}';
3+
4+
describe('{{ name }}.vue', () => {
5+
it('should render correct contents', () => {
6+
const Constructor = Vue.extend(Component);
7+
const propsData = {text: 'Test text'};
8+
const vm = new Constructor({propsData}).$mount();
9+
expect(vm.$el.querySelector('strong').textContent)
10+
.to.equal(propsData.text);
11+
});
12+
});

0 commit comments

Comments
 (0)