@@ -138,6 +138,21 @@ describe('Plotly.validate', function() {
138138 ) ;
139139 } ) ;
140140
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+
141156 it ( 'should work with isLinkedToArray attributes' , function ( ) {
142157 var out = Plotly . validate ( [ ] , {
143158 annotations : [ {
@@ -154,7 +169,7 @@ describe('Plotly.validate', function() {
154169 label : '1 month' ,
155170 step : 'all' ,
156171 count : 10
157- } , {
172+ } , 'wont-work' , {
158173 title : '1 month'
159174 } ]
160175 }
@@ -175,10 +190,25 @@ describe('Plotly.validate', function() {
175190 } ,
176191 shapes : [ {
177192 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' ]
178208 } ]
179209 } ) ;
180210
181- expect ( out . length ) . toEqual ( 7 ) ;
211+ expect ( out . length ) . toEqual ( 12 ) ;
182212 assertErrorContent (
183213 out [ 0 ] , 'schema' , 'layout' , null ,
184214 [ 'annotations' , 1 , 'arrowSymbol' ] , 'annotations[1].arrowSymbol' ,
@@ -197,27 +227,48 @@ describe('Plotly.validate', function() {
197227 ) ;
198228 assertErrorContent (
199229 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'
203233 ) ;
204234 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 ,
206242 [ 'xaxis2' , 'rangeselector' , 'buttons' , 0 , 'title' ] ,
207243 'xaxis2.rangeselector.buttons[0].title' ,
208244 'In layout, key xaxis2.rangeselector.buttons[0].title is not part of the schema'
209245 ) ;
210246 assertErrorContent (
211- out [ 5 ] , 'array' , 'layout' , null ,
247+ out [ 6 ] , 'array' , 'layout' , null ,
212248 [ 'xaxis3' , 'rangeselector' , 'buttons' ] ,
213249 'xaxis3.rangeselector.buttons' ,
214250 'In layout, key xaxis3.rangeselector.buttons must be linked to an array container'
215251 ) ;
216252 assertErrorContent (
217- out [ 6 ] , 'value' , 'layout' , null ,
253+ out [ 7 ] , 'value' , 'layout' , null ,
218254 [ 'shapes' , 0 , 'opacity' ] , 'shapes[0].opacity' ,
219255 'In layout, key shapes[0].opacity is set to an invalid value (none)'
220256 ) ;
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+ ) ;
221272 } ) ;
222273
223274 it ( 'should work with isSubplotObj attributes' , function ( ) {
0 commit comments