@@ -138,6 +138,21 @@ describe('Plotly.validate', function() {
138
138
) ;
139
139
} ) ;
140
140
141
+ it ( 'should work with info arrays' , function ( ) {
142
+ var out = Plotly . validate ( [ {
143
+ y : [ 1 , 2 , 2 ]
144
+ } ] , {
145
+ xaxis : { range : [ 0 , 10 ] } ,
146
+ yaxis : { range : 'not-gonna-work' } ,
147
+ } ) ;
148
+
149
+ expect ( out . length ) . toEqual ( 1 ) ;
150
+ assertErrorContent (
151
+ out [ 0 ] , 'value' , 'layout' , null , [ 'yaxis' , 'range' ] , 'yaxis.range' ,
152
+ 'In layout, key yaxis.range is set to an invalid value (not-gonna-work)'
153
+ ) ;
154
+ } ) ;
155
+
141
156
it ( 'should work with isLinkedToArray attributes' , function ( ) {
142
157
var out = Plotly . validate ( [ ] , {
143
158
annotations : [ {
@@ -154,7 +169,7 @@ describe('Plotly.validate', function() {
154
169
label : '1 month' ,
155
170
step : 'all' ,
156
171
count : 10
157
- } , {
172
+ } , 'wont-work' , {
158
173
title : '1 month'
159
174
} ]
160
175
}
@@ -175,10 +190,25 @@ describe('Plotly.validate', function() {
175
190
} ,
176
191
shapes : [ {
177
192
opacity : 'none'
193
+ } ] ,
194
+ updatemenus : [ {
195
+ buttons : [ {
196
+ method : 'restyle' ,
197
+ args : [ 'marker.color' , 'red' ]
198
+ } ]
199
+ } , 'wont-work' , {
200
+ buttons : [ {
201
+ method : 'restyle' ,
202
+ args : null
203
+ } , {
204
+ method : 'relayout' ,
205
+ args : [ 'marker.color' , 'red' ] ,
206
+ title : 'not-gonna-work'
207
+ } , 'wont-work' ]
178
208
} ]
179
209
} ) ;
180
210
181
- expect ( out . length ) . toEqual ( 7 ) ;
211
+ expect ( out . length ) . toEqual ( 12 ) ;
182
212
assertErrorContent (
183
213
out [ 0 ] , 'schema' , 'layout' , null ,
184
214
[ 'annotations' , 1 , 'arrowSymbol' ] , 'annotations[1].arrowSymbol' ,
@@ -197,27 +227,48 @@ describe('Plotly.validate', function() {
197
227
) ;
198
228
assertErrorContent (
199
229
out [ 3 ] , 'schema' , 'layout' , null ,
200
- [ 'xaxis' , 'rangeselector' , 'buttons' , 1 , 'title' ] ,
201
- 'xaxis.rangeselector.buttons[1 ].title' ,
202
- 'In layout, key xaxis.rangeselector.buttons[1 ].title is not part of the schema'
230
+ [ 'xaxis' , 'rangeselector' , 'buttons' , 2 , 'title' ] ,
231
+ 'xaxis.rangeselector.buttons[2 ].title' ,
232
+ 'In layout, key xaxis.rangeselector.buttons[2 ].title is not part of the schema'
203
233
) ;
204
234
assertErrorContent (
205
- out [ 4 ] , 'schema' , 'layout' , null ,
235
+ out [ 4 ] , 'object' , 'layout' , null ,
236
+ [ 'xaxis' , 'rangeselector' , 'buttons' , 1 ] ,
237
+ 'xaxis.rangeselector.buttons[1]' ,
238
+ 'In layout, key xaxis.rangeselector.buttons[1] must be linked to an object container'
239
+ ) ;
240
+ assertErrorContent (
241
+ out [ 5 ] , 'schema' , 'layout' , null ,
206
242
[ 'xaxis2' , 'rangeselector' , 'buttons' , 0 , 'title' ] ,
207
243
'xaxis2.rangeselector.buttons[0].title' ,
208
244
'In layout, key xaxis2.rangeselector.buttons[0].title is not part of the schema'
209
245
) ;
210
246
assertErrorContent (
211
- out [ 5 ] , 'array' , 'layout' , null ,
247
+ out [ 6 ] , 'array' , 'layout' , null ,
212
248
[ 'xaxis3' , 'rangeselector' , 'buttons' ] ,
213
249
'xaxis3.rangeselector.buttons' ,
214
250
'In layout, key xaxis3.rangeselector.buttons must be linked to an array container'
215
251
) ;
216
252
assertErrorContent (
217
- out [ 6 ] , 'value' , 'layout' , null ,
253
+ out [ 7 ] , 'value' , 'layout' , null ,
218
254
[ 'shapes' , 0 , 'opacity' ] , 'shapes[0].opacity' ,
219
255
'In layout, key shapes[0].opacity is set to an invalid value (none)'
220
256
) ;
257
+ assertErrorContent (
258
+ out [ 8 ] , 'schema' , 'layout' , null ,
259
+ [ 'updatemenus' , 2 , 'buttons' , 1 , 'title' ] , 'updatemenus[2].buttons[1].title' ,
260
+ 'In layout, key updatemenus[2].buttons[1].title is not part of the schema'
261
+ ) ;
262
+ assertErrorContent (
263
+ out [ 9 ] , 'unused' , 'layout' , null ,
264
+ [ 'updatemenus' , 2 , 'buttons' , 0 ] , 'updatemenus[2].buttons[0]' ,
265
+ 'In layout, key updatemenus[2].buttons[0] did not get coerced'
266
+ ) ;
267
+ assertErrorContent (
268
+ out [ 10 ] , 'object' , 'layout' , null ,
269
+ [ 'updatemenus' , 2 , 'buttons' , 2 ] , 'updatemenus[2].buttons[2]' ,
270
+ 'In layout, key updatemenus[2].buttons[2] must be linked to an object container'
271
+ ) ;
221
272
} ) ;
222
273
223
274
it ( 'should work with isSubplotObj attributes' , function ( ) {
0 commit comments