Skip to content

Commit 68e0628

Browse files
committed
wrap toggle() test functions
1 parent 937f5cf commit 68e0628

File tree

2 files changed

+91
-120
lines changed

2 files changed

+91
-120
lines changed

test/jasmine/tests/polar_test.js

+54-67
Original file line numberDiff line numberDiff line change
@@ -381,75 +381,62 @@ describe('Test relayout on polar subplots:', function() {
381381
}
382382

383383
function toggle(astr, vals, exps, selector, fn) {
384-
return Plotly.relayout(gd, astr, vals[0]).then(function() {
385-
fn(selector, exps[0], astr + ' ' + vals[0]);
386-
return Plotly.relayout(gd, astr, vals[1]);
387-
})
388-
.then(function() {
389-
fn(selector, exps[1], astr + ' ' + vals[1]);
390-
return Plotly.relayout(gd, astr, vals[0]);
391-
})
392-
.then(function() {
393-
fn(selector, exps[0], astr + ' ' + vals[0]);
394-
});
384+
return function() {
385+
return Plotly.relayout(gd, astr, vals[0]).then(function() {
386+
fn(selector, exps[0], astr + ' ' + vals[0]);
387+
return Plotly.relayout(gd, astr, vals[1]);
388+
})
389+
.then(function() {
390+
fn(selector, exps[1], astr + ' ' + vals[1]);
391+
return Plotly.relayout(gd, astr, vals[0]);
392+
})
393+
.then(function() {
394+
fn(selector, exps[0], astr + ' ' + vals[0]);
395+
});
396+
};
395397
}
396398

397-
Plotly.plot(gd, fig).then(function() {
398-
return toggle(
399-
'polar.radialaxis.showline',
400-
[true, false], [null, 'none'],
401-
'.radial-line > line', assertDisplay
402-
);
403-
})
404-
.then(function() {
405-
return toggle(
406-
'polar.radialaxis.showgrid',
407-
[true, false], [null, 'none'],
408-
'.radial-grid', assertDisplay
409-
);
410-
})
411-
.then(function() {
412-
return toggle(
413-
'polar.radialaxis.showticklabels',
414-
[true, false], [6, 0],
415-
'.radial-axis > .xtick > text', assertCnt
416-
);
417-
})
418-
.then(function() {
419-
return toggle(
420-
'polar.radialaxis.ticks',
421-
['outside', ''], [6, 0],
422-
'.radial-axis > path.xtick', assertCnt
423-
);
424-
})
425-
.then(function() {
426-
return toggle(
427-
'polar.angularaxis.showline',
428-
[true, false], [null, 'none'],
429-
'.angular-line > path', assertDisplay
430-
);
431-
})
432-
.then(function() {
433-
return toggle(
434-
'polar.angularaxis.showgrid',
435-
[true, false], [8, 0],
436-
'.angular-grid > .angularaxis > path', assertCnt
437-
);
438-
})
439-
.then(function() {
440-
return toggle(
441-
'polar.angularaxis.showticklabels',
442-
[true, false], [8, 0],
443-
'.angular-axis > .angularaxistick > text', assertCnt
444-
);
445-
})
446-
.then(function() {
447-
return toggle(
448-
'polar.angularaxis.ticks',
449-
['outside', ''], [8, 0],
450-
'.angular-axis > path.angularaxistick', assertCnt
451-
);
452-
})
399+
Plotly.plot(gd, fig)
400+
.then(toggle(
401+
'polar.radialaxis.showline',
402+
[true, false], [null, 'none'],
403+
'.radial-line > line', assertDisplay
404+
))
405+
.then(toggle(
406+
'polar.radialaxis.showgrid',
407+
[true, false], [null, 'none'],
408+
'.radial-grid', assertDisplay
409+
))
410+
.then(toggle(
411+
'polar.radialaxis.showticklabels',
412+
[true, false], [6, 0],
413+
'.radial-axis > .xtick > text', assertCnt
414+
))
415+
.then(toggle(
416+
'polar.radialaxis.ticks',
417+
['outside', ''], [6, 0],
418+
'.radial-axis > path.xtick', assertCnt
419+
))
420+
.then(toggle(
421+
'polar.angularaxis.showline',
422+
[true, false], [null, 'none'],
423+
'.angular-line > path', assertDisplay
424+
))
425+
.then(toggle(
426+
'polar.angularaxis.showgrid',
427+
[true, false], [8, 0],
428+
'.angular-grid > .angularaxis > path', assertCnt
429+
))
430+
.then(toggle(
431+
'polar.angularaxis.showticklabels',
432+
[true, false], [8, 0],
433+
'.angular-axis > .angularaxistick > text', assertCnt
434+
))
435+
.then(toggle(
436+
'polar.angularaxis.ticks',
437+
['outside', ''], [8, 0],
438+
'.angular-axis > path.angularaxistick', assertCnt
439+
))
453440
.catch(failTest)
454441
.then(done);
455442
});

