@@ -25,6 +25,7 @@ describe('plot schema', function() {
25
25
var isPlainObject = Lib . isPlainObject ;
26
26
27
27
var VALTYPES = Object . keys ( valObjects ) ;
28
+ var formerRoles = [ 'info' , 'style' , 'data' ] ;
28
29
var editType = plotSchema . defs . editType ;
29
30
30
31
function assertTraceSchema ( callback ) {
@@ -72,6 +73,27 @@ describe('plot schema', function() {
72
73
) ;
73
74
} ) ;
74
75
76
+ it ( 'all attributes should not have a former `role`' , function ( ) {
77
+ assertPlotSchema (
78
+ function ( attr ) {
79
+ if ( isValObject ( attr ) ) {
80
+ expect ( formerRoles . indexOf ( attr . role ) === - 1 ) . toBe ( true , attr ) ;
81
+ expect ( attr . role ) . toBeUndefined ( attr ) ;
82
+ }
83
+ }
84
+ ) ;
85
+ } ) ;
86
+
87
+ it ( 'all nested objects should have the *object* `role`' , function ( ) {
88
+ assertPlotSchema (
89
+ function ( attr , attrName ) {
90
+ if ( ! isValObject ( attr ) && isPlainObject ( attr ) && attrName !== 'items' ) {
91
+ expect ( attr . role === 'object' ) . toBe ( true ) ;
92
+ }
93
+ }
94
+ ) ;
95
+ } ) ;
96
+
75
97
it ( 'all attributes should have the required options' , function ( ) {
76
98
assertPlotSchema (
77
99
function ( attr ) {
@@ -94,7 +116,7 @@ describe('plot schema', function() {
94
116
var opts = valObject . requiredOpts
95
117
. concat ( valObject . otherOpts )
96
118
. concat ( [
97
- 'valType' , 'description' ,
119
+ 'valType' , 'description' , 'role' ,
98
120
'editType' , 'impliedEdits' , 'anim' ,
99
121
'_compareAsJSON' , '_noTemplating'
100
122
] ) ;
@@ -164,8 +186,13 @@ describe('plot schema', function() {
164
186
165
187
// N.B. the specs below must be satisfied for plotly.py
166
188
expect ( isPlainObject ( itemsObj ) ) . toBe ( true ) ;
189
+ expect ( itemsObj . role ) . toBeUndefined ( ) ;
167
190
expect ( Object . keys ( itemsObj ) . length ) . toEqual ( 1 ) ;
168
191
expect ( isPlainObject ( itemObj ) ) . toBe ( true ) ;
192
+ expect ( itemObj . role ) . toBe ( 'object' ) ;
193
+
194
+ var role = np . get ( ) . role ;
195
+ expect ( role ) . toEqual ( 'object' ) ;
169
196
} ) ;
170
197
} ) ;
171
198
@@ -197,7 +224,7 @@ describe('plot schema', function() {
197
224
) ;
198
225
} ) ;
199
226
200
- it ( 'deprecated attributes should have a `valType`' , function ( ) {
227
+ it ( 'deprecated attributes should have a `valType` and not any former roles ' , function ( ) {
201
228
var DEPRECATED = '_deprecated' ;
202
229
203
230
assertPlotSchema (
@@ -206,8 +233,10 @@ describe('plot schema', function() {
206
233
Object . keys ( attr [ DEPRECATED ] ) . forEach ( function ( dAttrName ) {
207
234
var dAttr = attr [ DEPRECATED ] [ dAttrName ] ;
208
235
209
- expect ( VALTYPES . indexOf ( dAttr . valType ) !== - 1 )
210
- . toBe ( true , attrString + ': ' + dAttrName ) ;
236
+ var msg = attrString + ': ' + dAttrName ;
237
+ expect ( VALTYPES . indexOf ( dAttr . valType ) !== - 1 ) . toBe ( true , msg ) ;
238
+ expect ( formerRoles . indexOf ( dAttr . role ) === - 1 ) . toBe ( true , msg ) ;
239
+ expect ( dAttr . role ) . toBeUndefined ( msg ) ;
211
240
} ) ;
212
241
}
213
242
}
@@ -289,13 +318,15 @@ describe('plot schema', function() {
289
318
expect ( plotSchema . defs . metaKeys )
290
319
. toEqual ( [
291
320
'_isSubplotObj' , '_isLinkedToArray' , '_arrayAttrRegexps' ,
292
- '_deprecated' , 'description' , 'editType' , 'impliedEdits'
321
+ '_deprecated' , 'description' , 'role' , ' editType', 'impliedEdits'
293
322
] ) ;
294
323
} ) ;
295
324
296
325
it ( 'should list the correct frame attributes' , function ( ) {
297
326
expect ( plotSchema . frames ) . toBeDefined ( ) ;
327
+ expect ( plotSchema . frames . role ) . toEqual ( 'object' ) ;
298
328
expect ( plotSchema . frames . items . frames_entry ) . toBeDefined ( ) ;
329
+ expect ( plotSchema . frames . items . frames_entry . role ) . toEqual ( 'object' ) ;
299
330
} ) ;
300
331
301
332
it ( 'should list config attributes' , function ( ) {
@@ -439,7 +470,7 @@ describe('getTraceValObject', function() {
439
470
// it still returns the attribute itself - but maybe we should only do this
440
471
// for valType: any? (or data_array/arrayOk with just an index)
441
472
[
442
- 'valType' , 'dflt' , 'description' , 'arrayOk' ,
473
+ 'valType' , 'dflt' , 'role' , ' description', 'arrayOk' ,
443
474
'editType' , 'min' , 'max' , 'values'
444
475
] . forEach ( function ( prop ) {
445
476
expect ( getTraceValObject ( { } , [ 'x' , prop ] ) )
0 commit comments