-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(definitions): Info properties test
- Loading branch information
Showing
8 changed files
with
619 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
test/definitions/3.0.0/models/info/info/properties/contact.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import {describe, it} from 'vitest'; | ||
import TestHelper from '@test/test-helper'; | ||
import path from 'path'; | ||
|
||
const jsonSchema = require('@definitions/3.0.0/info.json'); | ||
|
||
describe('Info: contact', () => { | ||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} null`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"contact": null | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsValidWhenIsTestName} empty`, () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"contact": {} | ||
}, | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} string`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"contact": "short description" | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsValidWhenIsTestName} object`, () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"contact": { | ||
"name": "AsyncAPI", | ||
"url": "https://www.asyncapi.com", | ||
"email": "[email protected]" | ||
} | ||
}, | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} array`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"contact": [ | ||
null, [], "", {}, false, 123 | ||
] | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} number`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"contact": 123 | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} boolean`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"contact": false | ||
}, | ||
['must be object'] | ||
)); | ||
}); |
80 changes: 80 additions & 0 deletions
80
test/definitions/3.0.0/models/info/info/properties/description.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import {describe, it} from 'vitest'; | ||
import TestHelper from '@test/test-helper'; | ||
import path from 'path'; | ||
|
||
const jsonSchema = require('@definitions/3.0.0/info.json'); | ||
|
||
describe('Info: description', () => { | ||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} null`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"description": null | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsValidWhenIsTestName} empty`, () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"description": "" | ||
}, | ||
)); | ||
|
||
it(`${TestHelper.propertyIsValidWhenIsTestName} string`, () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"description": "short description" | ||
}, | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} object`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"description": { | ||
"longVariant": "", | ||
"shortVariant": "" | ||
} | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} array`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"description": [ | ||
null, [], "", {}, false, 123 | ||
] | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} number`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"description": 123 | ||
}, | ||
['must be string'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} boolean`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"description": false | ||
}, | ||
['must be string'] | ||
)); | ||
}); |
105 changes: 105 additions & 0 deletions
105
test/definitions/3.0.0/models/info/info/properties/externalDocs.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import {describe, it} from 'vitest'; | ||
import TestHelper from '@test/test-helper'; | ||
import path from 'path'; | ||
|
||
const jsonSchema = require('@definitions/3.0.0/info.json'); | ||
|
||
describe('Info: externalDocs', () => { | ||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} null`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"externalDocs": null | ||
}, | ||
[ | ||
'must be object', | ||
'must be object', | ||
'must match exactly one schema in oneOf' | ||
] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} empty`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"externalDocs": {} | ||
}, | ||
[ | ||
'must have required property \'$ref\'', | ||
'must have required property \'url\'', | ||
'must match exactly one schema in oneOf' | ||
] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} string`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"externalDocs": "short description" | ||
}, | ||
[ | ||
'must be object', | ||
'must be object', | ||
'must match exactly one schema in oneOf' | ||
] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsValidWhenIsTestName} object`, () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"externalDocs": { | ||
"description" : "Find more info here", | ||
"url" : "https://example.com" | ||
} | ||
}, | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} array`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"externalDocs": [ | ||
null, [], "", {}, false, 123 | ||
] | ||
}, | ||
[ | ||
'must be object', | ||
'must be object', | ||
'must match exactly one schema in oneOf' | ||
] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} number`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"externalDocs": 123 | ||
}, | ||
[ | ||
'must be object', | ||
'must be object', | ||
'must match exactly one schema in oneOf' | ||
] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} boolean`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"externalDocs": false | ||
}, | ||
[ | ||
'must be object', | ||
'must be object', | ||
'must match exactly one schema in oneOf' | ||
] | ||
)); | ||
}); |
81 changes: 81 additions & 0 deletions
81
test/definitions/3.0.0/models/info/info/properties/license.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import {describe, it} from 'vitest'; | ||
import TestHelper from '@test/test-helper'; | ||
import path from 'path'; | ||
|
||
const jsonSchema = require('@definitions/3.0.0/info.json'); | ||
|
||
describe('Info: license', () => { | ||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} null`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"license": null | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} empty`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"license": {} | ||
}, | ||
['must have required property \'name\''] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} string`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"license": "short description" | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsValidWhenIsTestName} object`, () => TestHelper.objectIsValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"license": { | ||
"name": "Apache License 2.0", | ||
"url": "http://www.apache.org/licenses/" | ||
} | ||
}, | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} array`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"license": [ | ||
null, [], "", {}, false, 123 | ||
] | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} number`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"license": 123 | ||
}, | ||
['must be object'] | ||
)); | ||
|
||
it(`${TestHelper.propertyIsNotValidWhenIsTestName} boolean`, () => TestHelper.objectIsNotValid( | ||
jsonSchema, | ||
{ | ||
"title": "AsyncApi sample", | ||
"version": "2.0", | ||
"license": false | ||
}, | ||
['must be object'] | ||
)); | ||
}); |
Oops, something went wrong.