Skip to content

Commit

Permalink
Merge branch 'test/extend-test-cases' into test/definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Sep 2, 2024
2 parents 7b41223 + 392c1a5 commit d281233
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sonar.exclusions=tools/**/*
sonar.exclusions=tools/**/*,test/**/*
2 changes: 1 addition & 1 deletion test/bindings/solace/solace operation binding.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {describe} from 'vitest';
const config = new JsonSchemaTestSuiteConfig(
false,
[],
true,
false, // TODO: enable after schema patch
[]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const config = new JsonSchemaTestSuiteConfig(
'must have required property \'headers\'',
'must match a schema in anyOf'
],
true,
false, // TODO: enable after schema patch
[]
);

Expand Down
141 changes: 85 additions & 56 deletions test/definitions/3.0.0/models/operation/operation reply.test.mjs
Original file line number Diff line number Diff line change
@@ -1,62 +1,91 @@
import {
JsonSchemaTestSuite,
JsonSchemaTestSuiteConfig,
JsonSchemaTestSuiteData
} from '@test/definitions/base-schema-test.mjs';
import {describe} from 'vitest';
// TODO: enable after reference patch
/*
Validation error:
const jsonSchema = require('@definitions/3.0.0/operationReply.json');

const config = new JsonSchemaTestSuiteConfig(
false,
[],
true,
[]
);

const data = new JsonSchemaTestSuiteData(
jsonSchema,
[
{
"address": {
"description": "Consumer inbox",
"location": "$message.header#/replyTo"
},
"channel": {
"$ref": "#/components/channels/channel"
},
"messages": [
{
"$ref": "#/components/messages/message 1"
},
{
"$ref": "#/components/messages/message 2"
},
{
"$ref": "#/components/messages/message 3"
}
]
}
],
{},
{},
[
{
instancePath: '/messages/0/$ref',
schemaPath: 'http://asyncapi.com/definitions/3.0.0/ReferenceObject.json/format',
keyword: 'format',
params: { format: 'uri-reference' },
message: 'must match format "uri-reference"'
},
{
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
}
instancePath: '/messages/1/$ref',
schemaPath: 'http://asyncapi.com/definitions/3.0.0/ReferenceObject.json/format',
keyword: 'format',
params: { format: 'uri-reference' },
message: 'must match format "uri-reference"'
},
{
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
},
"ext-number": 1
instancePath: '/messages/2/$ref',
schemaPath: 'http://asyncapi.com/definitions/3.0.0/ReferenceObject.json/format',
keyword: 'format',
params: { format: 'uri-reference' },
message: 'must match format "uri-reference"'
}
);
]
*/

describe('Operation Reply', () => {
new JsonSchemaTestSuite(data, config).testSuite()
});
// import {
// JsonSchemaTestSuite,
// JsonSchemaTestSuiteConfig,
// JsonSchemaTestSuiteData
// } from '@test/definitions/base-schema-test.mjs';
// import {describe} from 'vitest';
//
// const jsonSchema = require('@definitions/3.0.0/operationReply.json');
//
// const config = new JsonSchemaTestSuiteConfig(
// false,
// [],
// true,
// []
// );
//
// const data = new JsonSchemaTestSuiteData(
// jsonSchema,
// [
// {
// "address": {
// "description": "Consumer inbox",
// "location": "$message.header#/replyTo"
// },
// "channel": {
// "$ref": "#/components/channels/channel"
// },
// "messages": [
// {
// "$ref": "#/components/messages/message 1"
// },
// {
// "$ref": "#/components/messages/message 2"
// },
// {
// "$ref": "#/components/messages/message 3"
// }
// ]
// }
// ],
// {},
// {},
// {
// "x-number": 0,
// "x-string": "",
// "x-object": {
// "property": {}
// }
// },
// {
// "x-number": 0,
// "x-string": "",
// "x-object": {
// "property": {}
// },
// "ext-number": 1
// }
// );
//
// describe('Operation Reply', () => {
// new JsonSchemaTestSuite(data, config).testSuite()
// });
2 changes: 1 addition & 1 deletion test/definitions/3.0.0/models/reference/reference.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const jsonSchema = require('@definitions/3.0.0/Reference.json');
const config = new JsonSchemaTestSuiteConfig(
true,
['must have required property \'$ref\''],
true,
false,
[]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config = new JsonSchemaTestSuiteConfig(
'must have required property \'type\'',
'must have required property \'flows\''
],
true,
false, // TODO: enable after schema patch
[]
);

Expand Down
19 changes: 11 additions & 8 deletions test/definitions/base-schema-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ export class JsonSchemaTestSuite {
this.data.onlyRequiredProperties,
));

it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid(
this.data.jsonSchema,
this.data.extended,
));
// TODO: Remove after schemas patch
if (this.config.canBeExtended) {
it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid(
this.data.jsonSchema,
this.data.extended,
));

it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
this.data.jsonSchema,
this.data.wronglyExtended,
));
it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
this.data.jsonSchema,
this.data.wronglyExtended,
));
}

}

Expand Down

0 comments on commit d281233

Please sign in to comment.