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

Commit

Permalink
change component test, fix test errors and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
klarkc committed Oct 22, 2017
1 parent a422177 commit ea65751
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ available in the window['{{name}}'] variable.

## Tests

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

`npm run test`
`npm run test:watch`
Expand Down
4 changes: 4 additions & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@
},
"devDependencies": {
"babel-preset-es2015": "^6.24.1",
"chai": "^4.1.2",
"eslint": "^3.17.1",
"eslint-plugin-vue": "beta",
"karma-chai": "^0.1.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-phantomjs-shim": "^1.5.0",
"node-glob": "^1.2.0",
"poi": "^9.3.10",
"poi-preset-karma": "^9.1.0",
Expand Down
9 changes: 5 additions & 4 deletions template/poi.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const presetKarma = require('poi-preset-karma');
const webpack = require('webpack');
const glob = require('glob').sync;
const {name} = require('./package.json');

Expand All @@ -7,13 +8,13 @@ module.exports = {
filename: {
js: name + '.min.js',
},
sourceMap: false,
sourceMap: true,
html: false,
presets: [
presetKarma({
files: ['test/specs/**/*.spec.js'],
files: ['./test/specs/**.spec.js'],
browsers: ['PhantomJS'],
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
frameworks: ['mocha', 'chai', 'phantomjs-shim'],
})
]
],
};
13 changes: 0 additions & 13 deletions template/test/index.js

This file was deleted.

15 changes: 10 additions & 5 deletions template/test/specs/Component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import Vue from 'vue';
import Component from '../../src/{{ name }}/{{ name }}';

describe('{{ name }}.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(Component);
const propsData = {text: 'Test text'};
const Constructor = Vue.extend(Component);
const propsData = {text: 'Test text'};

it('should instance the right component', () => {
const vm = new Constructor({propsData});
expect(vm.$options.name).to.equal('{{ name }}');
});

it('should render correct content', () => {
const vm = new Constructor({propsData}).$mount();
expect(vm.$el.querySelector('strong').textContent)
.to.equal(propsData.text);
expect(vm.$el.innerHTML).to.equal(propsData.text);
});
});

0 comments on commit ea65751

Please sign in to comment.