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

Commit 8b81f24

Browse files
committed
continue tests
1 parent c9f1e05 commit 8b81f24

File tree

11 files changed

+147
-22
lines changed

11 files changed

+147
-22
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ install:
55
- npm install
66
script:
77
- npm run test-client
8-
- npm run test-server
8+
- npm run test-client-vuex
9+
- npm run test-server
10+
- npm run test-server-vuex

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
"scripts": {
2929
"build": "babel lib -d compiled",
3030
"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",
31+
"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",
3132
"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",
3233
"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",
34+
"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",
3335
"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"
3436
},
3537
"license": "MIT",

test/child-row.spec.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import childRow from './setup/ChildRow.vue';
2+
import {mount} from 'vue-test-utils';
23

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

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

78
beforeEach(()=>{
8-
99
setOptions({
10-
childRow,
10+
childRow
1111
});
1212

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

8181
});
8282

83+
it('can position the toggler in the last column', (done)=>{
84+
85+
setOptions({
86+
childRow,
87+
childRowTogglerFirst:false
88+
});
89+
90+
run(function() {
91+
not_exists('table tbody tr td:first-child .VueTables__child-row-toggler');
92+
exists('table tbody tr td:last-child .VueTables__child-row-toggler');
93+
},done);
94+
95+
96+
});
97+
98+
// it.only('only mount the clicked row, without remounting other open rows (regression test for issue #272)', (done)=>{
99+
100+
// // The issue only occurs with open rows that come AFTER the clicked row
101+
102+
// const FIRST_ROW_ID = 245;
103+
// const SECOND_ROW_ID = 244;
104+
105+
// vm().toggleChildRow(SECOND_ROW_ID);
106+
107+
// setTimeout(()=>{
108+
// vm().toggleChildRow(FIRST_ROW_ID);
109+
// },100);
110+
111+
// run(()=>{
112+
// console.log(wrapper.emitted());
113+
// expect(wrapper.emitted().mounted_child_row.length).toBe(2);
114+
// },done,1000);
115+
116+
// });
83117

84118
});

test/display.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
describe(suite +': Basic Display (default options)', () => {
2-
2+
33
var records = 50;
44

55
it('Discerns the headings based on the columns prop', () => {

test/filters.spec.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
describe(suite + ': Filters (Common)', function() {
2+
it('can display column filters', ()=>{
3+
4+
createWrapper({filterByColumn:true});
5+
6+
exists('.VueTables__filters-row');
7+
exists('[name="vf__code"]');
8+
exists('[name="vf__name"]');
9+
exists('[name="vf__uri"]');
10+
11+
});
12+
13+
it('can display list filters', ()=>{
14+
15+
createWrapper({
16+
filterByColumn:true,
17+
listColumns:{
18+
id:[
19+
{
20+
id:245,
21+
text:'Zimbabwe'
22+
},
23+
{
24+
id:244,
25+
text:'Zambia'
26+
}
27+
]
28+
}}, ['id','name','code','uri']);
29+
30+
31+
exists('.VueTables__filters-row select[name="vf__id"]');
32+
see('Select id', '.VueTables__filters-row select[name="vf__id"] option:first-child');
33+
see('Zimbabwe', '.VueTables__filters-row select[name="vf__id"] option:nth-child(2)');
34+
see('Zambia', '.VueTables__filters-row select[name="vf__id"] option:nth-child(3)');
35+
36+
});
37+
38+
});

test/server/request.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('Server: Request', () => {
1+
describe(suite + ': Request', () => {
22

33
var initialParams = {
44
query: '',

test/setup/ChildRow.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
</template>
66

77
<script>
8+
89
export default {
9-
props:['data']
10+
name:'ChildRow',
11+
props:['data'],
12+
mounted() {
13+
// console.log(this.$parent.$data);
14+
this.$parent.$emit(`mounted_child_row`, this.data.id);
15+
}
1016
}
1117
</script>

test/setup/client-setup.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11

22
import Vue from 'vue'
3+
import Vuex from 'vuex'
34
import { mount } from 'vue-test-utils'
45
import ClientTable from '../../compiled/v-client-table'
6+
import {Event} from '../../compiled/index.js';
57
import data from './example-data'
68

9+
global.VueEvent = Event;
710
global.suite = 'Client';
811

9-
global.run = function(cb, done) {
12+
if (withVuex()) {
13+
suite+=" - Vuex";
14+
Vue.use(Vuex);
15+
}
16+
17+
global.run = function(cb, done, timeout = 0) {
1018
setTimeout(()=>{
1119
cb();
1220
done();
13-
}, 0);
21+
},timeout);
1422
}
1523

1624
beforeEach(function() {
17-
global.wrapper = mount(ClientTable.install(Vue), {
25+
createWrapper();
26+
});
27+
28+
global.createWrapper = function(options = {}, columns = null) {
29+
30+
let params = {
1831
propsData:{
19-
columns:['code','name','uri'],
32+
name:'client',
33+
columns:columns?columns:['code','name','uri'],
2034
data,
21-
options:{}
35+
options
2236
}
23-
});
24-
});
37+
};
38+
39+
if (withVuex()) {
40+
params.store = new Vuex.Store();
41+
}
42+
43+
global.wrapper = mount(ClientTable.install(Vue,{},withVuex()), params);
44+
}
2545

test/setup/server-setup.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Vue from 'vue'
2+
import Vuex from 'vuex'
23
import { mount } from 'vue-test-utils'
34
import ServerTable from '../../compiled/v-server-table.js'
45

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

910
import data from './example-data';
1011

12+
if (withVuex()) {
13+
Vue.use(Vuex);
14+
suite+=' - Vuex';
15+
}
16+
1117
beforeEach(()=>{
1218
moxios.install(axios);
1319

@@ -18,16 +24,9 @@ beforeEach(()=>{
1824
count:data.length
1925
}
2026
});
21-
22-
global.wrapper = mount(ServerTable.install(Vue), {
23-
propsData:{
24-
columns:['code','name','uri'],
25-
url:'get-data',
26-
options:{}
27-
}
28-
});
29-
3027

28+
createWrapper();
29+
3130
});
3231

3332

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

44+
global.createWrapper = function(options = {}, columns = null) {
45+
46+
var params = {
47+
propsData:{
48+
name:'server',
49+
columns:columns?columns:['code','name','uri'],
50+
url:'get-data',
51+
options
52+
}
53+
};
54+
55+
if (withVuex()) {
56+
params.store = new Vuex.Store();
57+
}
58+
59+
global.wrapper = mount(ServerTable.install(Vue, {} ,withVuex()), params);
60+
}

test/setup/setup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ global.exists = function(selector) {
2020
expect(wrapper.contains(selector)).toBe(true);
2121
}
2222

23+
global.not_exists = function(selector) {
24+
expect(wrapper.contains(selector)).toBe(false);
25+
}
2326

2427
global.count = function(selector, count) {
2528
expect(wrapper.findAll(selector)).toHaveLength(count);
@@ -33,5 +36,8 @@ global.click = function(selector) {
3336
wrapper.find(selector).trigger('click');
3437
}
3538

39+
global.withVuex = function() {
40+
return typeof useVuex!='undefined';
41+
}
3642

3743

test/setup/with-vuex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global.useVuex = true;

0 commit comments

Comments
 (0)