Skip to content

Commit 2cc639a

Browse files
committed
Add tests using AVA
1 parent d715906 commit 2cc639a

18 files changed

+4852
-164
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.idea
22
/node_modules
33
/.rpt2_cache
4+
/.nyc_output
45
/dist
56
/docs
67
/npm-debug.log

package-lock.json

Lines changed: 4093 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
},
2424
"devDependencies": {
2525
"@types/node": "^12.0.8",
26+
"ava": "^2.1.0",
2627
"gh-pages": "^2.0.1",
28+
"nyc": "^14.1.1",
2729
"rollup": "^1.15.1",
2830
"rollup-plugin-typescript2": "^0.21.1",
2931
"tslib": "^1.10.0",
@@ -34,11 +36,16 @@
3436
"dev": "rollup -c -w",
3537
"build": "rm -rf dist && rollup -c",
3638
"docs": "typedoc",
37-
"test": "node ./test",
38-
"prepublishOnly": "npm run build",
39+
"test": "nyc ava",
40+
"prepublishOnly": "npm run build && npm test",
3941
"postpublish": "npm run docs && gh-pages -d docs"
4042
},
4143
"files": [
4244
"dist"
43-
]
45+
],
46+
"ava": {
47+
"helpers": [
48+
"test/helpers/**/*"
49+
]
50+
}
4451
}

src/Commander.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ interface Command {
1212
args: Array<any>,
1313
}
1414

