Skip to content

Commit

Permalink
test(definitions): use .each for mqtt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Jun 14, 2024
1 parent 0c42257 commit 6a26266
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 244 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/mqtt/index.mjs');
await import('@test/bindings/nats/index.mjs');
await import('@test/bindings/pulsar/index.mjs');
await import('@test/bindings/sns/index.mjs');
Expand Down
1 change: 0 additions & 1 deletion test/bindings/mqtt/0.1.0/message/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/mqtt/0.1.0/message/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/mqtt/0.1.0/operation/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/mqtt/0.1.0/operation/index.mjs

This file was deleted.

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

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/mqtt/0.2.0/message/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/mqtt/0.2.0/message/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/mqtt/0.2.0/operation/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/mqtt/0.2.0/operation/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/mqtt/0.2.0/server/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/mqtt/0.2.0/server/index.mjs

This file was deleted.

15 changes: 0 additions & 15 deletions test/bindings/mqtt/index.mjs

This file was deleted.

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

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

const messageSchema = await import(`@bindings/mqtt/${bindingVersion}/message.json`);
const operationSchema = await import(`@bindings/mqtt/${bindingVersion}/operation.json`);
const serverSchema = await import(`@bindings/mqtt/${bindingVersion}/server.json`);

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

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

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

it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => 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('operation', () => {
it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid(
operationSchema,
path.resolve(__dirname, `./${bindingVersion}/operation/example.json`),
));

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

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

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

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

it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
operationSchema,
path.resolve(__dirname, `./${bindingVersion}/operation/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`),
));
})
})
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineConfig({
'**/test/bindings/http/http.test.mjs',
'**/test/bindings/jms/jms.test.mjs',
'**/test/bindings/kafka/kafka.test.mjs',
'**/test/bindings/mqtt/mqtt.test.mjs',
'**/test/definitions/3.0.0/definitions.suite.mjs',
],
reporters: ['verbose'] // https://vitest.dev/guide/reporters#custom-reporters
Expand Down

0 comments on commit 6a26266

Please sign in to comment.