Skip to content

Commit d1a5f09

Browse files
committed
update jasmine tests
1 parent 174ec01 commit d1a5f09

File tree

6 files changed

+37
-278
lines changed

6 files changed

+37
-278
lines changed

test/jasmine/bundle_tests/mathjax_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ describe('Test MathJax v' + mathjaxVersion + ':', function() {
5555

5656
return Plotly.newPlot(gd, fig)
5757
.then(function() { assertNoIntersect('base'); })
58-
.then(function() { return Plotly.relayout(gd, 'xaxis.titlefont.size', 40); })
58+
.then(function() { return Plotly.relayout(gd, 'xaxis.title.font.size', 40); })
5959
.then(function() { assertNoIntersect('large title font size'); })
60-
.then(function() { return Plotly.relayout(gd, 'xaxis.titlefont.size', null); })
60+
.then(function() { return Plotly.relayout(gd, 'xaxis.title.font.size', null); })
6161
.then(function() { assertNoIntersect('back to base'); })
6262
.then(function() { return Plotly.relayout(gd, 'xaxis.tickfont.size', 40); })
6363
.then(function() { assertNoIntersect('large title font size'); })

test/jasmine/tests/funnelarea_test.js

+9-30
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,10 @@ describe('Funnelarea traces', function() {
298298
};
299299
}
300300

301-
it('shows title top center if titleposition is undefined', function(done) {
301+
it('shows title top center if title.position is undefined', function(done) {
302302
Plotly.newPlot(gd, [{
303303
values: [2, 2, 2, 2],
304-
title: { text: 'Test<BR>Title' },
305-
titlefont: {
306-
size: 12
307-
},
304+
title: { text: 'Test<BR>Title', font: { size: 12 } },
308305
type: 'funnelarea',
309306
textinfo: 'none'
310307
}], {height: 300, width: 300})
@@ -315,11 +312,7 @@ describe('Funnelarea traces', function() {
315312
it('shows title top center', function(done) {
316313
Plotly.newPlot(gd, [{
317314
values: [1, 1, 1, 1, 2],
318-
title: { text: 'Test<BR>Title' },
319-
titleposition: 'top center',
320-
titlefont: {
321-
size: 12
322-
},
315+
title: { text: 'Test<BR>Title', position: 'top center', font: { size: 12 } },
323316
type: 'funnelarea',
324317
textinfo: 'none'
325318
}], {height: 300, width: 300})
@@ -330,11 +323,7 @@ describe('Funnelarea traces', function() {
330323
it('shows title top left', function(done) {
331324
Plotly.newPlot(gd, [{
332325
values: [3, 2, 1],
333-
title: { text: 'Test<BR>Title' },
334-
titleposition: 'top left',
335-
titlefont: {
336-
size: 12
337-
},
326+
title: { text: 'Test<BR>Title', position: 'top center', font: { size: 12 } },
338327
type: 'funnelarea',
339328
textinfo: 'none'
340329
}], {height: 300, width: 300})
@@ -345,11 +334,7 @@ describe('Funnelarea traces', function() {
345334
it('shows title top right', function(done) {
346335
Plotly.newPlot(gd, [{
347336
values: [4, 5, 6, 5],
348-
title: { text: 'Test<BR>Title' },
349-
titleposition: 'top right',
350-
titlefont: {
351-
size: 12
352-
},
337+
title: { text: 'Test<BR>Title', position: 'top right', font: { size: 12 } },
353338
type: 'funnelarea',
354339
textinfo: 'none'
355340
}], {height: 300, width: 300})
@@ -360,11 +345,7 @@ describe('Funnelarea traces', function() {
360345
it('correctly positions large title', function(done) {
361346
Plotly.newPlot(gd, [{
362347
values: [1, 3, 4, 1, 2],
363-
title: { text: 'Test<BR>Title' },
364-
titleposition: 'top center',
365-
titlefont: {
366-
size: 60
367-
},
348+
title: { text: 'Test<BR>Title', position: 'top center', size: 60 },
368349
type: 'funnelarea',
369350
textinfo: 'none'
370351
}], {height: 300, width: 300})
@@ -591,18 +572,16 @@ describe('Funnelarea traces', function() {
591572
Plotly.newPlot(gd, [{
592573
type: 'funnelarea',
593574
values: [1, 2, 3],
594-
title: { text: 'yo' },
595-
titlefont: {color: 'blue'},
596-
titleposition: 'top left'
575+
title: { text: 'yo', position: 'top left', font: { color: 'blue' } },
597576
}])
598577
.then(function() {
599578
_assertTitle('base', 'yo', 'rgb(0, 0, 255)');
600579
_verifyTitle(true, false, true, false, false);
601580

602581
return Plotly.restyle(gd, {
603582
title: { text: 'oy' },
604-
'titlefont.color': 'red',
605-
titleposition: 'top right'
583+
'title.font.color': 'red',
584+
'title.position': 'top right'
606585
});
607586
})
608587
.then(function() {

test/jasmine/tests/pie_test.js

+23-72
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ var customAssertions = require('../assets/custom_assertions');
1616
var assertHoverLabelStyle = customAssertions.assertHoverLabelStyle;
1717
var assertHoverLabelContent = customAssertions.assertHoverLabelContent;
1818
var checkTextTemplate = require('../assets/check_texttemplate');
19+
const { position } = require('../../../src/plots/cartesian/layout_attributes');
20+
const { font } = require('../../../src/plots/layout_attributes');
1921

2022
var SLICES_SELECTOR = '.slice path';
2123
var SLICES_TEXT_SELECTOR = '.pielayer text.slicetext';
@@ -329,11 +331,7 @@ describe('Pie traces', function() {
329331
it('scales multiline title to fit in hole', function(done) {
330332
Plotly.newPlot(gd, [{
331333
values: [2, 2, 2, 2],
332-
title: { text: 'Test<BR>Title' },
333-
titleposition: 'middle center',
334-
titlefont: {
335-
size: 60
336-
},
334+
title: { text: 'Test<BR>Title', position: 'middle center', font: { size: 60 } },
337335
hole: 0.1,
338336
type: 'pie',
339337
textinfo: 'none'
@@ -379,11 +377,7 @@ describe('Pie traces', function() {
379377
it('shows title top center if hole is zero', function(done) {
380378
Plotly.newPlot(gd, [{
381379
values: [2, 2, 2, 2],
382-
title: { text: 'Test<BR>Title' },
383-
titleposition: 'middle center',
384-
titlefont: {
385-
size: 12
386-
},
380+
title: { text: 'Test<BR>Title', position: 'middle center', font: { size: 12 } },
387381
hole: 0,
388382
type: 'pie',
389383
textinfo: 'none'
@@ -392,13 +386,10 @@ describe('Pie traces', function() {
392386
.then(done, done.fail);
393387
});
394388

395-
it('shows title top center if titleposition is undefined and no hole', function(done) {
389+
it('shows title top center if title.position is undefined and no hole', function(done) {
396390
Plotly.newPlot(gd, [{
397391
values: [2, 2, 2, 2],
398-
title: { text: 'Test<BR>Title' },
399-
titlefont: {
400-
size: 12
401-
},
392+
title: { text: 'Test<BR>Title', font: { size: 12 } },
402393
type: 'pie',
403394
textinfo: 'none'
404395
}], {height: 300, width: 300})
@@ -409,11 +400,7 @@ describe('Pie traces', function() {
409400
it('shows title top center', function(done) {
410401
Plotly.newPlot(gd, [{
411402
values: [1, 1, 1, 1, 2],
412-
title: { text: 'Test<BR>Title' },
413-
titleposition: 'top center',
414-
titlefont: {
415-
size: 12
416-
},
403+
title: { text: 'Test<BR>Title', position: 'top center', font: { size: 12 } },
417404
type: 'pie',
418405
textinfo: 'none'
419406
}], {height: 300, width: 300})
@@ -424,11 +411,7 @@ describe('Pie traces', function() {
424411
it('shows title top left', function(done) {
425412
Plotly.newPlot(gd, [{
426413
values: [3, 2, 1],
427-
title: { text: 'Test<BR>Title' },
428-
titleposition: 'top left',
429-
titlefont: {
430-
size: 12
431-
},
414+
title: { text: 'Test<BR>Title', position: 'top left', font: { size: 12 } },
432415
type: 'pie',
433416
textinfo: 'none'
434417
}], {height: 300, width: 300})
@@ -439,11 +422,7 @@ describe('Pie traces', function() {
439422
it('shows title top right', function(done) {
440423
Plotly.newPlot(gd, [{
441424
values: [4, 5, 6, 5],
442-
title: { text: 'Test<BR>Title' },
443-
titleposition: 'top right',
444-
titlefont: {
445-
size: 12
446-
},
425+
title: { text: 'Test<BR>Title', position: 'top right', font: { size: 12 } },
447426
type: 'pie',
448427
textinfo: 'none'
449428
}], {height: 300, width: 300})
@@ -454,11 +433,7 @@ describe('Pie traces', function() {
454433
it('shows title bottom left', function(done) {
455434
Plotly.newPlot(gd, [{
456435
values: [4, 5, 6, 5],
457-
title: { text: 'Test<BR>Title' },
458-
titleposition: 'bottom left',
459-
titlefont: {
460-
size: 12
461-
},
436+
title: { text: 'Test<BR>Title', position: 'bottom left', font: { size: 12 } },
462437
type: 'pie',
463438
textinfo: 'none'
464439
}], {height: 300, width: 300})
@@ -469,11 +444,7 @@ describe('Pie traces', function() {
469444
it('shows title bottom center', function(done) {
470445
Plotly.newPlot(gd, [{
471446
values: [4, 5, 6, 5],
472-
title: { text: 'Test<BR>Title' },
473-
titleposition: 'bottom center',
474-
titlefont: {
475-
size: 12
476-
},
447+
title: { text: 'Test<BR>Title', position: 'bottom center', font: { size: 12 } },
477448
type: 'pie',
478449
textinfo: 'none'
479450
}], {height: 300, width: 300})
@@ -484,11 +455,7 @@ describe('Pie traces', function() {
484455
it('shows title bottom right', function(done) {
485456
Plotly.newPlot(gd, [{
486457
values: [4, 5, 6, 5],
487-
title: { text: 'Test<BR>Title' },
488-
titleposition: 'bottom right',
489-
titlefont: {
490-
size: 12
491-
},
458+
title: { text: 'Test<BR>Title', position: 'bottom right', font: { size: 12 } },
492459
type: 'pie',
493460
textinfo: 'none'
494461
}], {height: 300, width: 300})
@@ -499,34 +466,26 @@ describe('Pie traces', function() {
499466
it('should be able to restyle title position', function(done) {
500467
Plotly.newPlot(gd, [{
501468
values: [3, 2, 1],
502-
title: { text: 'Test<BR>Title' },
503-
titleposition: 'top left',
504-
titlefont: {
505-
size: 12
506-
},
469+
title: { text: 'Test<BR>Title', position: 'top left', font: { size: 12 } },
507470
type: 'pie',
508471
textinfo: 'none'
509472
}], {height: 300, width: 300})
510473
.then(_verifyTitle(true, false, true, false, false))
511-
.then(function() { return Plotly.restyle(gd, 'titleposition', 'top right'); })
474+
.then(function() { return Plotly.restyle(gd, 'title.position', 'top right'); })
512475
.then(_verifyTitle(false, true, true, false, false))
513-
.then(function() { return Plotly.restyle(gd, 'titleposition', 'bottom left'); })
476+
.then(function() { return Plotly.restyle(gd, 'title.position', 'bottom left'); })
514477
.then(_verifyTitle(true, false, false, true, false))
515-
.then(function() { return Plotly.restyle(gd, 'titleposition', 'bottom center'); })
478+
.then(function() { return Plotly.restyle(gd, 'title.position', 'bottom center'); })
516479
.then(_verifyTitle(false, false, false, true, true))
517-
.then(function() { return Plotly.restyle(gd, 'titleposition', 'bottom right'); })
480+
.then(function() { return Plotly.restyle(gd, 'title.position', 'bottom right'); })
518481
.then(_verifyTitle(false, true, false, true, false))
519482
.then(done, done.fail);
520483
});
521484

522485
it('does not intersect pulled slices', function(done) {
523486
Plotly.newPlot(gd, [{
524487
values: [2, 2, 2, 2],
525-
title: { text: 'Test<BR>Title' },
526-
titleposition: 'top center',
527-
titlefont: {
528-
size: 14
529-
},
488+
title: { text: 'Test<BR>Title', position: 'top center', font: { size: 14 } },
530489
pull: [0.9, 0.9, 0.9, 0.9],
531490
type: 'pie',
532491
textinfo: 'none'
@@ -548,11 +507,7 @@ describe('Pie traces', function() {
548507
it('correctly positions large title', function(done) {
549508
Plotly.newPlot(gd, [{
550509
values: [1, 3, 4, 1, 2],
551-
title: { text: 'Test<BR>Title' },
552-
titleposition: 'top center',
553-
titlefont: {
554-
size: 60
555-
},
510+
title: { text: 'Test<BR>Title', position: 'top center', font: { size: 60 } },
556511
type: 'pie',
557512
textinfo: 'none'
558513
}], {height: 300, width: 300})
@@ -795,9 +750,7 @@ describe('Pie traces', function() {
795750
Plotly.newPlot(gd, [{
796751
type: 'pie',
797752
values: [1, 2, 3],
798-
title: { text: 'yo' },
799-
titlefont: {color: 'blue'},
800-
titleposition: 'top left'
753+
title: { text: 'yo', font: {color: 'blue'}, position: 'top left' }
801754
}])
802755
.then(function() {
803756
_assertTitle('base', 'yo', 'rgb(0, 0, 255)');
@@ -837,18 +790,16 @@ describe('Pie traces', function() {
837790
Plotly.newPlot(gd, [{
838791
type: 'pie',
839792
values: [1, 2, 3],
840-
title: { text: 'yo' },
841-
titlefont: {color: 'blue'},
842-
titleposition: 'top left'
793+
title: { text: 'yo', font: { color: 'blue' }, position: 'top left' }
843794
}])
844795
.then(function() {
845796
_assertTitle('base', 'yo', 'rgb(0, 0, 255)');
846797
_verifyTitle(true, false, true, false, false);
847798

848799
return Plotly.restyle(gd, {
849800
title: { text: 'oy' },
850-
'titlefont.color': 'red',
851-
titleposition: 'bottom right'
801+
'title.font.color': 'red',
802+
'title.position': 'bottom right'
852803
});
853804
})
854805
.then(function() {

test/jasmine/tests/plot_api_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ describe('Test plot api', function() {
535535
expect(eventData).toEqual({
536536
title: { text: 'Plotly chart' },
537537
'xaxis.title': 'X',
538-
'xaxis.titlefont': {color: 'green'},
538+
'xaxis.title.font': {color: 'green'},
539539
'yaxis.title': 'Y',
540540
'polar.radialaxis.title': 'Radial'
541541
});
@@ -545,7 +545,7 @@ describe('Test plot api', function() {
545545
return Plotly.relayout(gd, {
546546
title: { text: 'Plotly chart' },
547547
'xaxis.title': 'X',
548-
'xaxis.titlefont': {color: 'green'},
548+
'xaxis.title.font': {color: 'green'},
549549
'yaxis.title': 'Y',
550550
'polar.radialaxis.title': 'Radial'
551551
});

test/jasmine/tests/polar_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ describe('Test relayout on polar subplots:', function() {
490490
})
491491
.then(function() {
492492
assertTitle('yo2', true);
493-
return Plotly.relayout(gd, 'polar.radialaxis.titlefont.color', 'red');
493+
return Plotly.relayout(gd, 'polar.radialaxis.title.font.color', 'red');
494494
})
495495
.then(function() {
496496
assertTitle('yo2', false);

0 commit comments

Comments
 (0)