Skip to content

Commit af7103f

Browse files
Test values chosen so they are never beyond the plot boundaries
This is because if some components (e.g., annotations) are outside of the plotting area, they are deemed not visible and are removed, which wrecks the tests.
1 parent 3896b08 commit af7103f

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/domain_ref_shapes_test.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ function checkAROPosition(gd, aro) {
425425
}
426426

427427
// some made-up values for testing
428+
// NOTE: The pixel values are intentionally set so that 2*pixel is never greater
429+
// than the mock's margin. This is so that annotations are not unintentionally
430+
// clipped out because they exceed the plotting area. The reason for using twice
431+
// the pixel value is because the annotation test requires plotting 2
432+
// annotations, the second having arrow components twice as long as the first.
428433
var aroPositionsX = [{
429434
// aros referring to data
430435
ref: 'range',
@@ -433,21 +438,21 @@ var aroPositionsX = [{
433438
size: 1.5,
434439
// for the case when annotations specifies arrow in pixels, this value
435440
// is read instead of value[1]
436-
pixel: 50
441+
pixel: 25
437442
},
438443
{
439444
// aros referring to domains
440445
ref: 'domain',
441446
value: [0.2, 0.75],
442447
size: 0.3,
443-
pixel: 60
448+
pixel: 30
444449
},
445450
{
446451
// aros referring to paper
447452
ref: 'paper',
448453
value: [0.25, 0.8],
449454
size: 0.35,
450-
pixel: 70
455+
pixel: 35
451456
},
452457
];
453458
var aroPositionsY = [{
@@ -469,7 +474,7 @@ var aroPositionsY = [{
469474
// aros referring to paper
470475
ref: 'paper',
471476
value: [0.2, 0.85],
472-
pixel: 80,
477+
pixel: 45,
473478
size: .3
474479
}
475480
];
@@ -559,7 +564,7 @@ function test_correct_aro_positions() {
559564
testCombos.forEach(testDomRefAROCombo);
560565
}
561566

562-
function runComboTests(productItems,testCombo,start_stop,filter) {
567+
function runComboTests(productItems,testCombo,start_stop,filter,keep_graph_div) {
563568
var testCombos = [...iterable.cartesianProduct(productItems)];
564569
testCombos=testCombos.map((c,i)=>c.concat(['graph-'+i]));
565570
if(filter) {
@@ -569,7 +574,7 @@ function runComboTests(productItems,testCombo,start_stop,filter) {
569574
testCombos=testCombos.slice(start_stop.start,start_stop.stop);
570575
}
571576
console.log("Executing " + testCombos.length + " tests");
572-
var tc = testCombos.map(c=>testCombo(c,false)).reduce((a,v)=>a.then(v));
577+
var tc = testCombos.map(c=>testCombo(c,keep_graph_div)).reduce((a,v)=>a.then(v));
573578
}
574579

575580
var testImageComboMock = Lib.extendDeep({},
@@ -674,16 +679,17 @@ function testAnnotationCombo(combo,keep_graph_div) {
674679
});
675680
}
676681

677-
function runAnnotationTests(start_stop,filter) {
682+
function runAnnotationTests(start_stop,filter,keep_graph_div) {
678683
runComboTests([
679684
axisTypes, axisTypes, axisPairs, aroPositionsX, aroPositionsY, arrowAxis
680685
],
681-
testAnnotationCombo,start_stop,filter);
686+
testAnnotationCombo,start_stop,filter,keep_graph_div);
682687
}
683688

684689
module.exports = {
685690
runImageTests: runImageTests,
686691
testImageCombo: testImageCombo,
687692
runAnnotationTests: runAnnotationTests,
688-
testAnnotationCombo: testAnnotationCombo
693+
testAnnotationCombo: testAnnotationCombo,
694+
findAROByColor: findAROByColor
689695
};

0 commit comments

Comments
 (0)