-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,77 @@ | ||
import path from 'path'; | ||
import TestHelper from '@test/test-helper'; | ||
import TestHelper from '@test/test-helper.mjs'; | ||
|
||
const jsonSchema = require('@definitions/3.0.0/Reference.json'); | ||
|
||
describe('Reference Object', () => { | ||
it('$ref may be empty', () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './empty.json'), | ||
{ | ||
"$ref": "" | ||
}, | ||
)); | ||
|
||
it('$ref cannot be number', () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './number.json'), | ||
{ | ||
"$ref": 1234 | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it('$ref cannot be object', () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './object.json'), | ||
{ | ||
"$ref": { | ||
"$ref": "#/components/schemas/user" | ||
} | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it('$ref cannot be plain string', () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './string.json'), | ||
{ | ||
"$ref": "string value" | ||
}, | ||
['must match format "uri-reference"'] | ||
)); | ||
|
||
it('$ref cannot be boolean', () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './boolean.json'), | ||
{ | ||
"$ref": true | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it('$ref cannot be null', () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './null.json'), | ||
{ | ||
"$ref": null | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it('$ref cannot be array', () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './array.json'), | ||
{ | ||
"$ref": [ | ||
1, | ||
null, | ||
false, | ||
"#/components/schemas/user", | ||
{ | ||
"$ref": "#/components/schemas/user" | ||
} | ||
] | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it('$ref is URI', () => TestHelper.objectIsValid( | ||
it('$ref MUST be URI', () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
path.resolve(__dirname, './uri.json'), | ||
{ | ||
"$ref": "#/components/schemas/user" | ||
}, | ||
)); | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
JsonSchemaTestSuite, | ||
JsonSchemaTestSuiteConfig, | ||
JsonSchemaTestSuiteData | ||
} from '@test/definitions/base-schema-test.mjs'; | ||
import {describe} from 'vitest'; | ||
|
||
const jsonSchema = require('@definitions/3.0.0/Reference.json'); | ||
|
||
const config = new JsonSchemaTestSuiteConfig( | ||
true, | ||
['must have required property \'$ref\''], | ||
true, | ||
[] | ||
); | ||
|
||
const data = new JsonSchemaTestSuiteData( | ||
jsonSchema, | ||
[ | ||
{ | ||
"$ref": "#/components/schemas/user" | ||
} | ||
], | ||
{ | ||
"$ref": "#/components/schemas/user" | ||
}, | ||
{}, | ||
{ | ||
"$ref": "#/components/schemas/user", | ||
"x-number": 0, | ||
"x-string": "", | ||
"x-object": { | ||
"property": {} | ||
} | ||
}, | ||
{ | ||
"$ref": "#/components/schemas/user", | ||
"x-number": 0, | ||
"x-string": "", | ||
"x-object": { | ||
"property": {} | ||
}, | ||
"ext-number": 1 | ||
} | ||
); | ||
|
||
describe('Reference', () => { | ||
new JsonSchemaTestSuite(data, config).testSuite() | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import {describe} from 'vitest'; | ||
import { | ||
JsonSchemaTestSuite, | ||
JsonSchemaTestSuiteConfig, | ||
JsonSchemaTestSuiteData | ||
} from '@test/definitions/base-schema-test.mjs'; | ||
|
||
const jsonSchema = require('@definitions/3.0.0/serverVariable.json'); | ||
|
||
const config = new JsonSchemaTestSuiteConfig( | ||
false, | ||
[], | ||
true, | ||
[] | ||
); | ||
|
||
const data = new JsonSchemaTestSuiteData( | ||
jsonSchema, | ||
[ | ||
{ | ||
"enum": [ | ||
"8883", | ||
"8884" | ||
], | ||
"default": "8883", | ||
"description": "To which port connect", | ||
"examples": [ | ||
"8883", | ||
"8884" | ||
] | ||
} | ||
], | ||
{}, | ||
{ | ||
"enum": [ | ||
"8883", | ||
"8884" | ||
], | ||
"default": "8883", | ||
"description": "To which port connect", | ||
"examples": [ | ||
"8883", | ||
"8884" | ||
] | ||
}, | ||
{ | ||
"enum": [ | ||
"8883", | ||
"8884" | ||
], | ||
"default": "8883", | ||
"description": "To which port connect", | ||
"examples": [ | ||
"8883", | ||
"8884" | ||
], | ||
"x-number": 0, | ||
"x-string": "", | ||
"x-object": { | ||
"property": {} | ||
} | ||
}, | ||
{ | ||
"x-number": 0, | ||
"x-string": "", | ||
"x-object": { | ||
"property": {} | ||
}, | ||
"ext-number": 1 | ||
} | ||
); | ||
|
||
describe('Server Variable', () => { | ||
new JsonSchemaTestSuite(data, config).testSuite() | ||
}); |