Skip to content

Commit 9c66f81

Browse files
Add test for new attributes default and coerce
1 parent df96a13 commit 9c66f81

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/jasmine/tests/range_slider_test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,69 @@ describe('the range slider', function() {
559559
});
560560
});
561561

562+
fdescribe('yaxis options', function() {
563+
564+
it('should be set one yaxis is present', function() {
565+
var mock = {
566+
layout: {
567+
xaxis: { rangeslider: {} },
568+
yaxis: { }
569+
}
570+
};
571+
572+
supplyAllDefaults(mock);
573+
574+
expect(mock._fullLayout.xaxis.rangeslider.yaxis).toEqual({ rangemode: 'match' });
575+
});
576+
577+
it('should set multiple yaxis with data are present', function() {
578+
var mock = {
579+
data: [
580+
{y: [1, 2]},
581+
{y: [1, 2], yaxis: 'y2'}
582+
],
583+
layout: {
584+
xaxis: { rangeslider: {} },
585+
yaxis: { },
586+
yaxis2: { },
587+
yaxis3: { }
588+
}
589+
};
590+
591+
supplyAllDefaults(mock);
592+
593+
expect(mock._fullLayout.xaxis.rangeslider.yaxis).toEqual({ rangemode: 'match' });
594+
expect(mock._fullLayout.xaxis.rangeslider.yaxis2).toEqual({ rangemode: 'match' });
595+
expect(mock._fullLayout.xaxis.rangeslider.yaxis3).toEqual(undefined);
596+
});
597+
598+
it('should honor user settings', function() {
599+
var mock = {
600+
data: [
601+
{y: [1, 2]},
602+
{y: [1, 2], yaxis: 'y2'},
603+
{y: [1, 2], yaxis: 'y3'}
604+
],
605+
layout: {
606+
xaxis: { rangeslider: {
607+
yaxis: { rangemode: 'auto' },
608+
yaxis2: { rangemode: 'fixed' },
609+
yaxis3: { range: [0, 1] }
610+
} },
611+
yaxis: { },
612+
yaxis2: { },
613+
yaxis3: { }
614+
}
615+
};
616+
617+
supplyAllDefaults(mock);
618+
619+
expect(mock._fullLayout.xaxis.rangeslider.yaxis).toEqual({ rangemode: 'auto', range: [-1, 4] });
620+
expect(mock._fullLayout.xaxis.rangeslider.yaxis2).toEqual({ rangemode: 'fixed', range: [-1, 4] });
621+
expect(mock._fullLayout.xaxis.rangeslider.yaxis3).toEqual({ rangemode: 'fixed', range: [0, 1] });
622+
});
623+
});
624+
562625
describe('anchored axes fixedrange', function() {
563626

564627
it('should default to *true* when range slider is visible', function() {

0 commit comments

Comments
 (0)