test/jasmine/tests/ternary_test.js

+37-53
Original file line numberDiff line numberDiff line change
@@ -392,62 +392,46 @@ describe('ternary plots', function() {
392392
}
393393

394394
function toggle(selector, astr, vals, exps) {
395-
return Plotly.relayout(gd, astr, vals[0]).then(function() {
396-
assertCnt(selector, exps[0], astr + ' ' + vals[0]);
397-
return Plotly.relayout(gd, astr, vals[1]);
398-
})
399-
.then(function() {
400-
assertCnt(selector, exps[1], astr + ' ' + vals[1]);
401-
return Plotly.relayout(gd, astr, vals[0]);
402-
})
403-
.then(function() {
404-
assertCnt(selector, exps[0], astr + ' ' + vals[0]);
405-
});
395+
return function() {
396+
return Plotly.relayout(gd, astr, vals[0]).then(function() {
397+
assertCnt(selector, exps[0], astr + ' ' + vals[0]);
398+
return Plotly.relayout(gd, astr, vals[1]);
399+
})
400+
.then(function() {
401+
assertCnt(selector, exps[1], astr + ' ' + vals[1]);
402+
return Plotly.relayout(gd, astr, vals[0]);
403+
})
404+
.then(function() {
405+
assertCnt(selector, exps[0], astr + ' ' + vals[0]);
406+
});
407+
};
406408
}
407409

408410
Plotly.plot(gd, fig)
409-
.then(function() {
410-
return toggle(
411-
'.aaxis > .ytick > text',
412-
'ternary.aaxis.showticklabels',
413-
[true, false], [4, 0]
414-
);
415-
})
416-
.then(function() {
417-
return toggle(
418-
'.baxis > .xtick > text',
419-
'ternary.baxis.showticklabels',
420-
[true, false], [5, 0]
421-
);
422-
})
423-
.then(function() {
424-
return toggle(
425-
'.caxis > .ytick > text',
426-
'ternary.caxis.showticklabels',
427-
[true, false], [4, 0]
428-
);
429-
})
430-
.then(function() {
431-
return toggle(
432-
'.aaxis > path.ytick',
433-
'ternary.aaxis.ticks',
434-
['outside', ''], [4, 0]
435-
);
436-
})
437-
.then(function() {
438-
return toggle(
439-
'.baxis > path.xtick',
440-
'ternary.baxis.ticks',
441-
['outside', ''], [5, 0]
442-
);
443-
})
444-
.then(function() {
445-
return toggle(
446-
'.caxis > path.ytick',
447-
'ternary.caxis.ticks',
448-
['outside', ''], [4, 0]
449-
);
450-
})
411+
.then(toggle(
412+
'.aaxis > .ytick > text', 'ternary.aaxis.showticklabels',
413+
[true, false], [4, 0]
414+
))
415+
.then(toggle(
416+
'.baxis > .xtick > text', 'ternary.baxis.showticklabels',
417+
[true, false], [5, 0]
418+
))
419+
.then(toggle(
420+
'.caxis > .ytick > text', 'ternary.caxis.showticklabels',
421+
[true, false], [4, 0]
422+
))
423+
.then(toggle(
424+
'.aaxis > path.ytick', 'ternary.aaxis.ticks',
425+
['outside', ''], [4, 0]
426+
))
427+
.then(toggle(
428+
'.baxis > path.xtick', 'ternary.baxis.ticks',
429+
['outside', ''], [5, 0]
430+
))
431+
.then(toggle(
432+
'.caxis > path.ytick', 'ternary.caxis.ticks',
433+
['outside', ''], [4, 0]
434+
))
451435
.catch(failTest)
452436
.then(done);
453437
});

0 commit comments

Comments
 (0)