@@ -25,6 +25,7 @@ describe('plot schema', function() {
2525 var isPlainObject = Lib . isPlainObject ;
2626
2727 var VALTYPES = Object . keys ( valObjects ) ;
28+ var formerRoles = [ 'info' , 'style' , 'data' ] ;
2829 var editType = plotSchema . defs . editType ;
2930
3031 function assertTraceSchema ( callback ) {
@@ -72,6 +73,27 @@ describe('plot schema', function() {
7273 ) ;
7374 } ) ;
7475
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+
7597 it ( 'all attributes should have the required options' , function ( ) {
7698 assertPlotSchema (
7799 function ( attr ) {
@@ -94,7 +116,7 @@ describe('plot schema', function() {
94116 var opts = valObject . requiredOpts
95117 . concat ( valObject . otherOpts )
96118 . concat ( [
97- 'valType' , 'description' ,
119+ 'valType' , 'description' , 'role' ,
98120 'editType' , 'impliedEdits' , 'anim' ,
99121 '_compareAsJSON' , '_noTemplating'
100122 ] ) ;
@@ -164,8 +186,13 @@ describe('plot schema', function() {
164186
165187 // N.B. the specs below must be satisfied for plotly.py
166188 expect ( isPlainObject ( itemsObj ) ) . toBe ( true ) ;
189+ expect ( itemsObj . role ) . toBeUndefined ( ) ;
167190 expect ( Object . keys ( itemsObj ) . length ) . toEqual ( 1 ) ;
168191 expect ( isPlainObject ( itemObj ) ) . toBe ( true ) ;
192+ expect ( itemObj . role ) . toBe ( 'object' ) ;
193+
194+ var role = np . get ( ) . role ;
195+ expect ( role ) . toEqual ( 'object' ) ;
169196 } ) ;
170197 } ) ;
171198
@@ -197,7 +224,7 @@ describe('plot schema', function() {
197224 ) ;
198225 } ) ;
199226
200- it ( 'deprecated attributes should have a `valType`' , function ( ) {
227+ it ( 'deprecated attributes should have a `valType` and not any former roles ' , function ( ) {
201228 var DEPRECATED = '_deprecated' ;
202229
203230 assertPlotSchema (
@@ -206,8 +233,10 @@ describe('plot schema', function() {
206233 Object . keys ( attr [ DEPRECATED ] ) . forEach ( function ( dAttrName ) {
207234 var dAttr = attr [ DEPRECATED ] [ dAttrName ] ;
208235
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 ) ;
211240 } ) ;
212241 }
213242 }
@@ -289,13 +318,15 @@ describe('plot schema', function() {
289318 expect ( plotSchema . defs . metaKeys )
290319 . toEqual ( [
291320 '_isSubplotObj' , '_isLinkedToArray' , '_arrayAttrRegexps' ,
292- '_deprecated' , 'description' , 'editType' , 'impliedEdits'
321+ '_deprecated' , 'description' , 'role' , ' editType', 'impliedEdits'
293322 ] ) ;
294323 } ) ;
295324
296325 it ( 'should list the correct frame attributes' , function ( ) {
297326 expect ( plotSchema . frames ) . toBeDefined ( ) ;
327+ expect ( plotSchema . frames . role ) . toEqual ( 'object' ) ;
298328 expect ( plotSchema . frames . items . frames_entry ) . toBeDefined ( ) ;
329+ expect ( plotSchema . frames . items . frames_entry . role ) . toEqual ( 'object' ) ;
299330 } ) ;
300331
301332 it ( 'should list config attributes' , function ( ) {
@@ -439,7 +470,7 @@ describe('getTraceValObject', function() {
439470 // it still returns the attribute itself - but maybe we should only do this
440471 // for valType: any? (or data_array/arrayOk with just an index)
441472 [
442- 'valType' , 'dflt' , 'description' , 'arrayOk' ,
473+ 'valType' , 'dflt' , 'role' , ' description', 'arrayOk' ,
443474 'editType' , 'min' , 'max' , 'values'
444475 ] . forEach ( function ( prop ) {
445476 expect ( getTraceValObject ( { } , [ 'x' , prop ] ) )
0 commit comments