Skip to content

Commit 1931102

Browse files
committed
test hoveron in supplyDefaults
1 parent dddb6e1 commit 1931102

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

test/jasmine/tests/scatter_test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,39 @@ describe('Test scatter', function() {
6060
expect(traceOut.visible).toBe(false);
6161
});
6262

63+
it('should correctly assign \'hoveron\' default', function() {
64+
traceIn = {
65+
x: [1, 2, 3],
66+
y: [1, 2, 3],
67+
mode: 'lines+markers',
68+
fill: 'tonext'
69+
};
70+
71+
// even with fill tonext, as long as there are markers or text
72+
// you get points
73+
// you need visible: true here, as that normally gets set
74+
// outside of the module supplyDefaults
75+
traceOut = {visible: true};
76+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
77+
expect(traceOut.hoveron).toBe('points');
78+
79+
// but with only lines (or just fill) and fill tonext or toself
80+
// you get fills
81+
traceIn.mode = 'lines';
82+
traceOut = {visible: true};
83+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
84+
expect(traceOut.hoveron).toBe('fills');
85+
86+
// with the wrong fill you always get points
87+
// only area fills default to hoveron points. Vertical or
88+
// horizontal fills don't have the same physical meaning,
89+
// they're generally just filling their own slice, so they
90+
// default to hoveron points.
91+
traceIn.fill = 'tonexty';
92+
traceOut = {visible: true};
93+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
94+
expect(traceOut.hoveron).toBe('points');
95+
});
6396
});
6497

6598
describe('isBubble', function() {

test/jasmine/tests/scatterternary_test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,40 @@ describe('scatterternary defaults', function() {
158158
supplyDefaults(traceIn, traceOut, defaultColor, layout);
159159
expect(traceOut.hoverinfo).toBe('a+b+c+text');
160160
});
161+
162+
it('should correctly assign \'hoveron\' default', function() {
163+
traceIn = {
164+
a: [1, 2, 3],
165+
b: [1, 2, 3],
166+
c: [1, 2, 3],
167+
mode: 'lines+markers',
168+
fill: 'tonext'
169+
};
170+
171+
// even with fill tonext, as long as there are markers or text
172+
// you get points
173+
// you need visible: true here, as that normally gets set
174+
// outside of the module supplyDefaults
175+
traceOut = {visible: true};
176+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
177+
expect(traceOut.hoveron).toBe('points');
178+
179+
// but with only lines (or just fill) and fill tonext or toself
180+
// you get fills
181+
traceIn.mode = 'lines';
182+
traceOut = {visible: true};
183+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
184+
expect(traceOut.hoveron).toBe('fills');
185+
186+
// without a fill you always get points. For scatterternary, unlike
187+
// scatter, every allowed fill but 'none' is an area fill (rather than
188+
// a vertical / horizontal fill) so they all should default to
189+
// hoveron points.
190+
traceIn.fill = 'none';
191+
traceOut = {visible: true};
192+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
193+
expect(traceOut.hoveron).toBe('points');
194+
});
161195
});
162196

163197
describe('scatterternary calc', function() {

0 commit comments

Comments
 (0)