Skip to content

Commit

Permalink
test(definitions): use .each for ibmmq tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Jun 14, 2024
1 parent cf29628 commit b1d0f90
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 132 deletions.
1 change: 0 additions & 1 deletion test/bindings/bindings.suite.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {describe} from 'vitest';

describe('Bindings Test Suite', async () => {
await import('@test/bindings/ibmmq/index.mjs');
await import('@test/bindings/jms/index.mjs');
await import('@test/bindings/kafka/index.mjs');
await import('@test/bindings/mqtt/index.mjs');
Expand Down
1 change: 0 additions & 1 deletion test/bindings/ibmmq/0.1.0/channel/empty.json

This file was deleted.

42 changes: 0 additions & 42 deletions test/bindings/ibmmq/0.1.0/channel/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/ibmmq/0.1.0/message/empty.json

This file was deleted.

40 changes: 0 additions & 40 deletions test/bindings/ibmmq/0.1.0/message/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/ibmmq/0.1.0/server/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/ibmmq/0.1.0/server/index.mjs

This file was deleted.

115 changes: 115 additions & 0 deletions test/bindings/ibmmq/ibmmq.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import {it} from 'vitest';
import TestHelper from '@test/test-helper.mjs';
import path from 'path';

describe.each([
'0.1.0',
])('IBM MQ bindings v%s', async (bindingVersion) => {

const channelSchema = await import(`@bindings/ibmmq/${bindingVersion}/channel.json`);
const messageSchema = await import(`@bindings/ibmmq/${bindingVersion}/message.json`);
const serverSchema = await import(`@bindings/ibmmq/${bindingVersion}/server.json`);

describe('channel', () => {
it('queue destination', () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/examples/queue destination.json`),
));

it('topic destination', () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/examples/topic destination.json`),
));

it(TestHelper.canBeEmptyTestName, () => TestHelper.objectIsValid(
channelSchema,
{},
));

it(TestHelper.isValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/without required properties.json`),
));

it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/only required properties.json`),
));

it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/extended.json`),
));

it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/wrongly extended.json`),
));
})

describe('message', () => {
it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/example.json`),
));

it(TestHelper.cannotBeEmptyTestName, () => TestHelper.objectIsNotValid(
messageSchema,
{},
['must match exactly one schema in oneOf']
));

it(TestHelper.isNotValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsNotValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/without required properties.json`),
['must match exactly one schema in oneOf']
));

it.todo('\'type\' must be required?', () => TestHelper.objectIsValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/only required properties.json`),
));

it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/extended.json`),
));

it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/wrongly extended.json`),
));
})

describe('server', () => {
it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid(
serverSchema,
path.resolve(__dirname, `./${bindingVersion}/server/example.json`),
));

it(TestHelper.canBeEmptyTestName, () => TestHelper.objectIsValid(
serverSchema,
{}
));

it(TestHelper.isValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsValid(
serverSchema,
path.resolve(__dirname, `./${bindingVersion}/server/without required properties.json`),
));

it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => TestHelper.objectIsValid(
serverSchema,
path.resolve(__dirname, `./${bindingVersion}/server/only required properties.json`),
));

it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid(
serverSchema,
path.resolve(__dirname, `./${bindingVersion}/server/extended.json`),
));

it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
serverSchema,
path.resolve(__dirname, `./${bindingVersion}/server/wrongly extended.json`),
));
})
})
9 changes: 0 additions & 9 deletions test/bindings/ibmmq/index.mjs

This file was deleted.

1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default defineConfig({
'**/test/bindings/amqp/amqp.test.mjs',
'**/test/bindings/anypointmq/anypointmq.test.mjs',
'**/test/bindings/googlepubsub/googlepubsub.test.mjs',
'**/test/bindings/ibmmq/ibmmq.test.mjs',
'**/test/bindings/http/http.test.mjs',
'**/test/definitions/3.0.0/definitions.suite.mjs',
],
Expand Down

0 comments on commit b1d0f90

Please sign in to comment.