Skip to content

Commit db8ed5e

Browse files
committed
test: add scatter3d dflt test cases
1 parent b9a471e commit db8ed5e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

test/jasmine/tests/scatter3d_test.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var Scatter3D = require('@src/traces/scatter3d');
2+
var Lib = require('@src/lib');
3+
var Color = require('@src/components/color');
4+
5+
6+
describe('Scatter3D defaults', function() {
7+
'use strict';
8+
9+
var defaultColor = '#d3d3d3';
10+
11+
function _supply(traceIn) {
12+
var traceOut = { visible: true },
13+
layout = { _dataLength: 1 };
14+
15+
Scatter3D.supplyDefaults(traceIn, traceOut, defaultColor, layout);
16+
return traceOut;
17+
}
18+
19+
var base = {
20+
x: [1, 2, 3],
21+
y: [1, 2, 3],
22+
z: [1, 2, 1]
23+
};
24+
25+
it('should make marker.color inherit from line.color (scalar case)', function() {
26+
var out = _supply(Lib.extendFlat({}, base, {
27+
line: { color: 'red' }
28+
}));
29+
30+
expect(out.line.color).toEqual('red');
31+
expect(out.marker.color).toEqual('red');
32+
expect(out.marker.line.color).toBe(Color.defaultLine, 'but not marker.line.color');
33+
});
34+
35+
it('should make marker.color inherit from line.color (array case)', function() {
36+
var color = [1, 2, 3];
37+
38+
var out = _supply(Lib.extendFlat({}, base, {
39+
line: { color: color }
40+
}));
41+
42+
expect(out.line.color).toBe(color);
43+
expect(out.marker.color).toBe(color);
44+
expect(out.marker.line.color).toBe(Color.defaultLine, 'but not marker.line.color');
45+
});
46+
47+
it('should make line.color inherit from marker.color if scalar)', function() {
48+
var out = _supply(Lib.extendFlat({}, base, {
49+
marker: { color: 'red' }
50+
}));
51+
52+
expect(out.line.color).toEqual('red');
53+
expect(out.marker.color).toEqual('red');
54+
expect(out.marker.line.color).toBe(Color.defaultLine);
55+
});
56+
57+
it('should not make line.color inherit from marker.color if array', function() {
58+
var color = [1, 2, 3];
59+
60+
var out = _supply(Lib.extendFlat({}, base, {
61+
marker: { color: color }
62+
}));
63+
64+
expect(out.line.color).toBe(defaultColor);
65+
expect(out.marker.color).toBe(color);
66+
expect(out.marker.line.color).toBe(Color.defaultLine);
67+
});
68+
});

0 commit comments

Comments
 (0)