Skip to content

Commit 7c355b8

Browse files
committed
plotly#189 adding actual DOM axis tick order tests for a couple of less trivial places
1 parent d6fad10 commit 7c355b8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/jasmine/tests/calcdata_test.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ describe('calculated data and points', function() {
6868

6969
describe('domain alphanumerical category ordering', function() {
7070

71-
// TODO augment test cases with selection on the DOM to ensure that ticks are there in proper order
72-
7371
it('should output categories in ascending domain alphanumerical order', function() {
7472

7573
Plotly.plot(gd, [{x: ['c','a','e','b','d'], y: [15,11,12,13,14]}], { xaxis: {
@@ -223,8 +221,6 @@ describe('calculated data and points', function() {
223221

224222
it('should output categories in explicitly supplied order even if some missing categories were at the beginning or end of categorylist', function() {
225223

226-
// The auto-range feature currently eliminates unutilized category ticks on the left/right edge
227-
228224
Plotly.plot(gd, [{x: ['c','a','e','b','d'], y: [15,11,12,13,14]}], { xaxis: {
229225
type: 'category',
230226
categorymode: 'array',
@@ -236,6 +232,14 @@ describe('calculated data and points', function() {
236232
expect(gd.calcdata[0][2]).toEqual(jasmine.objectContaining({x: 6, y: 12}));
237233
expect(gd.calcdata[0][3]).toEqual(jasmine.objectContaining({x: 1, y: 13}));
238234
expect(gd.calcdata[0][4]).toEqual(jasmine.objectContaining({x: 4, y: 14}));
235+
236+
// The auto-range feature currently eliminates unused category ticks on the left/right axis tails.
237+
// The below test case reifies this current behavior, and checks proper order of categories kept.
238+
239+
var domTickTexts = Array.prototype.slice.call(document.querySelectorAll('g.xtick'))
240+
.map(function(e) {return e.__data__.text;});
241+
242+
expect(domTickTexts).toEqual(['b', 'x', 'a', 'd', 'z', 'e', 'c']); // y, q and k has no data points
239243
});
240244

241245
it('should output categories in explicitly supplied order even if some missing categories were at the beginning or end of categorylist', function() {
@@ -255,6 +259,11 @@ describe('calculated data and points', function() {
255259
expect(gd.calcdata[0][2]).toEqual(jasmine.objectContaining({x: 6, y: 12}));
256260
expect(gd.calcdata[0][3]).toEqual(jasmine.objectContaining({x: 1, y: 13}));
257261
expect(gd.calcdata[0][4]).toEqual(jasmine.objectContaining({x: 4, y: 14}));
262+
263+
var domTickTexts = Array.prototype.slice.call(document.querySelectorAll('g.xtick'))
264+
.map(function(e) {return e.__data__.text;});
265+
266+
expect(domTickTexts).toEqual(['y', 'b', 'x', 'a', 'd', 'z', 'e', 'c']); // q, k has no data; y is null
258267
});
259268

260269
it('should output categories in explicitly supplied order even if not all categories are present, and should interact with a null value orthogonally', function() {

0 commit comments

Comments
 (0)