Skip to content

Commit 5aca807

Browse files
committed
add box plot tests an improve gl3d tests
1 parent 48fabdd commit 5aca807

File tree

2 files changed

+96
-28
lines changed

2 files changed

+96
-28
lines changed

test/jasmine/tests/box_test.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,86 @@ describe('Test boxes supplyDefaults', function() {
636636
});
637637
});
638638

639+
describe('Test box converting numeric strings', function() {
640+
it('should disable converting numeric strings using axis.convertnumeric', function() {
641+
var gd = {
642+
layout: {
643+
xaxis: {
644+
convertnumeric: false
645+
}
646+
},
647+
data: [{
648+
type: 'box',
649+
x: ['3', '0', '1', '2'],
650+
651+
xaxis: 'x',
652+
lowerfence: ['0', '0', '0', '0'],
653+
q1: ['0.5', '1', '1.5', '2'],
654+
median: ['1', '2', '3', '4'],
655+
q3: ['1.5', '3', '4.5', '6'],
656+
upperfence: ['2', '4', '6', '8'],
657+
}]
658+
};
659+
660+
supplyAllDefaults(gd);
661+
662+
expect(gd._fullLayout.xaxis.convertnumeric).toBe(false);
663+
expect(gd._fullLayout.xaxis.type).toBe('category');
664+
});
665+
666+
it('should enable converting numeric strings using axis.convertnumeric', function() {
667+
var gd = {
668+
layout: {
669+
axesconvertnumeric: false,
670+
xaxis: {
671+
convertnumeric: true
672+
}
673+
},
674+
data: [{
675+
type: 'box',
676+
x: ['3', '0', '1', '2'],
677+
678+
xaxis: 'x',
679+
lowerfence: ['0', '0', '0', '0'],
680+
q1: ['0.5', '1', '1.5', '2'],
681+
median: ['1', '2', '3', '4'],
682+
q3: ['1.5', '3', '4.5', '6'],
683+
upperfence: ['2', '4', '6', '8'],
684+
}]
685+
};
686+
687+
supplyAllDefaults(gd);
688+
689+
expect(gd._fullLayout.xaxis.convertnumeric).toBe(true);
690+
expect(gd._fullLayout.xaxis.type).toBe('linear');
691+
});
692+
693+
it('should enable converting numeric inherit defaults from layout.axesconvertnumeric', function() {
694+
var gd = {
695+
layout: {
696+
axesconvertnumeric: false,
697+
xaxis: {}
698+
},
699+
data: [{
700+
type: 'box',
701+
x: ['3', '0', '1', '2'],
702+
703+
xaxis: 'x',
704+
lowerfence: ['0', '0', '0', '0'],
705+
q1: ['0.5', '1', '1.5', '2'],
706+
median: ['1', '2', '3', '4'],
707+
q3: ['1.5', '3', '4.5', '6'],
708+
upperfence: ['2', '4', '6', '8'],
709+
}]
710+
};
711+
712+
supplyAllDefaults(gd);
713+
714+
expect(gd._fullLayout.xaxis.convertnumeric).toBe(false);
715+
expect(gd._fullLayout.xaxis.type).toBe('category');
716+
});
717+
});
718+
639719
describe('Test box hover:', function() {
640720
var gd;
641721

test/jasmine/tests/gl3dlayout_test.js

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -387,29 +387,23 @@ describe('Test Gl3d layout defaults', function() {
387387
it('should disable converting numeric strings using axis.convertnumeric', function() {
388388
supplyLayoutDefaults({
389389
scene: {
390-
xaxis: {
391-
convertnumeric: false
392-
},
393-
yaxis: {
394-
convertnumeric: false
395-
},
396-
zaxis: {
397-
convertnumeric: false
398-
}
390+
xaxis: { convertnumeric: false },
391+
yaxis: {},
392+
zaxis: { convertnumeric: false }
399393
}
400394
}, layoutOut, [{
401395
type: 'scatter3d',
402-
x: ['0', '1', '1970', '2000'],
403-
y: ['0', '1', '1970', '2000'],
404-
z: ['0', '1', '1970', '2000'],
396+
x: ['1970', '2000', '0', '1'],
397+
y: ['1970', '2000', '0', '1'],
398+
z: ['1970', '2000', '0', '1'],
405399
scene: 'scene'
406400
}]);
407401

408402
expect(layoutOut.scene.xaxis.convertnumeric).toBe(false);
409-
expect(layoutOut.scene.yaxis.convertnumeric).toBe(false);
403+
expect(layoutOut.scene.yaxis.convertnumeric).toBe(true);
410404
expect(layoutOut.scene.zaxis.convertnumeric).toBe(false);
411405
expect(layoutOut.scene.xaxis.type).toBe('category');
412-
expect(layoutOut.scene.yaxis.type).toBe('category');
406+
expect(layoutOut.scene.yaxis.type).toBe('linear');
413407
expect(layoutOut.scene.zaxis.type).toBe('category');
414408
});
415409

@@ -418,29 +412,23 @@ describe('Test Gl3d layout defaults', function() {
418412

419413
supplyLayoutDefaults({
420414
scene: {
421-
xaxis: {
422-
convertnumeric: true
423-
},
424-
yaxis: {
425-
convertnumeric: true
426-
},
427-
zaxis: {
428-
convertnumeric: true
429-
}
415+
xaxis: { convertnumeric: true },
416+
yaxis: {},
417+
zaxis: { convertnumeric: true }
430418
}
431419
}, layoutOut, [{
432420
type: 'scatter3d',
433-
x: ['0', '1', '1970', '2000'],
434-
y: ['0', '1', '1970', '2000'],
435-
z: ['0', '1', '1970', '2000'],
421+
x: ['1970', '2000', '0', '1'],
422+
y: ['1970', '2000', '0', '1'],
423+
z: ['1970', '2000', '0', '1'],
436424
scene: 'scene'
437425
}]);
438426

439427
expect(layoutOut.scene.xaxis.convertnumeric).toBe(true);
440-
expect(layoutOut.scene.yaxis.convertnumeric).toBe(true);
428+
expect(layoutOut.scene.yaxis.convertnumeric).toBe(false);
441429
expect(layoutOut.scene.zaxis.convertnumeric).toBe(true);
442430
expect(layoutOut.scene.xaxis.type).toBe('linear');
443-
expect(layoutOut.scene.yaxis.type).toBe('linear');
431+
expect(layoutOut.scene.yaxis.type).toBe('category');
444432
expect(layoutOut.scene.zaxis.type).toBe('linear');
445433
});
446434
});

0 commit comments

Comments
 (0)