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

Commit ea65751

Browse files
committed
change component test, fix test errors and update docs
1 parent a422177 commit ea65751

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ available in the window['{{name}}'] variable.
3131

3232
## Tests
3333

34-
This template uses karma by default, you can change test settings in poi.config.js
34+
This template uses karma with chai by default, you can change test settings in poi.config.js
3535

3636
`npm run test`
3737
`npm run test:watch`

template/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727
},
2828
"devDependencies": {
2929
"babel-preset-es2015": "^6.24.1",
30+
"chai": "^4.1.2",
3031
"eslint": "^3.17.1",
3132
"eslint-plugin-vue": "beta",
33+
"karma-chai": "^0.1.0",
34+
"karma-phantomjs-launcher": "^1.0.4",
35+
"karma-phantomjs-shim": "^1.5.0",
3236
"node-glob": "^1.2.0",
3337
"poi": "^9.3.10",
3438
"poi-preset-karma": "^9.1.0",

template/poi.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const presetKarma = require('poi-preset-karma');
2+
const webpack = require('webpack');
23
const glob = require('glob').sync;
34
const {name} = require('./package.json');
45

@@ -7,13 +8,13 @@ module.exports = {
78
filename: {
89
js: name + '.min.js',
910
},
10-
sourceMap: false,
11+
sourceMap: true,
1112
html: false,
1213
presets: [
1314
presetKarma({
14-
files: ['test/specs/**/*.spec.js'],
15+
files: ['./test/specs/**.spec.js'],
1516
browsers: ['PhantomJS'],
16-
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
17+
frameworks: ['mocha', 'chai', 'phantomjs-shim'],
1718
})
18-
]
19+
],
1920
};

template/test/index.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

template/test/specs/Component.spec.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import Vue from 'vue';
22
import Component from '../../src/{{ name }}/{{ name }}';
33

44
describe('{{ name }}.vue', () => {
5-
it('should render correct contents', () => {
6-
const Constructor = Vue.extend(Component);
7-
const propsData = {text: 'Test text'};
5+
const Constructor = Vue.extend(Component);
6+
const propsData = {text: 'Test text'};
7+
8+
it('should instance the right component', () => {
9+
const vm = new Constructor({propsData});
10+
expect(vm.$options.name).to.equal('{{ name }}');
11+
});
12+
13+
it('should render correct content', () => {
814
const vm = new Constructor({propsData}).$mount();
9-
expect(vm.$el.querySelector('strong').textContent)
10-
.to.equal(propsData.text);
15+
expect(vm.$el.innerHTML).to.equal(propsData.text);
1116
});
1217
});

0 commit comments

Comments
 (0)