forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscattergl_test.js
97 lines (90 loc) · 3.14 KB
/
scattergl_test.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
var Plotly = require('@lib/index');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
describe('end-to-end scattergl tests', function() {
var gd;
beforeEach(function() {
gd = createGraphDiv();
});
afterEach(destroyGraphDiv);
it('should create a plot with text labels', function(done) {
Plotly.react(gd, [{
type: 'scattergl',
mode: 'text+lines',
x: [1, 2, 3, 4, 5, 6, 7],
y: [2, 3, 4, 5, 6, 7, 8],
text: 'Test'
}]).then(function() {
var fullLayout = gd._fullLayout;
var subplot = fullLayout._plots.xy;
var scene = subplot._scene;
expect(scene.glText.length).toEqual(1);
}).catch(failTest).then(done);
});
it('should update a plot with text labels', function(done) {
Plotly.react(gd, [{
type: 'scattergl',
mode: 'text+lines',
x: [1, 2, 3, 4, 5, 6, 7],
y: [2, 3, 4, 5, 6, 7, 8],
text: 'Test'
}]).then(function() {
var fullLayout = gd._fullLayout;
var subplot = fullLayout._plots.xy;
var scene = subplot._scene;
expect(scene.glText.length).toEqual(1);
// add plots
return Plotly.react(gd, [
{
type: 'scattergl',
mode: 'text+lines',
x: [1, 2, 3, 4, 5, 6, 7],
y: [2, 3, 4, 5, 6, 7, 8],
text: 'Test'
},
{
type: 'scattergl',
mode: 'text+lines',
x: [1, 2, 3, 4, 5, 6, 7],
y: [3, 4, 5, 6, 7, 8, 9],
text: 'Test 2'
},
{
type: 'scattergl',
mode: 'text+lines',
x: [1, 2, 3, 4, 5, 6, 7],
y: [4, 5, 6, 7, 8, 9, 10],
text: 'Test 3'
}
]);
}).then(function() {
var fullLayout = gd._fullLayout;
var subplot = fullLayout._plots.xy;
var scene = subplot._scene;
expect(scene.glText.length).toEqual(3);
// remove plots
return Plotly.react(gd, [
{
type: 'scattergl',
mode: 'text+lines',
x: [1, 2, 3, 4, 5, 6, 7],
y: [2, 3, 4, 5, 6, 7, 8],
text: 'Test'
},
{
type: 'scattergl',
mode: 'text+lines',
x: [1, 2, 3, 4, 5, 6, 7],
y: [3, 4, 5, 6, 7, 8, 9],
text: 'Test 2'
}
]);
}).then(function() {
var fullLayout = gd._fullLayout;
var subplot = fullLayout._plots.xy;
var scene = subplot._scene;
expect(scene.glText.length).toEqual(2);
}).catch(failTest).then(done);
});
});