Skip to content

Commit d3d8db7

Browse files
committed
Revert "adapt tests"
This reverts commit bd47920.
1 parent e53a3f6 commit d3d8db7

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

test/jasmine/bundle_tests/plotschema_test.js

+34-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('plot schema', function() {
2525
var isPlainObject = Lib.isPlainObject;
2626

2727
var VALTYPES = Object.keys(valObjects);
28+
var ROLES = ['info', 'style', 'data'];
2829
var editType = plotSchema.defs.editType;
2930

3031
function assertTraceSchema(callback) {
@@ -72,6 +73,26 @@ describe('plot schema', function() {
7273
);
7374
});
7475

76+
it('all attributes should only have valid `role`', function() {
77+
assertPlotSchema(
78+
function(attr) {
79+
if(isValObject(attr)) {
80+
expect(ROLES.indexOf(attr.role) !== -1).toBe(true, attr);
81+
}
82+
}
83+
);
84+
});
85+
86+
it('all nested objects should have the *object* `role`', function() {
87+
assertPlotSchema(
88+
function(attr, attrName) {
89+
if(!isValObject(attr) && isPlainObject(attr) && attrName !== 'items') {
90+
expect(attr.role === 'object').toBe(true);
91+
}
92+
}
93+
);
94+
});
95+
7596
it('all attributes should have the required options', function() {
7697
assertPlotSchema(
7798
function(attr) {
@@ -94,7 +115,7 @@ describe('plot schema', function() {
94115
var opts = valObject.requiredOpts
95116
.concat(valObject.otherOpts)
96117
.concat([
97-
'valType', 'description',
118+
'valType', 'description', 'role',
98119
'editType', 'impliedEdits', 'anim',
99120
'_compareAsJSON', '_noTemplating'
100121
]);
@@ -164,8 +185,13 @@ describe('plot schema', function() {
164185

165186
// N.B. the specs below must be satisfied for plotly.py
166187
expect(isPlainObject(itemsObj)).toBe(true);
188+
expect(itemsObj.role).toBeUndefined();
167189
expect(Object.keys(itemsObj).length).toEqual(1);
168190
expect(isPlainObject(itemObj)).toBe(true);
191+
expect(itemObj.role).toBe('object');
192+
193+
var role = np.get().role;
194+
expect(role).toEqual('object');
169195
});
170196
});
171197

@@ -197,7 +223,7 @@ describe('plot schema', function() {
197223
);
198224
});
199225

200-
it('deprecated attributes should have a `valType`', function() {
226+
it('deprecated attributes should have a `valType` and `role`', function() {
201227
var DEPRECATED = '_deprecated';
202228

203229
assertPlotSchema(
@@ -208,6 +234,8 @@ describe('plot schema', function() {
208234

209235
expect(VALTYPES.indexOf(dAttr.valType) !== -1)
210236
.toBe(true, attrString + ': ' + dAttrName);
237+
expect(ROLES.indexOf(dAttr.role) !== -1)
238+
.toBe(true, attrString + ': ' + dAttrName);
211239
});
212240
}
213241
}
@@ -289,13 +317,15 @@ describe('plot schema', function() {
289317
expect(plotSchema.defs.metaKeys)
290318
.toEqual([
291319
'_isSubplotObj', '_isLinkedToArray', '_arrayAttrRegexps',
292-
'_deprecated', 'description', 'editType', 'impliedEdits'
320+
'_deprecated', 'description', 'role', 'editType', 'impliedEdits'
293321
]);
294322
});
295323

296324
it('should list the correct frame attributes', function() {
297325
expect(plotSchema.frames).toBeDefined();
326+
expect(plotSchema.frames.role).toEqual('object');
298327
expect(plotSchema.frames.items.frames_entry).toBeDefined();
328+
expect(plotSchema.frames.items.frames_entry.role).toEqual('object');
299329
});
300330

301331
it('should list config attributes', function() {
@@ -439,7 +469,7 @@ describe('getTraceValObject', function() {
439469
// it still returns the attribute itself - but maybe we should only do this
440470
// for valType: any? (or data_array/arrayOk with just an index)
441471
[
442-
'valType', 'dflt', 'description', 'arrayOk',
472+
'valType', 'dflt', 'role', 'description', 'arrayOk',
443473
'editType', 'min', 'max', 'values'
444474
].forEach(function(prop) {
445475
expect(getTraceValObject({}, ['x', prop]))

test/jasmine/tests/plot_api_test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,8 @@ describe('plot_api edit_types', function() {
28772877

28782878
editTypes.update(flags, {
28792879
valType: 'boolean',
2880-
dflt: true
2880+
dflt: true,
2881+
role: 'style'
28812882
});
28822883

28832884
expect(flags).toEqual({calc: false, style: true});
@@ -2897,7 +2898,8 @@ describe('plot_api edit_types', function() {
28972898
editTypes.update(flags, {
28982899
editType: 'calc+style',
28992900
valType: 'number',
2900-
dflt: 1
2901+
dflt: 1,
2902+
role: 'style'
29012903
});
29022904

29032905
expect(flags).toEqual({calc: true, legend: true, style: true});

0 commit comments

Comments
 (0)