@0xcert/conventions
Version:
Module with implementation of all confirmed conventions.
99 lines • 3.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@hayspec/spec");
const jsonschema_1 = require("jsonschema");
const xcert_schema_1 = require("../assets/xcert-schema");
const spec = new spec_1.Spec();
spec.before((stage) => {
stage.set('validator', new jsonschema_1.Validator());
});
spec.test('allows simple types', (ctx) => {
const data = {
'$schema': 'https://conventions.0xcert.org/xcert-schema.json',
'description': '',
'properties': {
'string': {
'description': '',
'type': 'string',
},
'number': {
'description': '',
'type': 'number',
},
'boolean': {
'description': '',
'type': 'boolean',
},
'object': {
'description': '',
'type': 'object',
'properties': {
'string': {
'description': '',
'type': 'string',
},
'number': {
'description': '',
'type': 'number',
},
'boolean': {
'description': '',
'type': 'boolean',
},
'object': {
'description': '',
'type': 'object',
'properties': {
'string': {
'description': '',
'type': 'string',
},
'number': {
'description': '',
'type': 'number',
},
'boolean': {
'description': '',
'type': 'boolean',
},
},
},
},
},
'string-array': {
'description': '',
'type': 'array',
'items': {
'type': 'string',
},
},
'number-array': {
'description': '',
'type': 'array',
'items': {
'type': 'number',
},
},
'boolean-array': {
'description': '',
'type': 'array',
'items': {
'type': 'boolean',
},
},
'object-array': {
'description': '',
'type': 'array',
'items': {
'type': 'object',
'properties': {},
},
},
},
'title': '',
'type': 'object',
};
ctx.true(ctx.get('validator').validate(data, xcert_schema_1.xcertSchema).valid);
});
exports.default = spec;
//# sourceMappingURL=xcert-schema.test.js.map