Skip to content

Commit 9efb321

Browse files
committed
add jasmine test for ternary 'layer'
1 parent f6dd5d5 commit 9efb321

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

test/jasmine/tests/ternary_test.js

+73-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ var supplyLayoutDefaults = require('@src/plots/ternary/layout/defaults');
66
var d3 = require('d3');
77
var createGraphDiv = require('../assets/create_graph_div');
88
var destroyGraphDiv = require('../assets/destroy_graph_div');
9+
var fail = require('../assets/fail_test');
910
var mouseEvent = require('../assets/mouse_event');
1011
var click = require('../assets/click');
1112
var doubleClick = require('../assets/double_click');
1213
var customMatchers = require('../assets/custom_matchers');
1314
var getClientPosition = require('../assets/get_client_position');
1415

15-
1616
describe('ternary plots', function() {
1717
'use strict';
1818

@@ -244,6 +244,78 @@ describe('ternary plots', function() {
244244
});
245245
});
246246

247+
it('should be able to reorder axis layers when relayout\'ing *layer*', function(done) {
248+
var gd = createGraphDiv();
249+
var fig = Lib.extendDeep({}, require('@mocks/ternary_simple.json'));
250+
var dflt = [
251+
'draglayer', 'plotbg', 'backplot', 'grids',
252+
'frontplot',
253+
'aaxis', 'aline', 'baxis', 'bline', 'caxis', 'cline'
254+
];
255+
256+
function _assert(layers) {
257+
var toplevel = d3.selectAll('g.ternary > .toplevel');
258+
259+
expect(toplevel.size()).toBe(layers.length, '# of layer');
260+
261+
toplevel.each(function(d, i) {
262+
var className = d3.select(this)
263+
.attr('class')
264+
.split('toplevel ')[1];
265+
266+
expect(className).toBe(layers[i], 'layer ' + i);
267+
});
268+
}
269+
270+
Plotly.plot(gd, fig).then(function() {
271+
_assert(dflt);
272+
return Plotly.relayout(gd, 'ternary.aaxis.layer', 'below traces');
273+
})
274+
.then(function() {
275+
_assert([
276+
'draglayer', 'plotbg', 'backplot', 'grids',
277+
'aaxis', 'aline',
278+
'frontplot',
279+
'baxis', 'bline', 'caxis', 'cline'
280+
]);
281+
return Plotly.relayout(gd, 'ternary.caxis.layer', 'below traces');
282+
})
283+
.then(function() {
284+
_assert([
285+
'draglayer', 'plotbg', 'backplot', 'grids',
286+
'aaxis', 'aline', 'caxis', 'cline',
287+
'frontplot',
288+
'baxis', 'bline'
289+
]);
290+
return Plotly.relayout(gd, 'ternary.baxis.layer', 'below traces');
291+
})
292+
.then(function() {
293+
_assert([
294+
'draglayer', 'plotbg', 'backplot', 'grids',
295+
'aaxis', 'aline', 'baxis', 'bline', 'caxis', 'cline',
296+
'frontplot'
297+
]);
298+
return Plotly.relayout(gd, 'ternary.aaxis.layer', null);
299+
})
300+
.then(function() {
301+
_assert([
302+
'draglayer', 'plotbg', 'backplot', 'grids',
303+
'baxis', 'bline', 'caxis', 'cline',
304+
'frontplot',
305+
'aaxis', 'aline'
306+
]);
307+
return Plotly.relayout(gd, {
308+
'ternary.baxis.layer': null,
309+
'ternary.caxis.layer': null
310+
});
311+
})
312+
.then(function() {
313+
_assert(dflt);
314+
})
315+
.catch(fail)
316+
.then(done);
317+
});
318+
247319
function countTernarySubplot() {
248320
return d3.selectAll('.ternary').size();
249321
}

0 commit comments

Comments
 (0)