Skip to content

Commit

Permalink
test(definitions): use .each for solace tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Jun 14, 2024
1 parent 81c31f2 commit 079f853
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 247 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/solace/index.mjs');
await import('@test/bindings/sqs/index.mjs');
await import('@test/bindings/websockets/index.mjs');
})
1 change: 0 additions & 1 deletion test/bindings/solace/0.2.0/operation/empty.json

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/solace/0.3.0/operation/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/solace/0.3.0/operation/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/solace/0.3.0/server/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/solace/0.3.0/server/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/solace/0.4.0/operation/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/solace/0.4.0/operation/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/solace/0.4.0/server/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/solace/0.4.0/server/index.mjs

This file was deleted.

18 changes: 0 additions & 18 deletions test/bindings/solace/index.mjs

This file was deleted.

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

describe.each([
'0.2.0',
'0.3.0',
'0.4.0',
])('Solace bindings v%s', async (bindingVersion) => {

const operationSchema = await import(`@bindings/solace/${bindingVersion}/operation.json`);
const serverSchema = await import(`@bindings/solace/${bindingVersion}/server.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.todo('Can be extended or not?', () => TestHelper.objectIsValid(
operationSchema,
path.resolve(__dirname, `./${bindingVersion}/operation/extended.json`),
));

it.todo('Can be extended or not?', () => 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 @@ -22,6 +22,7 @@ export default defineConfig({
'**/test/bindings/nats/nats.test.mjs',
'**/test/bindings/pulsar/pulsar.test.mjs',
'**/test/bindings/sns/sns.test.mjs',
'**/test/bindings/solace/solace.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 079f853

Please sign in to comment.