Skip to content

Commit d0b15c8

Browse files
committed
tests of axis domain constraints
1 parent 9df6903 commit d0b15c8

File tree

4 files changed

+236
-33
lines changed

4 files changed

+236
-33
lines changed
45 Bytes
Loading

test/image/mocks/axes_scaleanchor.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"width": 800,
1010
"height":500,
1111
"title": "fixed-ratio axes",
12-
"xaxis": {"nticks": 10, "domain": [0, 0.45], "title": "shared X axis"},
12+
"xaxis": {"constrain": "domain", "nticks": 10, "domain": [0, 0.45], "title": "shared X axis"},
1313
"yaxis": {"scaleanchor": "x", "domain": [0, 0.45], "title": "1:1"},
14-
"yaxis2": {"scaleanchor": "x", "scaleratio": 0.2, "domain": [0.55,1], "title": "1:5"},
14+
"yaxis2": {"constrain": "domain", "constraintoward": "bottom", "scaleanchor": "x", "scaleratio": 0.2, "domain": [0.55,1], "title": "1:5"},
1515
"xaxis2": {"type": "log", "domain": [0.55, 1], "anchor": "y3", "title": "unconstrained log X"},
1616
"yaxis3": {"domain": [0, 0.45], "anchor": "x2", "title": "Scale matches ->"},
1717
"yaxis4": {"scaleanchor": "y3", "domain": [0.55, 1], "anchor": "x2", "title": "Scale matches <-"},

test/jasmine/assets/custom_matchers.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,19 @@ module.exports = {
5555
compare: function(actual, expected, precision, msgExtra) {
5656
precision = coercePosition(precision);
5757

58-
var tested = actual.map(function(element, i) {
59-
return isClose(element, expected[i], precision);
60-
});
61-
62-
var passed = (
63-
expected.length === actual.length &&
64-
tested.indexOf(false) < 0
65-
);
58+
var passed;
59+
60+
if(Array.isArray(actual) && Array.isArray(expected)) {
61+
var tested = actual.map(function(element, i) {
62+
return isClose(element, expected[i], precision);
63+
});
64+
65+
passed = (
66+
expected.length === actual.length &&
67+
tested.indexOf(false) < 0
68+
);
69+
}
70+
else passed = false;
6671

6772
var message = [
6873
'Expected', actual, 'to be close to', expected, msgExtra

0 commit comments

Comments
 (0)