Skip to content

Commit

Permalink
test(definitions): operation new tests structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Jul 24, 2024
1 parent 2eff358 commit 39b1754
Show file tree
Hide file tree
Showing 34 changed files with 281 additions and 2,822 deletions.
1 change: 0 additions & 1 deletion test/definitions/3.0.0/models/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import {describe} from 'vitest';

describe('Models Test Suite', async () => {
await import('./channel');
await import('./operation');
});
8 changes: 0 additions & 8 deletions test/definitions/3.0.0/models/operation/index.mjs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
JsonSchemaTestSuite,
JsonSchemaTestSuiteConfig,
JsonSchemaTestSuiteData
} from '@test/definitions/base-schema-test.mjs';
import {describe} from 'vitest';

const jsonSchema = require('@definitions/3.0.0/operationReplyAddress.json');

const config = new JsonSchemaTestSuiteConfig(
true,
['must have required property \'location\''],
true,
[]
);

const data = new JsonSchemaTestSuiteData(
jsonSchema,
[
{
"description" : "Consumer inbox",
"location" : "$message.header#/replyTo"
}
],
{
"location" : "$message.header#/replyTo"
},
{
"description" : "Consumer inbox"
},
{
"location" : "$message.header#/replyTo",
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
}
},
{
"location" : "$message.header#/replyTo",
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
},
"ext-number": 1
}
);

describe('Operation Reply Address', () => {
new JsonSchemaTestSuite(data, config).testSuite()
});
62 changes: 62 additions & 0 deletions test/definitions/3.0.0/models/operation/operation reply.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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()
});
83 changes: 83 additions & 0 deletions test/definitions/3.0.0/models/operation/operation trait.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import {
JsonSchemaTestSuite,
JsonSchemaTestSuiteConfig,
JsonSchemaTestSuiteData
} from '@test/definitions/base-schema-test.mjs';
import {describe} from 'vitest';

const jsonSchema = require('@definitions/3.0.0/operationTrait.json');

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

const data = new JsonSchemaTestSuiteData(
jsonSchema,
[
{
"title": "Send message operation",
"summary": "Send message",
"description": "Send message to remote server",
"security": [
{
"type": "apiKey",
"description": "apiKey",
"in": "user"
},
{
"$ref": "#/components/security/plain"
}
],
"tags": [
{
"$ref": "#/components/tags/tag"
}
],
"externalDocs": {
"$ref": "#/components/externalDocs"
},
"bindings": {
"amqp":{
"expiration": 100000,
"userId": "guest",
"cc": [
"user.logs"
],
"priority": 10,
"deliveryMode": 2,
"mandatory": false,
"bcc": [
"external.audit"
],
"timestamp": true,
"ack": false,
"bindingVersion": "0.3.0"
}
}
}
],
{},
{},
{
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
}
},
{
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
},
"ext-number": 1
}
);

describe('Operation Trait', () => {
new JsonSchemaTestSuite(data, config).testSuite()
});
84 changes: 84 additions & 0 deletions test/definitions/3.0.0/models/operation/operation.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {
JsonSchemaTestSuite,
JsonSchemaTestSuiteConfig,
JsonSchemaTestSuiteData
} from '@test/definitions/base-schema-test.mjs';
import {describe} from 'vitest';

const jsonSchema = require('@definitions/3.0.0/operation.json');

const config = new JsonSchemaTestSuiteConfig(
true,
[
'must have required property \'action\'',
'must have required property \'channel\''
],
true,
[]
);

const data = new JsonSchemaTestSuiteData(
jsonSchema,
[
{
"title": "User sign up",
"summary": "Action to sign a user up.",
"description": "A longer description",
"channel": {
"$ref": "#/channels/userSignup"
},
"action": "send",
"tags": [{ "name": "user" }, { "name": "signup" }, { "name": "register" }],
"bindings": {
"amqp": {
"ack": false
}
},
"traits": [{ "$ref": "#/components/operationTraits/kafka" }]
}
],
{
"channel": {
"$ref": "#/channels/userSignup"
},
"action": "send"
},
{
"title": "User sign up",
"summary": "Action to sign a user up.",
"description": "A longer description",
"bindings": {
"amqp": {
"ack": false
}
},
"traits": [{ "$ref": "#/components/operationTraits/kafka" }]
},
{
"channel": {
"$ref": "#/channels/userSignup"
},
"action": "send",
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
}
},
{
"channel": {
"$ref": "#/channels/userSignup"
},
"action": "send",
"x-number": 0,
"x-string": "",
"x-object": {
"property": {}
},
"ext-number": 1
}
);

describe('Operation', () => {
new JsonSchemaTestSuite(data, config).testSuite()
});

This file was deleted.

Loading

0 comments on commit 39b1754

Please sign in to comment.