Skip to content

Commit f7d5a3a

Browse files
committed
adjust tests
1 parent 992352b commit f7d5a3a

File tree

3 files changed

+55
-94
lines changed

3 files changed

+55
-94
lines changed

test/jasmine/tests/gl3d_plot_interact_test.js

+3
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ describe('Test gl3d modebar handlers - perspective case', function() {
455455
},
456456
aspectratio: { x: 3, y: 2, z: 1 }
457457
}
458+
},
459+
config: {
460+
modeBarButtonsToAdd: ['hoverClosest3d']
458461
}
459462
};
460463

test/jasmine/tests/modebar_test.js

+51-93
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ describe('ModeBar', function() {
342342
var buttons = getButtons([
343343
['toImage'],
344344
['zoom2d', 'pan2d'],
345-
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],
346-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
345+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']
347346
]);
348347

349348
var gd = getMockGraphInfo(['x'], ['y']);
@@ -361,8 +360,7 @@ describe('ModeBar', function() {
361360
var buttons = getButtons([
362361
['toImage'],
363362
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
364-
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],
365-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
363+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']
366364
]);
367365

368366
var gd = getMockGraphInfo(['x'], ['y']);
@@ -385,8 +383,7 @@ describe('ModeBar', function() {
385383
var buttons = getButtons([
386384
['toImage'],
387385
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
388-
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],
389-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
386+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']
390387
]);
391388

392389
var gd = getMockGraphInfo(['x'], ['y']);
@@ -407,8 +404,7 @@ describe('ModeBar', function() {
407404

408405
it('creates mode bar (cartesian fixed-axes version)', function() {
409406
var buttons = getButtons([
410-
['toImage'],
411-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
407+
['toImage']
412408
]);
413409

414410
var gd = getMockGraphInfo();
@@ -425,8 +421,7 @@ describe('ModeBar', function() {
425421
var buttons = getButtons([
426422
['toImage'],
427423
['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation'],
428-
['resetCameraDefault3d', 'resetCameraLastSave3d'],
429-
['hoverClosest3d']
424+
['resetCameraDefault3d', 'resetCameraLastSave3d']
430425
]);
431426

432427
var gd = getMockGraphInfo();
@@ -443,8 +438,7 @@ describe('ModeBar', function() {
443438
var buttons = getButtons([
444439
['toImage'],
445440
['pan2d'],
446-
['zoomInGeo', 'zoomOutGeo', 'resetGeo'],
447-
['hoverClosestGeo']
441+
['zoomInGeo', 'zoomOutGeo', 'resetGeo']
448442
]);
449443

450444
var gd = getMockGraphInfo();
@@ -461,8 +455,7 @@ describe('ModeBar', function() {
461455
var buttons = getButtons([
462456
['toImage'],
463457
['pan2d', 'select2d', 'lasso2d'],
464-
['zoomInGeo', 'zoomOutGeo', 'resetGeo'],
465-
['hoverClosestGeo']
458+
['zoomInGeo', 'zoomOutGeo', 'resetGeo']
466459
]);
467460

468461
var gd = getMockGraphInfo();
@@ -484,8 +477,7 @@ describe('ModeBar', function() {
484477
var buttons = getButtons([
485478
['toImage'],
486479
['pan2d'],
487-
['zoomInMapbox', 'zoomOutMapbox', 'resetViewMapbox'],
488-
['toggleHover']
480+
['zoomInMapbox', 'zoomOutMapbox', 'resetViewMapbox']
489481
]);
490482

491483
var gd = getMockGraphInfo();
@@ -502,8 +494,7 @@ describe('ModeBar', function() {
502494
var buttons = getButtons([
503495
['toImage'],
504496
['pan2d', 'select2d', 'lasso2d'],
505-
['zoomInMapbox', 'zoomOutMapbox', 'resetViewMapbox'],
506-
['toggleHover']
497+
['zoomInMapbox', 'zoomOutMapbox', 'resetViewMapbox']
507498
]);
508499

509500
var gd = getMockGraphInfo();
@@ -525,8 +516,7 @@ describe('ModeBar', function() {
525516
var buttons = getButtons([
526517
['toImage'],
527518
['zoom2d', 'pan2d'],
528-
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],
529-
['hoverClosestGl2d']
519+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']
530520
]);
531521

532522
var gd = getMockGraphInfo(['x'], ['y']);
@@ -542,8 +532,7 @@ describe('ModeBar', function() {
542532

543533
it('creates mode bar (pie version)', function() {
544534
var buttons = getButtons([
545-
['toImage'],
546-
['hoverClosestPie']
535+
['toImage']
547536
]);
548537

549538
var gd = getMockGraphInfo();
@@ -560,8 +549,7 @@ describe('ModeBar', function() {
560549
var buttons = getButtons([
561550
['toImage'],
562551
['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation'],
563-
['resetViews'],
564-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
552+
['resetViews']
565553
]);
566554

567555
var gd = getMockGraphInfo();
@@ -578,8 +566,7 @@ describe('ModeBar', function() {
578566
var buttons = getButtons([
579567
['toImage'],
580568
['zoom2d', 'pan2d'],
581-
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetViews'],
582-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
569+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetViews']
583570
]);
584571

585572
var gd = getMockGraphInfo(['x'], ['y']);
@@ -597,8 +584,7 @@ describe('ModeBar', function() {
597584
var buttons = getButtons([
598585
['toImage'],
599586
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
600-
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetViews'],
601-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
587+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetViews']
602588
]);
603589

604590
var gd = getMockGraphInfo(['x'], ['y']);
@@ -621,8 +607,7 @@ describe('ModeBar', function() {
621607
var buttons = getButtons([
622608
['toImage'],
623609
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
624-
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],
625-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
610+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']
626611
]);
627612

628613
var gd = getMockGraphInfo(['x'], ['y']);
@@ -645,8 +630,7 @@ describe('ModeBar', function() {
645630
var buttons = getButtons([
646631
['toImage'],
647632
['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation'],
648-
['resetViews'],
649-
['toggleHover']
633+
['resetViews']
650634
]);
651635

652636
var gd = getMockGraphInfo();
@@ -662,8 +646,7 @@ describe('ModeBar', function() {
662646
it('creates mode bar (un-selectable ternary version)', function() {
663647
var buttons = getButtons([
664648
['toImage'],
665-
['zoom2d', 'pan2d'],
666-
['toggleHover']
649+
['zoom2d', 'pan2d']
667650
]);
668651

669652
var gd = getMockGraphInfo();
@@ -679,8 +662,7 @@ describe('ModeBar', function() {
679662
it('creates mode bar (selectable ternary version)', function() {
680663
var buttons = getButtons([
681664
['toImage'],
682-
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
683-
['toggleHover']
665+
['zoom2d', 'pan2d', 'select2d', 'lasso2d']
684666
]);
685667

686668
var gd = getMockGraphInfo();
@@ -701,8 +683,7 @@ describe('ModeBar', function() {
701683
it('creates mode bar (ternary + cartesian version)', function() {
702684
var buttons = getButtons([
703685
['toImage'],
704-
['zoom2d', 'pan2d'],
705-
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
686+
['zoom2d', 'pan2d']
706687
]);
707688

708689
var gd = getMockGraphInfo();
@@ -719,8 +700,7 @@ describe('ModeBar', function() {
719700
var buttons = getButtons([
720701
['toImage'],
721702
['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation'],
722-
['resetViews'],
723-
['toggleHover']
703+
['resetViews']
724704
]);
725705

726706
var gd = getMockGraphInfo();
@@ -733,36 +713,6 @@ describe('ModeBar', function() {
733713
checkButtons(modeBar, buttons, 1);
734714
});
735715

736-
it('creates mode bar without hover button when all traces are noHover', function() {
737-
var buttons = getButtons([
738-
['toImage']
739-
]);
740-
741-
var gd = getMockGraphInfo();
742-
gd._fullData = [{ type: 'indicator' }];
743-
744-
manageModeBar(gd);
745-
var modeBar = gd._fullLayout._modeBar;
746-
747-
checkButtons(modeBar, buttons, 1);
748-
});
749-
750-
it('creates mode bar with hover button even in the presence of one noHover trace', function() {
751-
var buttons = getButtons([
752-
['toImage'],
753-
['hoverClosestPie']
754-
]);
755-
756-
var gd = getMockGraphInfo();
757-
gd._fullLayout._basePlotModules = [{ name: 'pie' }];
758-
gd._fullData = [{ type: 'indicator' }, {type: 'pie'}];
759-
760-
manageModeBar(gd);
761-
var modeBar = gd._fullLayout._modeBar;
762-
763-
checkButtons(modeBar, buttons, 1);
764-
});
765-
766716
it('throws an error if modeBarButtonsToRemove isn\'t an array', function() {
767717
var gd = getMockGraphInfo();
768718
gd._context.modeBarButtonsToRemove = 'not gonna work';
@@ -811,32 +761,28 @@ describe('ModeBar', function() {
811761
gd._fullData = [{type: 'pie'}];
812762
manageModeBar(gd);
813763
checkButtons(gd._fullLayout._modeBar, getButtons([
814-
['toImage'],
815-
['hoverClosestPie']
764+
['toImage']
816765
]), 1);
817766

818767
gd._context.showSendToCloud = true;
819768
gd._context.showEditInChartStudio = false;
820769
manageModeBar(gd);
821770
checkButtons(gd._fullLayout._modeBar, getButtons([
822-
['toImage', 'sendDataToCloud'],
823-
['hoverClosestPie']
771+
['toImage', 'sendDataToCloud']
824772
]), 1);
825773

826774
gd._context.showSendToCloud = false;
827775
gd._context.showEditInChartStudio = true;
828776
manageModeBar(gd);
829777
checkButtons(gd._fullLayout._modeBar, getButtons([
830-
['toImage', 'editInChartStudio'],
831-
['hoverClosestPie']
778+
['toImage', 'editInChartStudio']
832779
]), 1);
833780

834781
gd._context.showSendToCloud = true;
835782
gd._context.showEditInChartStudio = true;
836783
manageModeBar(gd);
837784
checkButtons(gd._fullLayout._modeBar, getButtons([
838-
['toImage', 'editInChartStudio'],
839-
['hoverClosestPie']
785+
['toImage', 'editInChartStudio']
840786
]), 1);
841787
});
842788

@@ -863,13 +809,13 @@ describe('ModeBar', function() {
863809
var gd = setupGraphInfo();
864810
manageModeBar(gd);
865811

866-
expect(countButtons(gd._fullLayout._modeBar)).toEqual(11);
812+
expect(countButtons(gd._fullLayout._modeBar)).toEqual(8);
867813

868-
gd._fullLayout._basePlotModules = [{ name: 'gl3d' }];
869-
gd._fullData = [{type: 'scatter3d'}];
814+
gd._fullLayout._basePlotModules = [{ name: 'geo' }];
815+
gd._fullData = [{type: 'scattergeo'}];
870816
manageModeBar(gd);
871817

872-
expect(countButtons(gd._fullLayout._modeBar)).toEqual(9);
818+
expect(countButtons(gd._fullLayout._modeBar)).toEqual(6);
873819
});
874820

875821
it('updates mode bar buttons if modeBarButtonsToRemove changes', function() {
@@ -906,7 +852,7 @@ describe('ModeBar', function() {
906852
it('sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove', function() {
907853
var gd = setupGraphInfo();
908854
gd._context.modeBarButtonsToRemove = [
909-
'toImage', 'pan2d', 'hoverCompareCartesian'
855+
'toImage', 'pan2d'
910856
];
911857
gd._context.modeBarButtonsToAdd = [
912858
{ name: 'some button', click: noop },
@@ -916,14 +862,14 @@ describe('ModeBar', function() {
916862
manageModeBar(gd);
917863

918864
var modeBar = gd._fullLayout._modeBar;
919-
expect(countGroups(modeBar)).toEqual(6);
920-
expect(countButtons(modeBar)).toEqual(10);
865+
expect(countGroups(modeBar)).toEqual(5);
866+
expect(countButtons(modeBar)).toEqual(8);
921867
});
922868

923869
it('sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove (2)', function() {
924870
var gd = setupGraphInfo();
925871
gd._context.modeBarButtonsToRemove = [
926-
'toImage', 'pan2d', 'hoverCompareCartesian'
872+
'toImage', 'pan2d'
927873
];
928874
gd._context.modeBarButtonsToAdd = [[
929875
{ name: 'some button', click: noop },
@@ -936,8 +882,8 @@ describe('ModeBar', function() {
936882
manageModeBar(gd);
937883

938884
var modeBar = gd._fullLayout._modeBar;
939-
expect(countGroups(modeBar)).toEqual(7);
940-
expect(countButtons(modeBar)).toEqual(12);
885+
expect(countGroups(modeBar)).toEqual(6);
886+
expect(countButtons(modeBar)).toEqual(10);
941887
});
942888

943889
it('sets up buttons with fully custom modeBarButtons', function() {
@@ -1119,7 +1065,13 @@ describe('ModeBar', function() {
11191065
};
11201066

11211067
gd = createGraphDiv();
1122-
Plotly.newPlot(gd, mockData, mockLayout).then(function() {
1068+
Plotly.newPlot(gd, mockData, mockLayout, {
1069+
modeBarButtonsToAdd: [
1070+
'toggleSpikelines',
1071+
'hoverCompareCartesian',
1072+
'hoverClosestCartesian'
1073+
]
1074+
}).then(function() {
11231075
modeBar = gd._fullLayout._modeBar;
11241076
buttonToggle = selectButton(modeBar, 'toggleSpikelines');
11251077
buttonCompare = selectButton(modeBar, 'hoverCompareCartesian');
@@ -1197,7 +1149,7 @@ describe('ModeBar', function() {
11971149
});
11981150
});
11991151

1200-
describe('buttons hoverCompareCartesian and hoverClosestCartesian ', function() {
1152+
describe('buttons hoverCompareCartesian and hoverClosestCartesian', function() {
12011153
it('should update layout hovermode', function() {
12021154
expect(gd._fullLayout.hovermode).toBe('closest');
12031155
assertActive(hovermodeButtons, buttonClosest);
@@ -1293,7 +1245,9 @@ describe('ModeBar', function() {
12931245
}];
12941246

12951247
gd = createGraphDiv();
1296-
Plotly.newPlot(gd, mockData).then(function() {
1248+
Plotly.newPlot(gd, mockData, {}, {
1249+
modeBarButtonsToAdd: ['hoverClosestPie']
1250+
}).then(function() {
12971251
modeBar = gd._fullLayout._modeBar;
12981252
done();
12991253
});
@@ -1326,7 +1280,9 @@ describe('ModeBar', function() {
13261280
}];
13271281

13281282
gd = createGraphDiv();
1329-
Plotly.newPlot(gd, mockData).then(function() {
1283+
Plotly.newPlot(gd, mockData, {}, {
1284+
modeBarButtonsToAdd: ['hoverClosestGeo']
1285+
}).then(function() {
13301286
modeBar = gd._fullLayout._modeBar;
13311287
done();
13321288
});
@@ -1410,7 +1366,9 @@ describe('ModeBar', function() {
14101366

14111367
Plotly.newPlot(gd, [
14121368
{type: 'scatterternary', a: [1], b: [2], c: [3]}
1413-
])
1369+
], {}, {
1370+
modeBarButtonsToAdd: ['toggleHover']
1371+
})
14141372
.then(function() {
14151373
_run('base');
14161374

0 commit comments

Comments
 (0)