Skip to content

Commit cb94e95

Browse files
committed
test restrictions on component xaxis/yaxis schemas
and fix some parts of plotschema test that the last commit broke
1 parent 96cc57f commit cb94e95

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

test/jasmine/tests/plotschema_test.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('plot schema', function() {
2626

2727
var VALTYPES = Object.keys(valObjects);
2828
var ROLES = ['info', 'style', 'data'];
29-
var editTypes = plotSchema.defs.editTypes;
29+
var editType = plotSchema.defs.editType;
3030

3131
function assertTraceSchema(callback) {
3232
var traces = plotSchema.traces;
@@ -251,21 +251,21 @@ describe('plot schema', function() {
251251

252252
assertTraceSchema(function(attr, attrName, attrs, level, attrString) {
253253
if(shouldHaveEditType(attr, attrName)) {
254-
expect(Lib.validate(attr.editType, editTypes.traces))
254+
expect(Lib.validate(attr.editType, editType.traces))
255255
.toBe(true, attrString + ': ' + JSON.stringify(attr.editType));
256256
}
257257
});
258258

259259
assertTransformSchema(function(attr, attrName, attrs, level, attrString) {
260260
if(shouldHaveEditType(attr, attrName)) {
261-
expect(Lib.validate(attr.editType, editTypes.traces))
261+
expect(Lib.validate(attr.editType, editType.traces))
262262
.toBe(true, attrString + ': ' + JSON.stringify(attr.editType));
263263
}
264264
});
265265

266266
assertLayoutSchema(function(attr, attrName, attrs, level, attrString) {
267267
if(shouldHaveEditType(attr, attrName)) {
268-
expect(Lib.validate(attr.editType, editTypes.layout))
268+
expect(Lib.validate(attr.editType, editType.layout))
269269
.toBe(true, attrString + ': ' + JSON.stringify(attr.editType));
270270
}
271271
});
@@ -399,7 +399,7 @@ describe('getTraceValObject', function() {
399399
// for valType: any? (or data_array/arrayOk with just an index)
400400
[
401401
'valType', 'dflt', 'role', 'description', 'arrayOk',
402-
'editTypes', 'min', 'max', 'values'
402+
'editType', 'min', 'max', 'values'
403403
].forEach(function(prop) {
404404
expect(getTraceValObject({}, ['x', prop]))
405405
.toBe(scatter.attributes.x, prop);
@@ -543,3 +543,26 @@ describe('getLayoutValObject', function() {
543543
expect(getLayoutValObject(combinedLayout2, ticklenParts)).toBe(gl2dTicklen);
544544
});
545545
});
546+
547+
describe('component schemas', function() {
548+
it('does not have yaxis-only attributes or mismatched x/yaxis attributes', function() {
549+
// in principle either of these should be allowable, but we don't currently
550+
// support them so lets simply test that we haven't added them accidentally!
551+
552+
function delDescription(attr) { delete attr.description; }
553+
554+
for(var key in Registry.componentsRegistry) {
555+
var _module = Registry.componentsRegistry[key];
556+
var schema = _module.schema;
557+
if(schema && schema.subplots && schema.subplots.yaxis) {
558+
expect(schema.subplots.xaxis).toBeDefined(_module.name);
559+
560+
var xa = Lib.extendDeep({}, schema.subplots.xaxis);
561+
var ya = Lib.extendDeep({}, schema.subplots.yaxis);
562+
Plotly.PlotSchema.crawl(xa, delDescription);
563+
Plotly.PlotSchema.crawl(ya, delDescription);
564+
expect(JSON.stringify(xa)).toBe(JSON.stringify(ya), _module.name);
565+
}
566+
}
567+
});
568+
});

0 commit comments

Comments
 (0)