Skip to content

Commit

Permalink
test(definitions): use .each for http tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Jun 14, 2024
1 parent 4dfb78c commit cf29628
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 249 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/http/index.mjs');
await import('@test/bindings/ibmmq/index.mjs');
await import('@test/bindings/jms/index.mjs');
await import('@test/bindings/kafka/index.mjs');
Expand Down
1 change: 0 additions & 1 deletion test/bindings/http/0.1.0/message/empty.json

This file was deleted.

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

This file was deleted.

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

This file was deleted.

39 changes: 0 additions & 39 deletions test/bindings/http/0.1.0/operation/index.mjs

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/http/0.3.0/message/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/http/0.3.0/message/index.mjs

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

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

const messageSchema = await import(`@bindings/http/${bindingVersion}/message.json`);
const operationSchema = await import(`@bindings/http/${bindingVersion}/operation.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(`${bindingVersion === '0.1.0' ? TestHelper.cannotBeEmptyTestName : TestHelper.canBeEmptyTestName}`, () => {
if (bindingVersion === '0.1.0') {
TestHelper.objectIsNotValid(
operationSchema,
{},
['must have required property \'type\'']
)
} else {
TestHelper.objectIsValid(
operationSchema,
{},
)
}
})

it(`${bindingVersion === '0.1.0' ? TestHelper.isNotValidWithoutRequiredPropertiesTestName : TestHelper.isValidWithoutRequiredPropertiesTestName}`, () => {
if (bindingVersion === '0.1.0') {
TestHelper.objectIsNotValid(
operationSchema,
path.resolve(__dirname, `./${bindingVersion}/operation/without required properties.json`),
['must have required property \'type\'']
)
} else {
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`),
));
})
})
18 changes: 0 additions & 18 deletions test/bindings/http/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/http/http.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 cf29628

Please sign in to comment.