Skip to content

Commit 4a9edd0

Browse files
committed
Working through slider testing issues
1 parent 1cad8a4 commit 4a9edd0

File tree

2 files changed

+151
-1
lines changed

2 files changed

+151
-1
lines changed

src/components/sliders/attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ module.exports = {
200200
valType: 'enumerated',
201201
values: ['left', 'center', 'right'],
202202
dflt: 'left',
203+
role: 'info',
203204
description: [
204205
'The alignment of the value readout relative to the length of the slider.'
205206
].join(' ')
@@ -219,7 +220,7 @@ module.exports = {
219220
valType: 'string',
220221
role: 'info',
221222
description: [
222-
'When `currentvalue.visible` is true, this sets the prefix of the lable. If provided,',
223+
'When currentvalue.visible is true, this sets the prefix of the lable. If provided,',
223224
'it will be joined to the current value with a single space between.'
224225
].join(' ')
225226
},

test/jasmine/tests/sliders_test.js

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
var Sliders = require('@src/components/sliders');
2+
// var constants = require('@src/components/sliders/constants');
3+
4+
// var d3 = require('d3');
5+
// var Plotly = require('@lib');
6+
// var Lib = require('@src/lib');
7+
// var createGraphDiv = require('../assets/create_graph_div');
8+
// var destroyGraphDiv = require('../assets/destroy_graph_div');
9+
10+
describe('sliders defaults', function() {
11+
'use strict';
12+
13+
var supply = Sliders.supplyLayoutDefaults;
14+
15+
var layoutIn, layoutOut;
16+
17+
beforeEach(function() {
18+
layoutIn = {};
19+
layoutOut = {};
20+
});
21+
22+
it('should set \'visible\' to false when no steps are present', function() {
23+
layoutIn.sliders = [{
24+
steps: [{
25+
method: 'relayout',
26+
args: ['title', 'Hello World']
27+
}, {
28+
method: 'update',
29+
args: [ { 'marker.size': 20 }, { 'xaxis.range': [0, 10] }, [0, 1] ]
30+
}, {
31+
method: 'animate',
32+
args: [ 'frame1', { transition: { duration: 500, ease: 'cubic-in-out' }}]
33+
}]
34+
}, {
35+
bgcolor: 'red'
36+
}, {
37+
visible: false,
38+
steps: [{
39+
method: 'relayout',
40+
args: ['title', 'Hello World']
41+
}]
42+
}];
43+
44+
supply(layoutIn, layoutOut);
45+
46+
expect(layoutOut.sliders[0].visible).toBe(true);
47+
expect(layoutOut.sliders[0].active).toEqual(0);
48+
expect(layoutOut.sliders[0].steps[0].args.length).toEqual(2);
49+
expect(layoutOut.sliders[0].steps[1].args.length).toEqual(3);
50+
expect(layoutOut.sliders[0].steps[2].args.length).toEqual(2);
51+
52+
expect(layoutOut.sliders[1].visible).toBe(false);
53+
expect(layoutOut.sliders[1].active).toBeUndefined();
54+
55+
expect(layoutOut.sliders[2].visible).toBe(false);
56+
expect(layoutOut.sliders[2].active).toBeUndefined();
57+
});
58+
59+
it('should skip over non-object steps', function() {
60+
layoutIn.sliders = [{
61+
steps: [
62+
null,
63+
{
64+
method: 'relayout',
65+
args: ['title', 'Hello World']
66+
},
67+
'remove'
68+
]
69+
}];
70+
71+
supply(layoutIn, layoutOut);
72+
73+
expect(layoutOut.sliders[0].steps.length).toEqual(1);
74+
expect(layoutOut.sliders[0].steps[0]).toEqual({
75+
method: 'relayout',
76+
args: ['title', 'Hello World'],
77+
label: '',
78+
_index: 1
79+
});
80+
});
81+
82+
it('should skip over steps with array \'args\' field', function() {
83+
layoutIn.sliders = [{
84+
steps: [{
85+
method: 'restyle',
86+
}, {
87+
method: 'relayout',
88+
args: ['title', 'Hello World']
89+
}, {
90+
method: 'relayout',
91+
args: null
92+
}, {}]
93+
}];
94+
95+
supply(layoutIn, layoutOut);
96+
97+
expect(layoutOut.sliders[0].steps.length).toEqual(1);
98+
expect(layoutOut.sliders[0].steps[0]).toEqual({
99+
method: 'relayout',
100+
args: ['title', 'Hello World'],
101+
label: '',
102+
_index: 1
103+
});
104+
});
105+
106+
it('should keep ref to input update menu container', function() {
107+
layoutIn.sliders = [{
108+
steps: [{
109+
method: 'relayout',
110+
args: ['title', 'Hello World']
111+
}]
112+
}, {
113+
bgcolor: 'red'
114+
}, {
115+
visible: false,
116+
steps: [{
117+
method: 'relayout',
118+
args: ['title', 'Hello World']
119+
}]
120+
}];
121+
122+
supply(layoutIn, layoutOut);
123+
124+
expect(layoutOut.sliders[0]._input).toBe(layoutIn.sliders[0]);
125+
expect(layoutOut.sliders[1]._input).toBe(layoutIn.sliders[1]);
126+
expect(layoutOut.sliders[2]._input).toBe(layoutIn.sliders[2]);
127+
});
128+
129+
it('should default \'bgcolor\' to layout \'paper_bgcolor\'', function() {
130+
var steps = [{
131+
method: 'relayout',
132+
args: ['title', 'Hello World']
133+
}];
134+
135+
layoutIn.sliders = [{
136+
steps: steps,
137+
}, {
138+
bgcolor: 'red',
139+
steps: steps
140+
}];
141+
142+
layoutOut.paper_bgcolor = 'blue';
143+
144+
supply(layoutIn, layoutOut);
145+
146+
expect(layoutOut.sliders[0].bgcolor).toEqual('blue');
147+
expect(layoutOut.sliders[1].bgcolor).toEqual('red');
148+
});
149+
});

0 commit comments

Comments
 (0)