Skip to content

Commit a91a58d

Browse files
committed
drop Plotly.Queue from the API - adopt tests
1 parent 9b30fea commit a91a58d

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/core.js

-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,3 @@ exports.Fx = {
9090
};
9191
exports.Snapshot = require('./snapshot');
9292
exports.PlotSchema = require('./plot_api/plot_schema');
93-
exports.Queue = require('./lib/queue');

test/jasmine/tests/frame_api_test.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
3+
var Queue = require('@src/lib/queue');
34

45
var createGraphDiv = require('../assets/create_graph_div');
56
var destroyGraphDiv = require('../assets/destroy_graph_div');
@@ -181,7 +182,7 @@ describe('Test frame api', function() {
181182
expect(f[7]).toEqual({name: 'frame7', data: [2]});
182183
expect(f[10]).toEqual({name: 'frame10', data: [3]});
183184

184-
return Plotly.Queue.undo(gd);
185+
return Queue.undo(gd);
185186
})
186187
.then(validate)
187188
.then(done, done.fail);
@@ -207,7 +208,7 @@ describe('Test frame api', function() {
207208
expect(f[7]).toEqual({name: 'frame7', data: [2]});
208209
expect(f[10]).toEqual({name: 'frame10', data: [3]});
209210

210-
return Plotly.Queue.undo(gd);
211+
return Queue.undo(gd);
211212
})
212213
.then(validate)
213214
.then(done, done.fail);
@@ -220,12 +221,12 @@ describe('Test frame api', function() {
220221
}
221222

222223
Plotly.addFrames(gd, [{name: 'frame 0'}, {name: 'frame 1'}]).then(validate).then(function() {
223-
return Plotly.Queue.undo(gd);
224+
return Queue.undo(gd);
224225
}).then(function() {
225226
expect(f).toEqual([]);
226227
expect(h).toEqual({});
227228

228-
return Plotly.Queue.redo(gd);
229+
return Queue.redo(gd);
229230
})
230231
.then(validate)
231232
.then(done, done.fail);
@@ -242,12 +243,12 @@ describe('Test frame api', function() {
242243
expect(f).toEqual([{name: 'test1'}, {name: 'test2'}, {name: 'test3'}]);
243244
expect(Object.keys(h)).toEqual(['test1', 'test2', 'test3']);
244245

245-
return Plotly.Queue.undo(gd);
246+
return Queue.undo(gd);
246247
}).then(function() {
247248
expect(f).toEqual([{name: 'test1', data: ['y']}, {name: 'test2'}]);
248249
expect(Object.keys(h)).toEqual(['test1', 'test2']);
249250

250-
return Plotly.Queue.redo(gd);
251+
return Queue.redo(gd);
251252
}).then(function() {
252253
expect(f).toEqual([{name: 'test1'}, {name: 'test2'}, {name: 'test3'}]);
253254
expect(Object.keys(h)).toEqual(['test1', 'test2', 'test3']);
@@ -267,11 +268,11 @@ describe('Test frame api', function() {
267268
expect(f).toEqual([]);
268269
expect(Object.keys(h)).toEqual([]);
269270

270-
return Plotly.Queue.undo(gd);
271+
return Queue.undo(gd);
271272
}).then(function() {
272273
expect(f).toEqual([{name: 'frame1'}]);
273274

274-
return Plotly.Queue.redo(gd);
275+
return Queue.redo(gd);
275276
}).then(function() {
276277
expect(f).toEqual([]);
277278
expect(Object.keys(h)).toEqual([]);
@@ -297,13 +298,13 @@ describe('Test frame api', function() {
297298
Plotly.addFrames(gd, frames).then(function() {
298299
return Plotly.deleteFrames(gd, [2, 8, 4, 6]);
299300
}).then(validate).then(function() {
300-
return Plotly.Queue.undo(gd);
301+
return Queue.undo(gd);
301302
}).then(function() {
302303
for(i = 0; i < 10; i++) {
303304
expect(f[i]).toEqual({name: 'frame' + i});
304305
}
305306

306-
return Plotly.Queue.redo(gd);
307+
return Queue.redo(gd);
307308
})
308309
.then(validate)
309310
.then(done, done.fail);
@@ -328,13 +329,13 @@ describe('Test frame api', function() {
328329
return Plotly.deleteFrames(gd);
329330
}).then(validateCount(0)).then(function() {
330331
// Restore:
331-
return Plotly.Queue.undo(gd);
332+
return Queue.undo(gd);
332333
}).then(validateCount(n)).then(function() {
333334
// Delete with null arg:
334335
return Plotly.deleteFrames(gd, null);
335336
}).then(validateCount(0)).then(function() {
336337
// Restore:
337-
return Plotly.Queue.undo(gd);
338+
return Queue.undo(gd);
338339
}).then(validateCount(n)).then(function() {
339340
// Delete with undefined:
340341
return Plotly.deleteFrames(gd, undefined);

test/jasmine/tests/plot_api_test.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1898,16 +1898,16 @@ describe('Test plot api', function() {
18981898
]
18991899
};
19001900

1901-
if(!Plotly.Queue) {
1902-
Plotly.Queue = {
1901+
if(!Queue) {
1902+
Queue = {
19031903
add: function() {},
19041904
startSequence: function() {},
19051905
endSequence: function() {}
19061906
};
19071907
}
19081908

19091909
spyOn(plotApi, 'redraw');
1910-
spyOn(Plotly.Queue, 'add');
1910+
spyOn(Queue, 'add');
19111911
});
19121912

19131913
it('should throw an error when gd.data isn\'t an array.', function() {
@@ -2054,9 +2054,9 @@ describe('Test plot api', function() {
20542054
}, [0, 1]);
20552055

20562056
expect(gd.data).not.toEqual(cachedData);
2057-
expect(Plotly.Queue.add).toHaveBeenCalled();
2057+
expect(Queue.add).toHaveBeenCalled();
20582058

2059-
var undoArgs = Plotly.Queue.add.calls.first().args[2];
2059+
var undoArgs = Queue.add.calls.first().args[2];
20602060

20612061
Plotly.prependTraces.apply(null, undoArgs);
20622062

@@ -2071,9 +2071,9 @@ describe('Test plot api', function() {
20712071
}, [0, 1]);
20722072

20732073
expect(gd.data).not.toEqual(cachedData);
2074-
expect(Plotly.Queue.add).toHaveBeenCalled();
2074+
expect(Queue.add).toHaveBeenCalled();
20752075

2076-
var undoArgs = Plotly.Queue.add.calls.first().args[2];
2076+
var undoArgs = Queue.add.calls.first().args[2];
20772077

20782078
Plotly.extendTraces.apply(null, undoArgs);
20792079

@@ -2089,9 +2089,9 @@ describe('Test plot api', function() {
20892089
}, [0, 1], maxPoints);
20902090

20912091
expect(gd.data).not.toEqual(cachedData);
2092-
expect(Plotly.Queue.add).toHaveBeenCalled();
2092+
expect(Queue.add).toHaveBeenCalled();
20932093

2094-
var undoArgs = Plotly.Queue.add.calls.first().args[2];
2094+
var undoArgs = Queue.add.calls.first().args[2];
20952095

20962096
Plotly.prependTraces.apply(null, undoArgs);
20972097

@@ -2148,12 +2148,12 @@ describe('Test plot api', function() {
21482148
}, [0, 1], args.maxp);
21492149

21502150
expect(plotApi.redraw).toHaveBeenCalled();
2151-
expect(Plotly.Queue.add).toHaveBeenCalled();
2151+
expect(Queue.add).toHaveBeenCalled();
21522152

21532153
expect(gd.data[0].x).toEqual(expectations.newArray);
21542154
expect(gd.data[1].x).toEqual(new Float32Array(expectations.newArray));
21552155

2156-
var cont = Plotly.Queue.add.calls.first().args[2][1].x;
2156+
var cont = Queue.add.calls.first().args[2][1].x;
21572157
expect(cont[0]).toEqual(expectations.remainder);
21582158
expect(cont[1]).toEqual(new Float32Array(expectations.remainder));
21592159
}

0 commit comments

Comments
 (0)