test: adjust schema test for broader use cases

This commit is contained in:
Rainer Killinger
2019-05-28 16:15:06 +02:00
parent c4a403e807
commit b965f7cd6e
2 changed files with 33 additions and 1 deletions

View File

@@ -14,6 +14,9 @@
*/
/**
* This is a simple interface declaration for
* testing the schema generation and validation.
*
* @validatable
*/
export interface Foo {
@@ -21,4 +24,15 @@ export interface Foo {
* Dummy parameter
*/
lorem: 'ipsum';
/**
* String literal type property
*/
type: FooType;
}
/**
* This is a simple type declaration for
* usage in the Foo interace.
*/
export type FooType = 'Foo';

View File

@@ -30,13 +30,20 @@ export class SchemaSpec {
const converter = new Converter(join(__dirname, '..', 'src', 'resources'));
const schema = converter.getSchema('Foo', '0.0.1');
expect(schema).to.be.deep.equal({
$schema: 'http://json-schema.org/draft-06/schema#',
additionalProperties: false,
definitions: {
FooType: {
description: 'This is a simple type declaration for\nusage in the Foo interace.',
enum: [
'Foo',
],
type: 'string',
},
SCFoo: {
additionalProperties: false,
description: 'This is a simple interface declaration for\ntesting the schema generation and validation.',
properties: {
lorem: {
description: 'Dummy parameter',
@@ -45,13 +52,19 @@ export class SchemaSpec {
],
type: 'string',
},
type: {
$ref: '#/definitions/FooType',
description: 'String literal type property',
},
},
required: [
'lorem',
'type',
],
type: 'object',
},
},
description: 'This is a simple interface declaration for\ntesting the schema generation and validation.',
id: 'https://core.stapps.tu-berlin.de/v0.0.1/lib/schema/Foo.json',
properties: {
lorem: {
@@ -61,9 +74,14 @@ export class SchemaSpec {
],
type: 'string',
},
type: {
$ref: '#/definitions/FooType',
description: 'String literal type property',
},
},
required: [
'lorem',
'type',
],
type: 'object',
});