Skip to content

Commit

Permalink
adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jan 20, 2021
1 parent b4c6798 commit bd47920
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
38 changes: 4 additions & 34 deletions test/jasmine/bundle_tests/plotschema_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('plot schema', function() {
var isPlainObject = Lib.isPlainObject;

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

function assertTraceSchema(callback) {
Expand Down Expand Up @@ -73,26 +72,6 @@ describe('plot schema', function() {
);
});

it('all attributes should only have valid `role`', function() {
assertPlotSchema(
function(attr) {
if(isValObject(attr)) {
expect(ROLES.indexOf(attr.role) !== -1).toBe(true, attr);
}
}
);
});

it('all nested objects should have the *object* `role`', function() {
assertPlotSchema(
function(attr, attrName) {
if(!isValObject(attr) && isPlainObject(attr) && attrName !== 'items') {
expect(attr.role === 'object').toBe(true);
}
}
);
});

it('all attributes should have the required options', function() {
assertPlotSchema(
function(attr) {
Expand All @@ -115,7 +94,7 @@ describe('plot schema', function() {
var opts = valObject.requiredOpts
.concat(valObject.otherOpts)
.concat([
'valType', 'description', 'role',
'valType', 'description',
'editType', 'impliedEdits', 'anim',
'_compareAsJSON', '_noTemplating'
]);
Expand Down Expand Up @@ -185,13 +164,8 @@ describe('plot schema', function() {

// N.B. the specs below must be satisfied for plotly.py
expect(isPlainObject(itemsObj)).toBe(true);
expect(itemsObj.role).toBeUndefined();
expect(Object.keys(itemsObj).length).toEqual(1);
expect(isPlainObject(itemObj)).toBe(true);
expect(itemObj.role).toBe('object');

var role = np.get().role;
expect(role).toEqual('object');
});
});

Expand Down Expand Up @@ -223,7 +197,7 @@ describe('plot schema', function() {
);
});

it('deprecated attributes should have a `valType` and `role`', function() {
it('deprecated attributes should have a `valType`', function() {
var DEPRECATED = '_deprecated';

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

expect(VALTYPES.indexOf(dAttr.valType) !== -1)
.toBe(true, attrString + ': ' + dAttrName);
expect(ROLES.indexOf(dAttr.role) !== -1)
.toBe(true, attrString + ': ' + dAttrName);
});
}
}
Expand Down Expand Up @@ -317,15 +289,13 @@ describe('plot schema', function() {
expect(plotSchema.defs.metaKeys)
.toEqual([
'_isSubplotObj', '_isLinkedToArray', '_arrayAttrRegexps',
'_deprecated', 'description', 'role', 'editType', 'impliedEdits'
'_deprecated', 'description', 'editType', 'impliedEdits'
]);
});

it('should list the correct frame attributes', function() {
expect(plotSchema.frames).toBeDefined();
expect(plotSchema.frames.role).toEqual('object');
expect(plotSchema.frames.items.frames_entry).toBeDefined();
expect(plotSchema.frames.items.frames_entry.role).toEqual('object');
});

it('should list config attributes', function() {
Expand Down Expand Up @@ -469,7 +439,7 @@ describe('getTraceValObject', function() {
// it still returns the attribute itself - but maybe we should only do this
// for valType: any? (or data_array/arrayOk with just an index)
[
'valType', 'dflt', 'role', 'description', 'arrayOk',
'valType', 'dflt', 'description', 'arrayOk',
'editType', 'min', 'max', 'values'
].forEach(function(prop) {
expect(getTraceValObject({}, ['x', prop]))
Expand Down
6 changes: 2 additions & 4 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2877,8 +2877,7 @@ describe('plot_api edit_types', function() {

editTypes.update(flags, {
valType: 'boolean',
dflt: true,
role: 'style'
dflt: true
});

expect(flags).toEqual({calc: false, style: true});
Expand All @@ -2898,8 +2897,7 @@ describe('plot_api edit_types', function() {
editTypes.update(flags, {
editType: 'calc+style',
valType: 'number',
dflt: 1,
role: 'style'
dflt: 1
});

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

0 comments on commit bd47920

Please sign in to comment.