Skip to content

Commit

Permalink
test(definitions): use .each for pulsar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Jun 14, 2024
1 parent 2f16869 commit 234d615
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 93 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/pulsar/index.mjs');
await import('@test/bindings/sns/index.mjs');
await import('@test/bindings/solace/index.mjs');
await import('@test/bindings/sqs/index.mjs');
Expand Down
1 change: 0 additions & 1 deletion test/bindings/pulsar/0.1.0/channel/empty.json

This file was deleted.

45 changes: 0 additions & 45 deletions test/bindings/pulsar/0.1.0/channel/index.mjs

This file was deleted.

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

This file was deleted.

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

This file was deleted.

8 changes: 0 additions & 8 deletions test/bindings/pulsar/index.mjs

This file was deleted.

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

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

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

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

it(TestHelper.cannotBeEmptyTestName, () => TestHelper.objectIsNotValid(
channelSchema,
{},
[
'must have required property \'namespace\'',
'must have required property \'persistence\''
]
));

it(TestHelper.isNotValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsNotValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/without required properties.json`),
[
'must have required property \'namespace\'',
'must have required property \'persistence\''
]
));

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('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 @@ -20,6 +20,7 @@ export default defineConfig({
'**/test/bindings/kafka/kafka.test.mjs',
'**/test/bindings/mqtt/mqtt.test.mjs',
'**/test/bindings/nats/nats.test.mjs',
'**/test/bindings/pulsar/pulsar.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 234d615

Please sign in to comment.