Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Commit

Permalink
continue tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matfish2 committed Nov 15, 2017
1 parent c9f1e05 commit 8b81f24
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ install:
- npm install
script:
- npm run test-client
- npm run test-server
- npm run test-client-vuex
- npm run test-server
- npm run test-server-vuex
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
"scripts": {
"build": "babel lib -d compiled",
"test-client": "cross-env NODE_ENV=test mocha-webpack --webpack-config webpack.config.js --require test/setup/setup.js test/setup/client-setup.js test/*.spec.js test/client/*.spec.js",
"test-client-vuex": "cross-env NODE_ENV=test mocha-webpack --webpack-config webpack.config.js --require test/setup/setup.js test/setup/with-vuex.js test/setup/client-setup.js test/*.spec.js test/client/*.spec.js",
"watch-client": "cross-env NODE_ENV=test mocha-webpack --webpack-config webpack.config.js --watch --require test/setup/setup.js test/setup/client-setup.js test/*.spec.js test/client/*.spec.js",
"test-server": "cross-env NODE_ENV=test mocha-webpack --webpack-config webpack.config.js --require test/setup/setup.js test/setup/server-setup.js test/*.spec.js test/server/*.spec.js",
"test-server-vuex": "cross-env NODE_ENV=test mocha-webpack --webpack-config webpack.config.js --require test/setup/setup.js test/setup/with-vuex.js test/setup/server-setup.js test/*.spec.js test/server/*.spec.js",
"watch-server": "cross-env NODE_ENV=test mocha-webpack --webpack-config webpack.config.js --watch --require test/setup/setup.js test/setup/server-setup.js test/*.spec.js test/server/*.spec.js"
},
"license": "MIT",
Expand Down
38 changes: 36 additions & 2 deletions test/child-row.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import childRow from './setup/ChildRow.vue';
import {mount} from 'vue-test-utils';

describe(suite + ': Child row', () => {

var firstRowToggler = 'table tbody tr td:first-child span';

beforeEach(()=>{

setOptions({
childRow,
childRow
});

});
Expand Down Expand Up @@ -80,5 +80,39 @@ describe(suite + ': Child row', () => {

});

it('can position the toggler in the last column', (done)=>{

setOptions({
childRow,
childRowTogglerFirst:false
});

run(function() {
not_exists('table tbody tr td:first-child .VueTables__child-row-toggler');
exists('table tbody tr td:last-child .VueTables__child-row-toggler');
},done);


});

// it.only('only mount the clicked row, without remounting other open rows (regression test for issue #272)', (done)=>{

// // The issue only occurs with open rows that come AFTER the clicked row

// const FIRST_ROW_ID = 245;
// const SECOND_ROW_ID = 244;

// vm().toggleChildRow(SECOND_ROW_ID);

// setTimeout(()=>{
// vm().toggleChildRow(FIRST_ROW_ID);
// },100);

// run(()=>{
// console.log(wrapper.emitted());
// expect(wrapper.emitted().mounted_child_row.length).toBe(2);
// },done,1000);

// });

});
2 changes: 1 addition & 1 deletion test/display.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe(suite +': Basic Display (default options)', () => {

var records = 50;

it('Discerns the headings based on the columns prop', () => {
Expand Down
38 changes: 38 additions & 0 deletions test/filters.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
describe(suite + ': Filters (Common)', function() {
it('can display column filters', ()=>{

createWrapper({filterByColumn:true});

exists('.VueTables__filters-row');
exists('[name="vf__code"]');
exists('[name="vf__name"]');
exists('[name="vf__uri"]');

});

it('can display list filters', ()=>{

createWrapper({
filterByColumn:true,
listColumns:{
id:[
{
id:245,
text:'Zimbabwe'
},
{
id:244,
text:'Zambia'
}
]
}}, ['id','name','code','uri']);


exists('.VueTables__filters-row select[name="vf__id"]');
see('Select id', '.VueTables__filters-row select[name="vf__id"] option:first-child');
see('Zimbabwe', '.VueTables__filters-row select[name="vf__id"] option:nth-child(2)');
see('Zambia', '.VueTables__filters-row select[name="vf__id"] option:nth-child(3)');

});

});
2 changes: 1 addition & 1 deletion test/server/request.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Server: Request', () => {
describe(suite + ': Request', () => {

var initialParams = {
query: '',
Expand Down
8 changes: 7 additions & 1 deletion test/setup/ChildRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
</template>

<script>
export default {
props:['data']
name:'ChildRow',
props:['data'],
mounted() {
// console.log(this.$parent.$data);
this.$parent.$emit(`mounted_child_row`, this.data.id);
}
}
</script>
34 changes: 27 additions & 7 deletions test/setup/client-setup.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@

import Vue from 'vue'
import Vuex from 'vuex'
import { mount } from 'vue-test-utils'
import ClientTable from '../../compiled/v-client-table'
import {Event} from '../../compiled/index.js';
import data from './example-data'

global.VueEvent = Event;
global.suite = 'Client';

global.run = function(cb, done) {
if (withVuex()) {
suite+=" - Vuex";
Vue.use(Vuex);
}

global.run = function(cb, done, timeout = 0) {
setTimeout(()=>{
cb();
done();
}, 0);
},timeout);
}

beforeEach(function() {
global.wrapper = mount(ClientTable.install(Vue), {
createWrapper();
});

global.createWrapper = function(options = {}, columns = null) {

let params = {
propsData:{
columns:['code','name','uri'],
name:'client',
columns:columns?columns:['code','name','uri'],
data,
options:{}
options
}
});
});
};

if (withVuex()) {
params.store = new Vuex.Store();
}

global.wrapper = mount(ClientTable.install(Vue,{},withVuex()), params);
}

34 changes: 25 additions & 9 deletions test/setup/server-setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Vue from 'vue'
import Vuex from 'vuex'
import { mount } from 'vue-test-utils'
import ServerTable from '../../compiled/v-server-table.js'

Expand All @@ -8,6 +9,11 @@ global.moxios = require('moxios');

import data from './example-data';

if (withVuex()) {
Vue.use(Vuex);
suite+=' - Vuex';
}

beforeEach(()=>{
moxios.install(axios);

Expand All @@ -18,16 +24,9 @@ beforeEach(()=>{
count:data.length
}
});

global.wrapper = mount(ServerTable.install(Vue), {
propsData:{
columns:['code','name','uri'],
url:'get-data',
options:{}
}
});


createWrapper();

});


Expand All @@ -42,3 +41,20 @@ global.run = function(cb, done) {
});
}

global.createWrapper = function(options = {}, columns = null) {

var params = {
propsData:{
name:'server',
columns:columns?columns:['code','name','uri'],
url:'get-data',
options
}
};

if (withVuex()) {
params.store = new Vuex.Store();
}

global.wrapper = mount(ServerTable.install(Vue, {} ,withVuex()), params);
}
6 changes: 6 additions & 0 deletions test/setup/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ global.exists = function(selector) {
expect(wrapper.contains(selector)).toBe(true);
}

global.not_exists = function(selector) {
expect(wrapper.contains(selector)).toBe(false);
}

global.count = function(selector, count) {
expect(wrapper.findAll(selector)).toHaveLength(count);
Expand All @@ -33,5 +36,8 @@ global.click = function(selector) {
wrapper.find(selector).trigger('click');
}

global.withVuex = function() {
return typeof useVuex!='undefined';
}


1 change: 1 addition & 0 deletions test/setup/with-vuex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.useVuex = true;

0 comments on commit 8b81f24

Please sign in to comment.