-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapshotTest.js
55 lines (46 loc) · 1.44 KB
/
snapshotTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { GlobalView } from '../../../dist/global-view';
export default class SnapshotTest {
constructor(div, ondone) {
this.div = div;
this.ondone = ondone;
this.plot = this.createPlot();
this.timeOutMS = 500;
this.run();
}
// creates the GlobalView plot
createPlot() {
return new GlobalView(this.div, this.getPlotOptions());
}
// returns the GlobalView plot
getPlot() {
return this.plot;
}
// calls the callback function after a default timeout
callOnDone() {
setTimeout(() => {
this.ondone();
}, this.getTimeOutMS());
}
// default dataset to be used with the tests
static getDatasetName() {
return 'datasets/iris.data';
}
// default dataset column names (if not specified in the dataset itself)
static getDatasetColumnNames() {
return ['Sepal Length [cm]', 'Sepal Width [cm]', 'Petal Length [cm]', 'Petal Width [cm]', 'Class'];
}
// Override to specify any specific plot options
getPlotOptions() { // eslint-disable-line class-methods-use-this
return null;
}
// Override with with the code to run the specific test
// Make sure to either run the default this.callOnDone, or the callback this.ondone()
// manually (e.g. if the call back should be called after a conditions is passed)
run() {
this.callOnDone();
}
// the timeout to wait before calling the callback. Override to modify the wait time.
getTimeOutMS() {
return this.timeOutMS;
}
}