Skip to content

Commit

Permalink
Create first test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 6, 2016
1 parent a874195 commit 2246059
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 26 deletions.
7 changes: 3 additions & 4 deletions test/unit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
var testsContext = require.context('./specs', true, /\.spec$/);
testsContext.keys().forEach(testsContext);

/*

// require all src files except main.js for coverage.
// you can also change this to match only the subset of files that
// you want coverage for.
var srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
srcContext.keys().forEach(srcContext)
*/
var srcContext = require.context('src', true, /\.(js|vue)$/);
srcContext.keys().forEach(srcContext);
50 changes: 50 additions & 0 deletions test/unit/specs/VueFormGenerator.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { expect } from "chai";

import Vue from "vue";
import VueFormGenerator from "src/index";

function createFormGenerator(schema, model, options, done) {
let el = document.createElement("div");
el.innerHTML = `<vue-form-generator :schema="schema" :model="model" :options="options"></vue-form-generator>`;

let vm = new Vue({
el: el,
data: {
schema,
model,
options
}
});

vm.$nextTick(() => {
console.log(el);
done(el, vm);
});
}

describe("VueFormGenerator.vue", () => {

let el, vm;

Vue.component("VueFormGenerator", VueFormGenerator.component);

beforeEach((done) => {
createFormGenerator({}, null, {}, (_el, _vm) => {
el = _el;
vm = _vm;
done();
});
});

it("should be create HTML divs", () => {
expect(vm.$el).to.be.exist;
expect(el.getElementsByTagName("table")).to.be.length(1);

let table = el.getElementsByTagName("table")[0];

});




});
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { expect } from "chai";

import VueFormGenerator from "src/index";

describe("VueFormGenerator", () => {

it("class properties", () => {

expect(true).to.be.true;

Expand All @@ -15,4 +13,4 @@ describe("VueFormGenerator", () => {

});

})
})
40 changes: 21 additions & 19 deletions test/unit/webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
var path = require("path");
var webpack = require('webpack');

var sourceDir = path.resolve(__dirname, '../../src');
module.exports = {
devtool: '#inline-source-map',

module: {
preLoaders: [
{
test: /\.js$/,
loader: 'isparta',
include: sourceDir,
exclude: /node_modules/
}
],

loaders: [
{
"test": /\.js?$/,
"test": /\.vue$/,
"loader": "vue"
},
{
"test": /\.js$/,
//"include": /test\/unit/,
"exclude": /node_modules/,
"loader": "babel",
"query": {
"presets": [
"es2015",
"stage-0"
],
"plugins": []
}
"loader": "babel"
},
{
"test": /\.css?$/,
Expand All @@ -30,10 +37,6 @@ module.exports = {
"test": /\.jade?$/,
"loader": "jade"
},
{
"test": /\.vue?$/,
"loader": "vue"
},
{
test: /\.(woff2?|svg)$/,
loader: 'url'
Expand All @@ -47,22 +50,21 @@ module.exports = {
},

resolve: {
packageAlias: 'browser',
packageAlias: 'browser',
alias: {
'src': path.resolve(__dirname, '../../src')
'src': sourceDir
}
},

plugins: [
],

vue: {
autoprefixer: {
browsers: ['last 2 versions']
}/*,
},
loaders: {
js: 'isparta'
}*/
}
}

};

0 comments on commit 2246059

Please sign in to comment.