15-
/**
16-
* @ignore
17-
*/
1815
export default abstract class Commander {
1916
/**
2017
* @ignore
@@ -30,6 +27,14 @@ export default abstract class Commander {
3027
this.command(className, iArguments);
3128
}
3229

30+
/**
31+
* @ignore
32+
*/
33+
public static init() {
34+
this.commands = [];
35+
this.objectCount = 0;
36+
}
37+
3338
protected static command(key: string | null, method: string, iArguments: IArguments) {
3439
const args = Array.from(iArguments);
3540
this.commands.push({

src/Layout.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { Commander, Tracer } from './';
22

3-
/**
4-
* @ignore
5-
*/
63
export default abstract class Layout extends Commander {
74
/**
85
* Create a layout.

src/Tracer.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { Commander } from './';
22

3-
/**
4-
* @ignore
5-
*/
63
export default abstract class Tracer extends Commander {
74
/**
85
* Create a tracer.

test/Array1DTracer.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import test from 'ava';
2+
import Tester from './helpers/Tester';
3+
import { Array1DTracer, ChartTracer } from '..';
4+
5+
test('Array1DTracer', new Tester(execute => {
6+
let tracer;
7+
let key;
8+
let chartTracer;
9+
10+
execute([
11+
tracer = new Array1DTracer('Test Tracer'),
12+
key = tracer.key,
13+
chartTracer = new ChartTracer(),
14+
],
15+
{ key, method: 'Array1DTracer', args: ['Test Tracer'] },
16+
{ key: chartTracer.key, method: 'ChartTracer', args: [] },
17+
);
18+
19+
execute([
20+
tracer.chart(chartTracer),
21+
tracer.chart(null),
22+
],
23+
{ key, method: 'chart', args: [chartTracer.key] },
24+
{ key, method: 'chart', args: [null] },
25+
);
26+
27+
execute([
28+
tracer.depatch(1),
29+
],
30+
{ key, method: 'depatch', args: [1] },
31+
);
32+
33+
execute([
34+
tracer.deselect(2, 3),
35+
],
36+
{ key, method: 'deselect', args: [2, 3] },
37+
);
38+
39+
execute([
40+
tracer.destroy(),
41+
],
42+
{ key, method: 'destroy', args: [] },
43+
);
44+
45+
execute([
46+
tracer.patch(1, 'value'),
47+
tracer.patch(4, 999),
48+
],
49+
{ key, method: 'patch', args: [1, 'value'] },
50+
{ key, method: 'patch', args: [4, 999] },
51+
);
52+
53+
execute([
54+
tracer.reset(),
55+
],
56+
{ key, method: 'reset', args: [] },
57+
);
58+
59+
execute([
60+
tracer.select(2, 3),
61+
],
62+
{ key, method: 'select', args: [2, 3] },
63+
);
64+
65+
execute([
66+
tracer.set([1, 2, 3]),
67+
tracer.set(['a', 1, true]),
68+
],
69+
{ key, method: 'set', args: [[1, 2, 3]] },
70+
{ key, method: 'set', args: [['a', 1, true]] },
71+
);
72+
}).test);

test/Array2DTracer.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import test from 'ava';
2+
import Tester from './helpers/Tester';
3+
import { Array2DTracer } from '..';
4+
5+
test('Array2DTracer', new Tester(execute => {
6+
let tracer;
7+
let key;
8+
9+
execute([
10+
tracer = new Array2DTracer('Test Tracer'),
11+
key = tracer.key,
12+
],
13+
{ key, method: 'Array2DTracer', args: ['Test Tracer'] },
14+
);
15+
16+
execute([
17+
tracer.depatch(3, 1),
18+
],
19+
{ key, method: 'depatch', args: [3, 1] },
20+
);
21+
22+
execute([
23+
tracer.deselect(1, 2, 4, 5),
24+
tracer.deselect(1, 2),
25+
],
26+
{ key, method: 'deselect', args: [1, 2, 4, 5] },
27+
{ key, method: 'deselect', args: [1, 2] },
28+
);
29+
30+
execute([
31+
tracer.deselectCol(3, 1, 5),
32+
],
33+
{ key, method: 'deselectCol', args: [3, 1, 5] },
34+
);
35+
36+
execute([
37+
tracer.deselectRow(4, 1, 3),
38+
],
39+
{ key, method: 'deselectRow', args: [4, 1, 3] },
40+
);
41+
42+
execute([
43+
tracer.destroy(),
44+
],
45+
{ key, method: 'destroy', args: [] },
46+
);
47+
48+
execute([
49+
tracer.patch(1, 3, 'value'),
50+
tracer.patch(2, 5, 999),
51+
],
52+
{ key, method: 'patch', args: [1, 3, 'value'] },
53+
{ key, method: 'patch', args: [2, 5, 999] },
54+
);
55+
56+
execute([
57+
tracer.reset(),
58+
],
59+
{ key, method: 'reset', args: [] },
60+
);
61+
62+
execute([
63+
tracer.select(1, 3, 5, 7),
64+
tracer.select(2, 8),
65+
],
66+
{ key, method: 'select', args: [1, 3, 5, 7] },
67+
{ key, method: 'select', args: [2, 8] },
68+
);
69+
70+
execute([
71+
tracer.selectCol(3, 1, 5),
72+
],
73+
{ key, method: 'selectCol', args: [3, 1, 5] },
74+
);
75+
76+
execute([
77+
tracer.selectRow(4, 1, 3),
78+
],
79+
{ key, method: 'selectRow', args: [4, 1, 3] },
80+
);
81+
82+
execute([
83+
tracer.set([
84+
[1, 2, 3, 4],
85+
[5, 6, 7, 8],
86+
]),
87+
],
88+
{
89+
key, method: 'set', args: [[
90+
[1, 2, 3, 4],
91+
[5, 6, 7, 8],
92+
]],
93+
},
94+
);
95+
}).test);

test/ChartTracer.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import test from 'ava';
2+
import Tester from './helpers/Tester';
3+
import { ChartTracer } from '..';
4+
5+
test('ChartTracer', new Tester(execute => {
6+
let tracer;
7+
let key;
8+
let chartTracer;
9+
10+
execute([
11+
tracer = new ChartTracer('Test Tracer'),
12+
key = tracer.key,
13+
chartTracer = new ChartTracer(),
14+
],
15+
{ key, method: 'ChartTracer', args: ['Test Tracer'] },
16+
{ key: chartTracer.key, method: 'ChartTracer', args: [] },
17+
);
18+
19+
execute([
20+
tracer.chart(chartTracer),
21+
tracer.chart(null),
22+
],
23+
{ key, method: 'chart', args: [chartTracer.key] },
24+
{ key, method: 'chart', args: [null] },
25+
);
26+
27+
execute([
28+
tracer.depatch(1),
29+
],
30+
{ key, method: 'depatch', args: [1] },
31+
);
32+
33+
execute([
34+
tracer.deselect(2, 3),
35+
],
36+
{ key, method: 'deselect', args: [2, 3] },
37+
);
38+
39+
execute([
40+
tracer.destroy(),
41+
],
42+
{ key, method: 'destroy', args: [] },
43+
);
44+
45+
execute([
46+
tracer.patch(1, 'value'),
47+
tracer.patch(4, 999),
48+
],
49+
{ key, method: 'patch', args: [1, 'value'] },
50+
{ key, method: 'patch', args: [4, 999] },
51+
);
52+
53+
execute([
54+
tracer.reset(),
55+
],
56+
{ key, method: 'reset', args: [] },
57+
);
58+
59+
execute([
60+
tracer.select(2, 3),
61+
],
62+
{ key, method: 'select', args: [2, 3] },
63+
);
64+
65+
execute([
66+
tracer.set([1, 2, 3]),
67+
tracer.set(['a', 1, true]),
68+
],
69+
{ key, method: 'set', args: [[1, 2, 3]] },
70+
{ key, method: 'set', args: [['a', 1, true]] },
71+
);
72+
}).test);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy