Skip to content

Commit 60e053d

Browse files
It seems the image tests are running correctly
The only way to actually know is to run them wrapped in Jasmine stuff, which we will do soon.
1 parent 68c807b commit 60e053d

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

test/all_layout_images_test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
var domainRefTests = require('./domain_ref_shapes_test');
2-
domainRefTests.runImageTests();
3-
2+
domainRefTests.runImageTests(
3+
{start:0,stop:10},
4+
function (combo) {
5+
return combo[1] === 'log';
6+
});

test/domain_ref_shapes_test.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ function checkImage(layout, imageObj, imageBBox) {}
358358

359359
function imageTest(gd, layout, xaxtype, yaxtype, x, y, sizex, sizey, xanchor,
360360
yanchor, xref, yref, xid, yid) {
361+
console.log('running imageTest on ',gd);
361362
var image = {
362363
x: x,
363364
y: y,
@@ -540,6 +541,9 @@ function test_correct_aro_positions() {
540541
testCombos.forEach(testDomRefAROCombo);
541542
}
542543

544+
var testImageComboMock = Lib.extendDeep({},
545+
require('../test/image/mocks/domain_ref_base.json'));
546+
543547
function testImageCombo(combo,keep_graph_div) {
544548
var axistypex = combo[0];
545549
var axistypey = combo[1];
@@ -553,13 +557,14 @@ function testImageCombo(combo,keep_graph_div) {
553557
var yid = axispair[1];
554558
var xref = makeAxRef(xid, aroposx.ref);
555559
var yref = makeAxRef(yid, aroposy.ref);
556-
var gd = createGraphDiv(gd_id);
557-
var mock = Lib.extendDeep({},
558-
require('../test/image/mocks/domain_ref_base.json'));
559560
if (DEBUG) {
560561
console.log(combo);
561562
}
562-
return Plotly.newPlot(gd, mock).then(function (gd) {
563+
return new Promise(function(resolve){
564+
var gd = createGraphDiv(gd_id);
565+
resolve(gd);
566+
}).then(function (gd) { return Plotly.newPlot(gd, testImageComboMock); })
567+
.then(function (gd) {
563568
return imageTest(gd, {}, axistypex, axistypey,
564569
aroposx.value[0], aroposy.value[0], aroposx.size,
565570
aroposy.size,
@@ -575,13 +580,16 @@ function testImageCombo(combo,keep_graph_div) {
575580
"yref:", yref, "\n",
576581
].join(' '), test_ret);
577582
}).then( function () {
583+
console.log("Hello?", keep_graph_div);
578584
if (!keep_graph_div) {
585+
console.log('destroying graph div ', gd_id);
586+
Plotly.purge(gd_id);
579587
destroyGraphDiv(gd_id);
580588
}
581589
});
582590
}
583591

584-
function runImageTests() {
592+
function runImageTests(start_stop,filter) {
585593
var testCombos = [...iterable.cartesianProduct([
586594
axisTypes, axisTypes, axisPairs,
587595
// axis reference types are contained in here
@@ -590,8 +598,26 @@ function runImageTests() {
590598
])];
591599
// add a unique id to each combination so we can instantiate a unique graph
592600
// each time
593-
testCombos=testCombos.map((c,i)=>c.concat(['graph-'+i])).slice(0,20);
594-
testCombos.map(testImageCombo).reduce((a,v)=>a.then(v));
601+
testCombos=testCombos.map((c,i)=>c.concat(['graph-'+i]));
602+
if(filter) {
603+
testCombos=testCombos.filter(filter);
604+
}
605+
if(start_stop) {
606+
testCombos=testCombos.slice(start_stop.start,start_stop.stop);
607+
}
608+
console.log("Executing " + testCombos.length + " tests");
609+
var tc = testCombos.map(c=>testImageCombo(c,false)).reduce((a,v)=>a.then(v));
610+
}
611+
612+
function testAnnotationCombo(combo) {
613+
var axistypex = combo[0];
614+
var axistypey = combo[1];
615+
var axispair = combo[2];
616+
var aroposx = combo[3];
617+
var aroposy = combo[4];
618+
var xanchor = combo[5];
619+
var yanchor = combo[6];
620+
var gd_id = combo[7];
595621
}
596622

597623
module.exports = {

0 commit comments

Comments
 (0)