From 8ec723d2e6bf66f26bec94af9b55c515f697abac Mon Sep 17 00:00:00 2001 From: Pavel Bodiachevskii Date: Mon, 3 Jun 2024 02:55:49 +0400 Subject: [PATCH] test(definitions): fix linter issues https://github.com/asyncapi/spec-json-schemas/issues/539 --- .../amqp/0.2.0/channel/channel.test.js | 64 ------------------- test/bindings/amqp/0.2.0/channel/index.mjs | 44 +++++++++++++ test/bindings/amqp/0.2.0/message/index.mjs | 37 +++++++++++ .../amqp/0.2.0/message/message.test.js | 53 --------------- test/bindings/amqp/0.2.0/operation/index.mjs | 37 +++++++++++ .../amqp/0.2.0/operation/operation.test.js | 53 --------------- test/bindings/amqp/0.2.0/server/example.json | 3 - .../amqp/0.2.0/server/server.test.mjs | 54 ---------------- .../server/without required properties.json | 3 - .../amqp/0.3.0/channel/channel.test.js | 64 ------------------- test/bindings/amqp/0.3.0/channel/index.mjs | 44 +++++++++++++ test/bindings/amqp/0.3.0/message/index.mjs | 37 +++++++++++ .../amqp/0.3.0/message/message.test.js | 53 --------------- test/bindings/amqp/0.3.0/operation/index.mjs | 37 +++++++++++ .../amqp/0.3.0/operation/operation.test.js | 53 --------------- test/bindings/amqp/0.3.0/server/example.json | 3 - .../bindings/amqp/0.3.0/server/server.test.js | 53 --------------- .../server/without required properties.json | 3 - test/bindings/amqp/index.mjs | 14 ++-- .../anypointmq/0.0.1/channel/channel.test.js | 57 ----------------- .../anypointmq/0.0.1/channel/index.mjs | 37 +++++++++++ .../anypointmq/0.0.1/message/index.mjs | 37 +++++++++++ .../anypointmq/0.0.1/message/message.test.js | 53 --------------- test/bindings/anypointmq/index.mjs | 4 +- .../0.1.0/channel/channel.test.js | 59 ----------------- .../googlepubsub/0.1.0/channel/index.mjs | 45 +++++++++++++ .../googlepubsub/0.1.0/message/index.mjs | 37 +++++++++++ .../0.1.0/message/message.test.js | 53 --------------- .../0.2.0/channel/channel.test.js | 57 ----------------- .../googlepubsub/0.2.0/channel/index.mjs | 43 +++++++++++++ .../googlepubsub/0.2.0/message/index.mjs | 37 +++++++++++ .../0.2.0/message/message.test.js | 53 --------------- test/bindings/googlepubsub/index.mjs | 8 +-- test/bindings/http/0.1.0/message/index.mjs | 37 +++++++++++ .../http/0.1.0/message/message.test.js | 53 --------------- test/bindings/http/0.1.0/operation/index.mjs | 39 +++++++++++ .../http/0.1.0/operation/operation.test.js | 57 ----------------- test/bindings/http/0.2.0/message/index.mjs | 37 +++++++++++ .../http/0.2.0/message/message.test.js | 53 --------------- test/bindings/http/0.2.0/operation/index.mjs | 37 +++++++++++ .../http/0.2.0/operation/operation.test.js | 53 --------------- test/bindings/http/0.3.0/message/index.mjs | 37 +++++++++++ .../http/0.3.0/message/message.test.js | 53 --------------- test/bindings/http/0.3.0/operation/index.mjs | 37 +++++++++++ .../http/0.3.0/operation/operation.test.js | 53 --------------- test/bindings/http/index.mjs | 12 ++-- .../ibmmq/0.1.0/channel/channel.test.js | 60 ----------------- test/bindings/ibmmq/0.1.0/channel/index.mjs | 42 ++++++++++++ test/bindings/ibmmq/0.1.0/message/index.mjs | 40 ++++++++++++ .../ibmmq/0.1.0/message/message.test.js | 59 ----------------- test/bindings/ibmmq/0.1.0/server/index.mjs | 37 +++++++++++ .../ibmmq/0.1.0/server/server.test.js | 53 --------------- test/bindings/ibmmq/index.mjs | 6 +- .../server => jms/0.0.1/channel}/empty.json | 0 .../jms/{0.1.0 => 0.0.1}/channel/example.json | 0 .../0.0.1/channel}/extended.json | 0 test/bindings/jms/0.0.1/channel/index.mjs | 37 +++++++++++ .../channel}/only required properties.json | 0 .../channel/without required properties.json | 0 .../0.0.1/channel}/wrongly extended.json | 0 .../server => jms/0.0.1/message}/empty.json | 0 .../jms/{0.1.0 => 0.0.1}/message/example.json | 0 .../0.0.1/message}/extended.json | 0 test/bindings/jms/0.0.1/message/index.mjs | 37 +++++++++++ .../message}/only required properties.json | 0 .../message/without required properties.json | 0 .../0.0.1/message}/wrongly extended.json | 0 .../channel => 0.0.1/server}/empty.json | 0 .../jms/{0.1.0 => 0.0.1}/server/example.json | 0 .../jms/{0.1.0 => 0.0.1}/server/extended.json | 0 test/bindings/jms/0.0.1/server/index.mjs | 39 +++++++++++ .../server/only required properties.json | 0 .../server/without required properties.json | 0 .../server/wrongly extended.json | 0 .../jms/0.1.0/channel/channel.test.js | 53 --------------- test/bindings/jms/0.1.0/channel/extended.json | 7 -- .../channel/only required properties.json | 1 - .../jms/0.1.0/channel/wrongly extended.json | 8 --- test/bindings/jms/0.1.0/message/empty.json | 1 - test/bindings/jms/0.1.0/message/extended.json | 7 -- .../jms/0.1.0/message/message.test.js | 53 --------------- .../message/only required properties.json | 1 - .../jms/0.1.0/message/wrongly extended.json | 8 --- test/bindings/jms/0.1.0/server/empty.json | 1 - test/bindings/jms/0.1.0/server/server.test.js | 57 ----------------- test/bindings/jms/index.mjs | 8 +-- test/bindings/kafka/0.1.0/message/index.mjs | 37 +++++++++++ .../kafka/0.1.0/message/message.test.js | 53 --------------- test/bindings/kafka/0.1.0/operation/index.mjs | 37 +++++++++++ .../kafka/0.1.0/operation/operation.test.js | 53 --------------- .../kafka/0.3.0/channel/channel.test.js | 53 --------------- test/bindings/kafka/0.3.0/channel/index.mjs | 37 +++++++++++ test/bindings/kafka/0.3.0/message/index.mjs | 37 +++++++++++ .../kafka/0.3.0/message/message.test.js | 53 --------------- test/bindings/kafka/0.3.0/operation/index.mjs | 37 +++++++++++ .../kafka/0.3.0/operation/operation.test.js | 53 --------------- test/bindings/kafka/0.3.0/server/index.mjs | 37 +++++++++++ .../kafka/0.3.0/server/server.test.js | 53 --------------- .../kafka/0.4.0/channel/channel.test.js | 53 --------------- test/bindings/kafka/0.4.0/channel/index.mjs | 37 +++++++++++ test/bindings/kafka/0.4.0/message/index.mjs | 37 +++++++++++ .../kafka/0.4.0/message/message.test.js | 53 --------------- test/bindings/kafka/0.4.0/operation/index.mjs | 37 +++++++++++ .../kafka/0.4.0/operation/operation.test.js | 53 --------------- test/bindings/kafka/0.4.0/server/index.mjs | 37 +++++++++++ .../kafka/0.4.0/server/server.test.js | 53 --------------- .../kafka/0.5.0/channel/channel.test.js | 53 --------------- test/bindings/kafka/0.5.0/channel/index.mjs | 37 +++++++++++ test/bindings/kafka/0.5.0/message/index.mjs | 37 +++++++++++ .../kafka/0.5.0/message/message.test.js | 53 --------------- test/bindings/kafka/0.5.0/operation/index.mjs | 37 +++++++++++ .../kafka/0.5.0/operation/operation.test.js | 53 --------------- test/bindings/kafka/0.5.0/server/index.mjs | 37 +++++++++++ .../kafka/0.5.0/server/server.test.js | 53 --------------- test/bindings/kafka/index.mjs | 28 ++++---- test/bindings/mqtt/0.1.0/message/index.mjs | 37 +++++++++++ .../mqtt/0.1.0/message/message.test.js | 53 --------------- test/bindings/mqtt/0.1.0/operation/index.mjs | 37 +++++++++++ .../mqtt/0.1.0/operation/operation.test.js | 53 --------------- test/bindings/mqtt/0.1.0/server/index.mjs | 37 +++++++++++ .../bindings/mqtt/0.1.0/server/server.test.js | 53 --------------- test/bindings/mqtt/0.2.0/message/index.mjs | 37 +++++++++++ .../mqtt/0.2.0/message/message.test.js | 53 --------------- test/bindings/mqtt/0.2.0/operation/index.mjs | 37 +++++++++++ .../mqtt/0.2.0/operation/operation.test.js | 53 --------------- test/bindings/mqtt/0.2.0/server/index.mjs | 37 +++++++++++ .../bindings/mqtt/0.2.0/server/server.test.js | 53 --------------- test/bindings/mqtt/index.mjs | 12 ++-- test/bindings/nats/0.1.0/operation/index.mjs | 37 +++++++++++ .../nats/0.1.0/operation/operation.test.js | 53 --------------- test/bindings/nats/index.mjs | 2 +- .../pulsar/0.1.0/channel/channel.test.js | 59 ----------------- test/bindings/pulsar/0.1.0/channel/index.mjs | 45 +++++++++++++ test/bindings/pulsar/0.1.0/server/index.mjs | 37 +++++++++++ .../pulsar/0.1.0/server/server.test.js | 53 --------------- test/bindings/pulsar/index.mjs | 4 +- .../sns/0.1.0/channel/channel.test.js | 57 ----------------- test/bindings/sns/0.1.0/channel/index.mjs | 39 +++++++++++ test/bindings/sns/0.1.0/operation/index.mjs | 39 +++++++++++ .../sns/0.1.0/operation/operation.test.js | 57 ----------------- test/bindings/sns/index.mjs | 4 +- .../bindings/solace/0.2.0/operation/index.mjs | 37 +++++++++++ .../solace/0.2.0/operation/operation.test.js | 53 --------------- test/bindings/solace/0.2.0/server/index.mjs | 37 +++++++++++ .../solace/0.2.0/server/server.test.js | 53 --------------- .../bindings/solace/0.3.0/operation/index.mjs | 37 +++++++++++ .../solace/0.3.0/operation/operation.test.js | 53 --------------- test/bindings/solace/0.3.0/server/index.mjs | 37 +++++++++++ .../solace/0.3.0/server/server.test.js | 53 --------------- .../bindings/solace/0.4.0/operation/index.mjs | 37 +++++++++++ .../solace/0.4.0/operation/operation.test.js | 53 --------------- test/bindings/solace/0.4.0/server/index.mjs | 37 +++++++++++ .../solace/0.4.0/server/server.test.js | 53 --------------- test/bindings/solace/index.mjs | 12 ++-- .../sqs/0.2.0/channel/channel.test.js | 57 ----------------- test/bindings/sqs/0.2.0/channel/index.mjs | 39 +++++++++++ test/bindings/sqs/0.2.0/operation/index.mjs | 39 +++++++++++ .../sqs/0.2.0/operation/operation.test.js | 57 ----------------- test/bindings/sqs/index.mjs | 4 +- .../websockets/0.1.0/channel/channel.test.mjs | 53 --------------- .../websockets/0.1.0/channel/index.mjs | 37 +++++++++++ test/bindings/websockets/index.mjs | 2 +- 162 files changed, 2261 insertions(+), 3367 deletions(-) delete mode 100644 test/bindings/amqp/0.2.0/channel/channel.test.js create mode 100644 test/bindings/amqp/0.2.0/channel/index.mjs create mode 100644 test/bindings/amqp/0.2.0/message/index.mjs delete mode 100644 test/bindings/amqp/0.2.0/message/message.test.js create mode 100644 test/bindings/amqp/0.2.0/operation/index.mjs delete mode 100644 test/bindings/amqp/0.2.0/operation/operation.test.js delete mode 100644 test/bindings/amqp/0.2.0/server/example.json delete mode 100644 test/bindings/amqp/0.2.0/server/server.test.mjs delete mode 100644 test/bindings/amqp/0.2.0/server/without required properties.json delete mode 100644 test/bindings/amqp/0.3.0/channel/channel.test.js create mode 100644 test/bindings/amqp/0.3.0/channel/index.mjs create mode 100644 test/bindings/amqp/0.3.0/message/index.mjs delete mode 100644 test/bindings/amqp/0.3.0/message/message.test.js create mode 100644 test/bindings/amqp/0.3.0/operation/index.mjs delete mode 100644 test/bindings/amqp/0.3.0/operation/operation.test.js delete mode 100644 test/bindings/amqp/0.3.0/server/example.json delete mode 100644 test/bindings/amqp/0.3.0/server/server.test.js delete mode 100644 test/bindings/amqp/0.3.0/server/without required properties.json delete mode 100644 test/bindings/anypointmq/0.0.1/channel/channel.test.js create mode 100644 test/bindings/anypointmq/0.0.1/channel/index.mjs create mode 100644 test/bindings/anypointmq/0.0.1/message/index.mjs delete mode 100644 test/bindings/anypointmq/0.0.1/message/message.test.js delete mode 100644 test/bindings/googlepubsub/0.1.0/channel/channel.test.js create mode 100644 test/bindings/googlepubsub/0.1.0/channel/index.mjs create mode 100644 test/bindings/googlepubsub/0.1.0/message/index.mjs delete mode 100644 test/bindings/googlepubsub/0.1.0/message/message.test.js delete mode 100644 test/bindings/googlepubsub/0.2.0/channel/channel.test.js create mode 100644 test/bindings/googlepubsub/0.2.0/channel/index.mjs create mode 100644 test/bindings/googlepubsub/0.2.0/message/index.mjs delete mode 100644 test/bindings/googlepubsub/0.2.0/message/message.test.js create mode 100644 test/bindings/http/0.1.0/message/index.mjs delete mode 100644 test/bindings/http/0.1.0/message/message.test.js create mode 100644 test/bindings/http/0.1.0/operation/index.mjs delete mode 100644 test/bindings/http/0.1.0/operation/operation.test.js create mode 100644 test/bindings/http/0.2.0/message/index.mjs delete mode 100644 test/bindings/http/0.2.0/message/message.test.js create mode 100644 test/bindings/http/0.2.0/operation/index.mjs delete mode 100644 test/bindings/http/0.2.0/operation/operation.test.js create mode 100644 test/bindings/http/0.3.0/message/index.mjs delete mode 100644 test/bindings/http/0.3.0/message/message.test.js create mode 100644 test/bindings/http/0.3.0/operation/index.mjs delete mode 100644 test/bindings/http/0.3.0/operation/operation.test.js delete mode 100644 test/bindings/ibmmq/0.1.0/channel/channel.test.js create mode 100644 test/bindings/ibmmq/0.1.0/channel/index.mjs create mode 100644 test/bindings/ibmmq/0.1.0/message/index.mjs delete mode 100644 test/bindings/ibmmq/0.1.0/message/message.test.js create mode 100644 test/bindings/ibmmq/0.1.0/server/index.mjs delete mode 100644 test/bindings/ibmmq/0.1.0/server/server.test.js rename test/bindings/{amqp/0.2.0/server => jms/0.0.1/channel}/empty.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/channel/example.json (100%) rename test/bindings/{amqp/0.2.0/server => jms/0.0.1/channel}/extended.json (100%) create mode 100644 test/bindings/jms/0.0.1/channel/index.mjs rename test/bindings/{amqp/0.2.0/server => jms/0.0.1/channel}/only required properties.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/channel/without required properties.json (100%) rename test/bindings/{amqp/0.2.0/server => jms/0.0.1/channel}/wrongly extended.json (100%) rename test/bindings/{amqp/0.3.0/server => jms/0.0.1/message}/empty.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/message/example.json (100%) rename test/bindings/{amqp/0.3.0/server => jms/0.0.1/message}/extended.json (100%) create mode 100644 test/bindings/jms/0.0.1/message/index.mjs rename test/bindings/{amqp/0.3.0/server => jms/0.0.1/message}/only required properties.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/message/without required properties.json (100%) rename test/bindings/{amqp/0.3.0/server => jms/0.0.1/message}/wrongly extended.json (100%) rename test/bindings/jms/{0.1.0/channel => 0.0.1/server}/empty.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/server/example.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/server/extended.json (100%) create mode 100644 test/bindings/jms/0.0.1/server/index.mjs rename test/bindings/jms/{0.1.0 => 0.0.1}/server/only required properties.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/server/without required properties.json (100%) rename test/bindings/jms/{0.1.0 => 0.0.1}/server/wrongly extended.json (100%) delete mode 100644 test/bindings/jms/0.1.0/channel/channel.test.js delete mode 100644 test/bindings/jms/0.1.0/channel/extended.json delete mode 100644 test/bindings/jms/0.1.0/channel/only required properties.json delete mode 100644 test/bindings/jms/0.1.0/channel/wrongly extended.json delete mode 100644 test/bindings/jms/0.1.0/message/empty.json delete mode 100644 test/bindings/jms/0.1.0/message/extended.json delete mode 100644 test/bindings/jms/0.1.0/message/message.test.js delete mode 100644 test/bindings/jms/0.1.0/message/only required properties.json delete mode 100644 test/bindings/jms/0.1.0/message/wrongly extended.json delete mode 100644 test/bindings/jms/0.1.0/server/empty.json delete mode 100644 test/bindings/jms/0.1.0/server/server.test.js create mode 100644 test/bindings/kafka/0.1.0/message/index.mjs delete mode 100644 test/bindings/kafka/0.1.0/message/message.test.js create mode 100644 test/bindings/kafka/0.1.0/operation/index.mjs delete mode 100644 test/bindings/kafka/0.1.0/operation/operation.test.js delete mode 100644 test/bindings/kafka/0.3.0/channel/channel.test.js create mode 100644 test/bindings/kafka/0.3.0/channel/index.mjs create mode 100644 test/bindings/kafka/0.3.0/message/index.mjs delete mode 100644 test/bindings/kafka/0.3.0/message/message.test.js create mode 100644 test/bindings/kafka/0.3.0/operation/index.mjs delete mode 100644 test/bindings/kafka/0.3.0/operation/operation.test.js create mode 100644 test/bindings/kafka/0.3.0/server/index.mjs delete mode 100644 test/bindings/kafka/0.3.0/server/server.test.js delete mode 100644 test/bindings/kafka/0.4.0/channel/channel.test.js create mode 100644 test/bindings/kafka/0.4.0/channel/index.mjs create mode 100644 test/bindings/kafka/0.4.0/message/index.mjs delete mode 100644 test/bindings/kafka/0.4.0/message/message.test.js create mode 100644 test/bindings/kafka/0.4.0/operation/index.mjs delete mode 100644 test/bindings/kafka/0.4.0/operation/operation.test.js create mode 100644 test/bindings/kafka/0.4.0/server/index.mjs delete mode 100644 test/bindings/kafka/0.4.0/server/server.test.js delete mode 100644 test/bindings/kafka/0.5.0/channel/channel.test.js create mode 100644 test/bindings/kafka/0.5.0/channel/index.mjs create mode 100644 test/bindings/kafka/0.5.0/message/index.mjs delete mode 100644 test/bindings/kafka/0.5.0/message/message.test.js create mode 100644 test/bindings/kafka/0.5.0/operation/index.mjs delete mode 100644 test/bindings/kafka/0.5.0/operation/operation.test.js create mode 100644 test/bindings/kafka/0.5.0/server/index.mjs delete mode 100644 test/bindings/kafka/0.5.0/server/server.test.js create mode 100644 test/bindings/mqtt/0.1.0/message/index.mjs delete mode 100644 test/bindings/mqtt/0.1.0/message/message.test.js create mode 100644 test/bindings/mqtt/0.1.0/operation/index.mjs delete mode 100644 test/bindings/mqtt/0.1.0/operation/operation.test.js create mode 100644 test/bindings/mqtt/0.1.0/server/index.mjs delete mode 100644 test/bindings/mqtt/0.1.0/server/server.test.js create mode 100644 test/bindings/mqtt/0.2.0/message/index.mjs delete mode 100644 test/bindings/mqtt/0.2.0/message/message.test.js create mode 100644 test/bindings/mqtt/0.2.0/operation/index.mjs delete mode 100644 test/bindings/mqtt/0.2.0/operation/operation.test.js create mode 100644 test/bindings/mqtt/0.2.0/server/index.mjs delete mode 100644 test/bindings/mqtt/0.2.0/server/server.test.js create mode 100644 test/bindings/nats/0.1.0/operation/index.mjs delete mode 100644 test/bindings/nats/0.1.0/operation/operation.test.js delete mode 100644 test/bindings/pulsar/0.1.0/channel/channel.test.js create mode 100644 test/bindings/pulsar/0.1.0/channel/index.mjs create mode 100644 test/bindings/pulsar/0.1.0/server/index.mjs delete mode 100644 test/bindings/pulsar/0.1.0/server/server.test.js delete mode 100644 test/bindings/sns/0.1.0/channel/channel.test.js create mode 100644 test/bindings/sns/0.1.0/channel/index.mjs create mode 100644 test/bindings/sns/0.1.0/operation/index.mjs delete mode 100644 test/bindings/sns/0.1.0/operation/operation.test.js create mode 100644 test/bindings/solace/0.2.0/operation/index.mjs delete mode 100644 test/bindings/solace/0.2.0/operation/operation.test.js create mode 100644 test/bindings/solace/0.2.0/server/index.mjs delete mode 100644 test/bindings/solace/0.2.0/server/server.test.js create mode 100644 test/bindings/solace/0.3.0/operation/index.mjs delete mode 100644 test/bindings/solace/0.3.0/operation/operation.test.js create mode 100644 test/bindings/solace/0.3.0/server/index.mjs delete mode 100644 test/bindings/solace/0.3.0/server/server.test.js create mode 100644 test/bindings/solace/0.4.0/operation/index.mjs delete mode 100644 test/bindings/solace/0.4.0/operation/operation.test.js create mode 100644 test/bindings/solace/0.4.0/server/index.mjs delete mode 100644 test/bindings/solace/0.4.0/server/server.test.js delete mode 100644 test/bindings/sqs/0.2.0/channel/channel.test.js create mode 100644 test/bindings/sqs/0.2.0/channel/index.mjs create mode 100644 test/bindings/sqs/0.2.0/operation/index.mjs delete mode 100644 test/bindings/sqs/0.2.0/operation/operation.test.js delete mode 100644 test/bindings/websockets/0.1.0/channel/channel.test.mjs create mode 100644 test/bindings/websockets/0.1.0/channel/index.mjs diff --git a/test/bindings/amqp/0.2.0/channel/channel.test.js b/test/bindings/amqp/0.2.0/channel/channel.test.js deleted file mode 100644 index 81bc4baa..00000000 --- a/test/bindings/amqp/0.2.0/channel/channel.test.js +++ /dev/null @@ -1,64 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/amqp/0.2.0/channel.json')) - -describe(`${title}`, () => { - it('is: routingKey', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/examples/is routing key.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('is: queue', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/examples/is queue.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it.skip('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'is\''); - assert(validator.errors.length === 1); - }); - - it.skip('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'is\''); - assert(validator.errors.length === 1); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.2.0/channel/index.mjs b/test/bindings/amqp/0.2.0/channel/index.mjs new file mode 100644 index 00000000..d9a3fc1b --- /dev/null +++ b/test/bindings/amqp/0.2.0/channel/index.mjs @@ -0,0 +1,44 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/amqp/0.2.0/channel.json'); + +describe('Channel', () => { + it('is: routingKey', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './examples/is routing key.json'), + )); + + it('is: queue', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './examples/is queue.json'), + )); + + it.skip('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'is\''] + )); + + it.skip('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'is\''] + )); + + it.skip('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json') + )); +}); diff --git a/test/bindings/amqp/0.2.0/message/index.mjs b/test/bindings/amqp/0.2.0/message/index.mjs new file mode 100644 index 00000000..3b33d9ca --- /dev/null +++ b/test/bindings/amqp/0.2.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/amqp/0.2.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json') + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json') + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json') + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json') + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json') + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json') + )); +}); diff --git a/test/bindings/amqp/0.2.0/message/message.test.js b/test/bindings/amqp/0.2.0/message/message.test.js deleted file mode 100644 index f24e4c0c..00000000 --- a/test/bindings/amqp/0.2.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/amqp/0.2.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.2.0/operation/index.mjs b/test/bindings/amqp/0.2.0/operation/index.mjs new file mode 100644 index 00000000..20024800 --- /dev/null +++ b/test/bindings/amqp/0.2.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/amqp/0.2.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json') + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json') + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json') + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json') + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json') + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json') + )); +}); diff --git a/test/bindings/amqp/0.2.0/operation/operation.test.js b/test/bindings/amqp/0.2.0/operation/operation.test.js deleted file mode 100644 index 9306ecdb..00000000 --- a/test/bindings/amqp/0.2.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/amqp/0.2.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.2.0/server/example.json b/test/bindings/amqp/0.2.0/server/example.json deleted file mode 100644 index 281892d4..00000000 --- a/test/bindings/amqp/0.2.0/server/example.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "bindingVersion": "0.2.0" -} \ No newline at end of file diff --git a/test/bindings/amqp/0.2.0/server/server.test.mjs b/test/bindings/amqp/0.2.0/server/server.test.mjs deleted file mode 100644 index 6d606ded..00000000 --- a/test/bindings/amqp/0.2.0/server/server.test.mjs +++ /dev/null @@ -1,54 +0,0 @@ -import {describe, it} from 'vitest'; -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/amqp/0.2.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.2.0/server/without required properties.json b/test/bindings/amqp/0.2.0/server/without required properties.json deleted file mode 100644 index 281892d4..00000000 --- a/test/bindings/amqp/0.2.0/server/without required properties.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "bindingVersion": "0.2.0" -} \ No newline at end of file diff --git a/test/bindings/amqp/0.3.0/channel/channel.test.js b/test/bindings/amqp/0.3.0/channel/channel.test.js deleted file mode 100644 index bbf060a9..00000000 --- a/test/bindings/amqp/0.3.0/channel/channel.test.js +++ /dev/null @@ -1,64 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/amqp/0.3.0/channel.json')) - -describe(`${title}`, () => { - it('is: routingKey', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/examples/is routing key.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('is: queue', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/examples/is queue.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it.skip('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'is\''); - assert(validator.errors.length === 1); - }); - - it.skip('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'is\''); - assert(validator.errors.length === 1); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.3.0/channel/index.mjs b/test/bindings/amqp/0.3.0/channel/index.mjs new file mode 100644 index 00000000..79713f8a --- /dev/null +++ b/test/bindings/amqp/0.3.0/channel/index.mjs @@ -0,0 +1,44 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/amqp/0.3.0/channel.json'); + +describe('Channel', () => { + it('is: routingKey', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './examples/is routing key.json'), + )); + + it('is: queue', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './examples/is queue.json'), + )); + + it.skip('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'is\''] + )); + + it.skip('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'is\''] + )); + + it.skip('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json') + )); +}); diff --git a/test/bindings/amqp/0.3.0/message/index.mjs b/test/bindings/amqp/0.3.0/message/index.mjs new file mode 100644 index 00000000..7ce6a8ec --- /dev/null +++ b/test/bindings/amqp/0.3.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/amqp/0.3.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json') + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json') + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json') + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json') + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json') + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json') + )); +}); diff --git a/test/bindings/amqp/0.3.0/message/message.test.js b/test/bindings/amqp/0.3.0/message/message.test.js deleted file mode 100644 index 5b84a031..00000000 --- a/test/bindings/amqp/0.3.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/amqp/0.3.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.3.0/operation/index.mjs b/test/bindings/amqp/0.3.0/operation/index.mjs new file mode 100644 index 00000000..91ce821c --- /dev/null +++ b/test/bindings/amqp/0.3.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/amqp/0.3.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json') + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json') + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json') + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json') + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json') + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json') + )); +}); diff --git a/test/bindings/amqp/0.3.0/operation/operation.test.js b/test/bindings/amqp/0.3.0/operation/operation.test.js deleted file mode 100644 index 32358300..00000000 --- a/test/bindings/amqp/0.3.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/amqp/0.3.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.3.0/server/example.json b/test/bindings/amqp/0.3.0/server/example.json deleted file mode 100644 index e50c8c3e..00000000 --- a/test/bindings/amqp/0.3.0/server/example.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "bindingVersion": "0.3.0" -} \ No newline at end of file diff --git a/test/bindings/amqp/0.3.0/server/server.test.js b/test/bindings/amqp/0.3.0/server/server.test.js deleted file mode 100644 index 32358300..00000000 --- a/test/bindings/amqp/0.3.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/amqp/0.3.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/amqp/0.3.0/server/without required properties.json b/test/bindings/amqp/0.3.0/server/without required properties.json deleted file mode 100644 index e50c8c3e..00000000 --- a/test/bindings/amqp/0.3.0/server/without required properties.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "bindingVersion": "0.3.0" -} \ No newline at end of file diff --git a/test/bindings/amqp/index.mjs b/test/bindings/amqp/index.mjs index 00267944..95bfd3c6 100644 --- a/test/bindings/amqp/index.mjs +++ b/test/bindings/amqp/index.mjs @@ -2,16 +2,14 @@ import {describe} from 'vitest'; describe('AMQP Test Suite', () => { describe('0.2.0', async () => { - await import('./0.2.0/channel/channel.test.js'); - await import('./0.2.0/message/message.test.js'); - await import('./0.2.0/operation/operation.test.js'); - await import('./0.2.0/server/server.test.mjs'); + await import('./0.2.0/channel'); + await import('./0.2.0/message'); + await import('./0.2.0/operation'); }); describe('0.3.0', async () => { - await import('./0.3.0/channel/channel.test.js'); - await import('./0.3.0/message/message.test.js'); - await import('./0.3.0/operation/operation.test.js'); - await import('./0.3.0/server/server.test.js'); + await import('./0.3.0/channel'); + await import('./0.3.0/message'); + await import('./0.3.0/operation'); }); }) \ No newline at end of file diff --git a/test/bindings/anypointmq/0.0.1/channel/channel.test.js b/test/bindings/anypointmq/0.0.1/channel/channel.test.js deleted file mode 100644 index 158cea02..00000000 --- a/test/bindings/anypointmq/0.0.1/channel/channel.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/anypointmq/0.0.1/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it.skip('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'is\''); - assert(validator.errors.length === 1); - }); - - it.skip('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'is\''); - assert(validator.errors.length === 1); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/anypointmq/0.0.1/channel/index.mjs b/test/bindings/anypointmq/0.0.1/channel/index.mjs new file mode 100644 index 00000000..c72f1e70 --- /dev/null +++ b/test/bindings/anypointmq/0.0.1/channel/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/anypointmq/0.0.1/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/anypointmq/0.0.1/message/index.mjs b/test/bindings/anypointmq/0.0.1/message/index.mjs new file mode 100644 index 00000000..67be721a --- /dev/null +++ b/test/bindings/anypointmq/0.0.1/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/anypointmq/0.0.1/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/anypointmq/0.0.1/message/message.test.js b/test/bindings/anypointmq/0.0.1/message/message.test.js deleted file mode 100644 index 702a7011..00000000 --- a/test/bindings/anypointmq/0.0.1/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/anypointmq/0.0.1/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it.skip('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/anypointmq/index.mjs b/test/bindings/anypointmq/index.mjs index dfe280d1..11a70172 100644 --- a/test/bindings/anypointmq/index.mjs +++ b/test/bindings/anypointmq/index.mjs @@ -2,7 +2,7 @@ import {describe} from 'vitest'; describe('Anypoint MQ Test Suite', () => { describe('0.0.1', async () => { - await import('./0.0.1/channel/channel.test.js'); - await import('./0.0.1/message/message.test.js'); + await import('./0.0.1/channel'); + await import('./0.0.1/message'); }); }) \ No newline at end of file diff --git a/test/bindings/googlepubsub/0.1.0/channel/channel.test.js b/test/bindings/googlepubsub/0.1.0/channel/channel.test.js deleted file mode 100644 index d615542a..00000000 --- a/test/bindings/googlepubsub/0.1.0/channel/channel.test.js +++ /dev/null @@ -1,59 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/googlepubsub/0.1.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'schemaSettings\''); - assert(validator.errors[1].message === 'must have required property \'topic\''); - assert(validator.errors.length === 2); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'schemaSettings\''); - assert(validator.errors[1].message === 'must have required property \'topic\''); - assert(validator.errors.length === 2); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/googlepubsub/0.1.0/channel/index.mjs b/test/bindings/googlepubsub/0.1.0/channel/index.mjs new file mode 100644 index 00000000..7631989a --- /dev/null +++ b/test/bindings/googlepubsub/0.1.0/channel/index.mjs @@ -0,0 +1,45 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/googlepubsub/0.1.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + [ + 'must have required property \'schemaSettings\'', + 'must have required property \'topic\'' + ] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + [ + 'must have required property \'schemaSettings\'', + 'must have required property \'topic\'' + ] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/googlepubsub/0.1.0/message/index.mjs b/test/bindings/googlepubsub/0.1.0/message/index.mjs new file mode 100644 index 00000000..0a905bf7 --- /dev/null +++ b/test/bindings/googlepubsub/0.1.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/googlepubsub/0.1.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/googlepubsub/0.1.0/message/message.test.js b/test/bindings/googlepubsub/0.1.0/message/message.test.js deleted file mode 100644 index 513c7b05..00000000 --- a/test/bindings/googlepubsub/0.1.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/googlepubsub/0.1.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/googlepubsub/0.2.0/channel/channel.test.js b/test/bindings/googlepubsub/0.2.0/channel/channel.test.js deleted file mode 100644 index 8c17ab45..00000000 --- a/test/bindings/googlepubsub/0.2.0/channel/channel.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/googlepubsub/0.2.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'schemaSettings\''); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'schemaSettings\''); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/googlepubsub/0.2.0/channel/index.mjs b/test/bindings/googlepubsub/0.2.0/channel/index.mjs new file mode 100644 index 00000000..e627be88 --- /dev/null +++ b/test/bindings/googlepubsub/0.2.0/channel/index.mjs @@ -0,0 +1,43 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/googlepubsub/0.2.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + [ + 'must have required property \'schemaSettings\'', + ] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + [ + 'must have required property \'schemaSettings\'', + ] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/googlepubsub/0.2.0/message/index.mjs b/test/bindings/googlepubsub/0.2.0/message/index.mjs new file mode 100644 index 00000000..e1bffca0 --- /dev/null +++ b/test/bindings/googlepubsub/0.2.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/googlepubsub/0.2.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/googlepubsub/0.2.0/message/message.test.js b/test/bindings/googlepubsub/0.2.0/message/message.test.js deleted file mode 100644 index 5f4555a8..00000000 --- a/test/bindings/googlepubsub/0.2.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/googlepubsub/0.2.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/googlepubsub/index.mjs b/test/bindings/googlepubsub/index.mjs index eb92a809..619466ed 100644 --- a/test/bindings/googlepubsub/index.mjs +++ b/test/bindings/googlepubsub/index.mjs @@ -2,12 +2,12 @@ import {describe} from 'vitest'; describe('Google Pub/Sub Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/channel/channel.test.js') - await import('./0.1.0/message/message.test.js') + await import('./0.1.0/channel') + await import('./0.1.0/message') }); describe('0.2.0', async () => { - await import('./0.2.0/channel/channel.test.js') - await import('./0.2.0/message/message.test.js') + await import('./0.2.0/channel') + await import('./0.2.0/message') }); }) \ No newline at end of file diff --git a/test/bindings/http/0.1.0/message/index.mjs b/test/bindings/http/0.1.0/message/index.mjs new file mode 100644 index 00000000..3b2da7a2 --- /dev/null +++ b/test/bindings/http/0.1.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/http/0.1.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/http/0.1.0/message/message.test.js b/test/bindings/http/0.1.0/message/message.test.js deleted file mode 100644 index 6419818c..00000000 --- a/test/bindings/http/0.1.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/http/0.1.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/http/0.1.0/operation/index.mjs b/test/bindings/http/0.1.0/operation/index.mjs new file mode 100644 index 00000000..36d49e4d --- /dev/null +++ b/test/bindings/http/0.1.0/operation/index.mjs @@ -0,0 +1,39 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/http/0.1.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'type\''] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'type\''] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/http/0.1.0/operation/operation.test.js b/test/bindings/http/0.1.0/operation/operation.test.js deleted file mode 100644 index 40ebb3c4..00000000 --- a/test/bindings/http/0.1.0/operation/operation.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/http/0.1.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'type\''); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'type\''); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/http/0.2.0/message/index.mjs b/test/bindings/http/0.2.0/message/index.mjs new file mode 100644 index 00000000..51e2ff5f --- /dev/null +++ b/test/bindings/http/0.2.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/http/0.2.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/http/0.2.0/message/message.test.js b/test/bindings/http/0.2.0/message/message.test.js deleted file mode 100644 index 5f9a320b..00000000 --- a/test/bindings/http/0.2.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/http/0.2.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/http/0.2.0/operation/index.mjs b/test/bindings/http/0.2.0/operation/index.mjs new file mode 100644 index 00000000..171f4e07 --- /dev/null +++ b/test/bindings/http/0.2.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/http/0.2.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/http/0.2.0/operation/operation.test.js b/test/bindings/http/0.2.0/operation/operation.test.js deleted file mode 100644 index e370989a..00000000 --- a/test/bindings/http/0.2.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/http/0.2.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/http/0.3.0/message/index.mjs b/test/bindings/http/0.3.0/message/index.mjs new file mode 100644 index 00000000..757ca8cb --- /dev/null +++ b/test/bindings/http/0.3.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/http/0.3.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/http/0.3.0/message/message.test.js b/test/bindings/http/0.3.0/message/message.test.js deleted file mode 100644 index 4bf342e2..00000000 --- a/test/bindings/http/0.3.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/http/0.3.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/http/0.3.0/operation/index.mjs b/test/bindings/http/0.3.0/operation/index.mjs new file mode 100644 index 00000000..9939b1dc --- /dev/null +++ b/test/bindings/http/0.3.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/http/0.3.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/http/0.3.0/operation/operation.test.js b/test/bindings/http/0.3.0/operation/operation.test.js deleted file mode 100644 index 5482c011..00000000 --- a/test/bindings/http/0.3.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/http/0.3.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/http/index.mjs b/test/bindings/http/index.mjs index 62cf1119..c76cf55f 100644 --- a/test/bindings/http/index.mjs +++ b/test/bindings/http/index.mjs @@ -2,17 +2,17 @@ import {describe} from 'vitest'; describe('HTTP Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/message/message.test.js') - await import('./0.1.0/operation/operation.test.js') + await import('./0.1.0/message') + await import('./0.1.0/operation') }); describe('0.2.0', async () => { - await import('./0.2.0/message/message.test.js') - await import('./0.2.0/operation/operation.test.js') + await import('./0.2.0/message') + await import('./0.2.0/operation') }); describe('0.3.0', async () => { - await import('./0.3.0/message/message.test.js') - await import('./0.3.0/operation/operation.test.js') + await import('./0.3.0/message') + await import('./0.3.0/operation') }); }) \ No newline at end of file diff --git a/test/bindings/ibmmq/0.1.0/channel/channel.test.js b/test/bindings/ibmmq/0.1.0/channel/channel.test.js deleted file mode 100644 index f73cf216..00000000 --- a/test/bindings/ibmmq/0.1.0/channel/channel.test.js +++ /dev/null @@ -1,60 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/ibmmq/0.1.0/channel.json')) - -describe(`${title}`, () => { - it('queue destination', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/examples/queue destination.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('topic destination', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/examples/topic destination.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/ibmmq/0.1.0/channel/index.mjs b/test/bindings/ibmmq/0.1.0/channel/index.mjs new file mode 100644 index 00000000..efea3328 --- /dev/null +++ b/test/bindings/ibmmq/0.1.0/channel/index.mjs @@ -0,0 +1,42 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/ibmmq/0.1.0/channel.json'); + +describe('Channel', () => { + it('queue destination', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './examples/queue destination.json'), + )); + + it('topic destination', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './examples/topic destination.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/ibmmq/0.1.0/message/index.mjs b/test/bindings/ibmmq/0.1.0/message/index.mjs new file mode 100644 index 00000000..818874db --- /dev/null +++ b/test/bindings/ibmmq/0.1.0/message/index.mjs @@ -0,0 +1,40 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/ibmmq/0.1.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must match exactly one schema in oneOf'] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must match exactly one schema in oneOf'] + )); + + it('only required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + ['must match exactly one schema in oneOf'] + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/ibmmq/0.1.0/message/message.test.js b/test/bindings/ibmmq/0.1.0/message/message.test.js deleted file mode 100644 index 90af3717..00000000 --- a/test/bindings/ibmmq/0.1.0/message/message.test.js +++ /dev/null @@ -1,59 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/ibmmq/0.1.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must match exactly one schema in oneOf'); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must match exactly one schema in oneOf'); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with only required properties.'); - assert(validator.errors[0].message === 'must match exactly one schema in oneOf'); - assert(validator.errors.length === 1); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/ibmmq/0.1.0/server/index.mjs b/test/bindings/ibmmq/0.1.0/server/index.mjs new file mode 100644 index 00000000..01cf0d4e --- /dev/null +++ b/test/bindings/ibmmq/0.1.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/ibmmq/0.1.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/ibmmq/0.1.0/server/server.test.js b/test/bindings/ibmmq/0.1.0/server/server.test.js deleted file mode 100644 index b4f9c8b0..00000000 --- a/test/bindings/ibmmq/0.1.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/ibmmq/0.1.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/ibmmq/index.mjs b/test/bindings/ibmmq/index.mjs index 1564bb81..988f88a6 100644 --- a/test/bindings/ibmmq/index.mjs +++ b/test/bindings/ibmmq/index.mjs @@ -2,8 +2,8 @@ import {describe} from 'vitest'; describe('IBM MQ Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/channel/channel.test.js'); - await import('./0.1.0/message/message.test.js'); - await import('./0.1.0/server/server.test.js'); + await import('./0.1.0/channel'); + await import('./0.1.0/message'); + await import('./0.1.0/server'); }); }) \ No newline at end of file diff --git a/test/bindings/amqp/0.2.0/server/empty.json b/test/bindings/jms/0.0.1/channel/empty.json similarity index 100% rename from test/bindings/amqp/0.2.0/server/empty.json rename to test/bindings/jms/0.0.1/channel/empty.json diff --git a/test/bindings/jms/0.1.0/channel/example.json b/test/bindings/jms/0.0.1/channel/example.json similarity index 100% rename from test/bindings/jms/0.1.0/channel/example.json rename to test/bindings/jms/0.0.1/channel/example.json diff --git a/test/bindings/amqp/0.2.0/server/extended.json b/test/bindings/jms/0.0.1/channel/extended.json similarity index 100% rename from test/bindings/amqp/0.2.0/server/extended.json rename to test/bindings/jms/0.0.1/channel/extended.json diff --git a/test/bindings/jms/0.0.1/channel/index.mjs b/test/bindings/jms/0.0.1/channel/index.mjs new file mode 100644 index 00000000..a6ce8b12 --- /dev/null +++ b/test/bindings/jms/0.0.1/channel/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/jms/0.0.1/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/amqp/0.2.0/server/only required properties.json b/test/bindings/jms/0.0.1/channel/only required properties.json similarity index 100% rename from test/bindings/amqp/0.2.0/server/only required properties.json rename to test/bindings/jms/0.0.1/channel/only required properties.json diff --git a/test/bindings/jms/0.1.0/channel/without required properties.json b/test/bindings/jms/0.0.1/channel/without required properties.json similarity index 100% rename from test/bindings/jms/0.1.0/channel/without required properties.json rename to test/bindings/jms/0.0.1/channel/without required properties.json diff --git a/test/bindings/amqp/0.2.0/server/wrongly extended.json b/test/bindings/jms/0.0.1/channel/wrongly extended.json similarity index 100% rename from test/bindings/amqp/0.2.0/server/wrongly extended.json rename to test/bindings/jms/0.0.1/channel/wrongly extended.json diff --git a/test/bindings/amqp/0.3.0/server/empty.json b/test/bindings/jms/0.0.1/message/empty.json similarity index 100% rename from test/bindings/amqp/0.3.0/server/empty.json rename to test/bindings/jms/0.0.1/message/empty.json diff --git a/test/bindings/jms/0.1.0/message/example.json b/test/bindings/jms/0.0.1/message/example.json similarity index 100% rename from test/bindings/jms/0.1.0/message/example.json rename to test/bindings/jms/0.0.1/message/example.json diff --git a/test/bindings/amqp/0.3.0/server/extended.json b/test/bindings/jms/0.0.1/message/extended.json similarity index 100% rename from test/bindings/amqp/0.3.0/server/extended.json rename to test/bindings/jms/0.0.1/message/extended.json diff --git a/test/bindings/jms/0.0.1/message/index.mjs b/test/bindings/jms/0.0.1/message/index.mjs new file mode 100644 index 00000000..8c10dbe9 --- /dev/null +++ b/test/bindings/jms/0.0.1/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/jms/0.0.1/message.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/amqp/0.3.0/server/only required properties.json b/test/bindings/jms/0.0.1/message/only required properties.json similarity index 100% rename from test/bindings/amqp/0.3.0/server/only required properties.json rename to test/bindings/jms/0.0.1/message/only required properties.json diff --git a/test/bindings/jms/0.1.0/message/without required properties.json b/test/bindings/jms/0.0.1/message/without required properties.json similarity index 100% rename from test/bindings/jms/0.1.0/message/without required properties.json rename to test/bindings/jms/0.0.1/message/without required properties.json diff --git a/test/bindings/amqp/0.3.0/server/wrongly extended.json b/test/bindings/jms/0.0.1/message/wrongly extended.json similarity index 100% rename from test/bindings/amqp/0.3.0/server/wrongly extended.json rename to test/bindings/jms/0.0.1/message/wrongly extended.json diff --git a/test/bindings/jms/0.1.0/channel/empty.json b/test/bindings/jms/0.0.1/server/empty.json similarity index 100% rename from test/bindings/jms/0.1.0/channel/empty.json rename to test/bindings/jms/0.0.1/server/empty.json diff --git a/test/bindings/jms/0.1.0/server/example.json b/test/bindings/jms/0.0.1/server/example.json similarity index 100% rename from test/bindings/jms/0.1.0/server/example.json rename to test/bindings/jms/0.0.1/server/example.json diff --git a/test/bindings/jms/0.1.0/server/extended.json b/test/bindings/jms/0.0.1/server/extended.json similarity index 100% rename from test/bindings/jms/0.1.0/server/extended.json rename to test/bindings/jms/0.0.1/server/extended.json diff --git a/test/bindings/jms/0.0.1/server/index.mjs b/test/bindings/jms/0.0.1/server/index.mjs new file mode 100644 index 00000000..07931121 --- /dev/null +++ b/test/bindings/jms/0.0.1/server/index.mjs @@ -0,0 +1,39 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/jms/0.0.1/server.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'jmsConnectionFactory\''] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'jmsConnectionFactory\''] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/jms/0.1.0/server/only required properties.json b/test/bindings/jms/0.0.1/server/only required properties.json similarity index 100% rename from test/bindings/jms/0.1.0/server/only required properties.json rename to test/bindings/jms/0.0.1/server/only required properties.json diff --git a/test/bindings/jms/0.1.0/server/without required properties.json b/test/bindings/jms/0.0.1/server/without required properties.json similarity index 100% rename from test/bindings/jms/0.1.0/server/without required properties.json rename to test/bindings/jms/0.0.1/server/without required properties.json diff --git a/test/bindings/jms/0.1.0/server/wrongly extended.json b/test/bindings/jms/0.0.1/server/wrongly extended.json similarity index 100% rename from test/bindings/jms/0.1.0/server/wrongly extended.json rename to test/bindings/jms/0.0.1/server/wrongly extended.json diff --git a/test/bindings/jms/0.1.0/channel/channel.test.js b/test/bindings/jms/0.1.0/channel/channel.test.js deleted file mode 100644 index 5607c81e..00000000 --- a/test/bindings/jms/0.1.0/channel/channel.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/jms/0.0.1/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/jms/0.1.0/channel/extended.json b/test/bindings/jms/0.1.0/channel/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/jms/0.1.0/channel/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/channel/only required properties.json b/test/bindings/jms/0.1.0/channel/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/jms/0.1.0/channel/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/channel/wrongly extended.json b/test/bindings/jms/0.1.0/channel/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/jms/0.1.0/channel/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/message/empty.json b/test/bindings/jms/0.1.0/message/empty.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/jms/0.1.0/message/empty.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/message/extended.json b/test/bindings/jms/0.1.0/message/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/jms/0.1.0/message/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/message/message.test.js b/test/bindings/jms/0.1.0/message/message.test.js deleted file mode 100644 index 8a86507d..00000000 --- a/test/bindings/jms/0.1.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/jms/0.0.1/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/jms/0.1.0/message/only required properties.json b/test/bindings/jms/0.1.0/message/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/jms/0.1.0/message/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/message/wrongly extended.json b/test/bindings/jms/0.1.0/message/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/jms/0.1.0/message/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/server/empty.json b/test/bindings/jms/0.1.0/server/empty.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/jms/0.1.0/server/empty.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/jms/0.1.0/server/server.test.js b/test/bindings/jms/0.1.0/server/server.test.js deleted file mode 100644 index 015f94fd..00000000 --- a/test/bindings/jms/0.1.0/server/server.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/jms/0.0.1/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'jmsConnectionFactory\''); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'jmsConnectionFactory\''); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/jms/index.mjs b/test/bindings/jms/index.mjs index fbec0e7e..930b9d81 100644 --- a/test/bindings/jms/index.mjs +++ b/test/bindings/jms/index.mjs @@ -1,9 +1,9 @@ import {describe} from 'vitest'; describe('JMS Test Suite', () => { - describe('0.1.0', async () => { - await import('./0.1.0/channel/channel.test.js'); - await import('./0.1.0/message/message.test.js'); - await import('./0.1.0/server/server.test.js'); + describe('0.0.1', async () => { + await import('@test/bindings/jms/0.0.1/channel'); + await import('@test/bindings/jms/0.0.1/message'); + await import('@test/bindings/jms/0.0.1/server'); }); }) \ No newline at end of file diff --git a/test/bindings/kafka/0.1.0/message/index.mjs b/test/bindings/kafka/0.1.0/message/index.mjs new file mode 100644 index 00000000..66d2aa3f --- /dev/null +++ b/test/bindings/kafka/0.1.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.1.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.1.0/message/message.test.js b/test/bindings/kafka/0.1.0/message/message.test.js deleted file mode 100644 index e4735863..00000000 --- a/test/bindings/kafka/0.1.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/kafka/0.1.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.1.0/operation/index.mjs b/test/bindings/kafka/0.1.0/operation/index.mjs new file mode 100644 index 00000000..e03ad247 --- /dev/null +++ b/test/bindings/kafka/0.1.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.1.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.1.0/operation/operation.test.js b/test/bindings/kafka/0.1.0/operation/operation.test.js deleted file mode 100644 index 4790ee66..00000000 --- a/test/bindings/kafka/0.1.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/kafka/0.1.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.3.0/channel/channel.test.js b/test/bindings/kafka/0.3.0/channel/channel.test.js deleted file mode 100644 index 29b07c05..00000000 --- a/test/bindings/kafka/0.3.0/channel/channel.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/kafka/0.3.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.3.0/channel/index.mjs b/test/bindings/kafka/0.3.0/channel/index.mjs new file mode 100644 index 00000000..91324f70 --- /dev/null +++ b/test/bindings/kafka/0.3.0/channel/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.3.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.3.0/message/index.mjs b/test/bindings/kafka/0.3.0/message/index.mjs new file mode 100644 index 00000000..503d8f0f --- /dev/null +++ b/test/bindings/kafka/0.3.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.3.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.3.0/message/message.test.js b/test/bindings/kafka/0.3.0/message/message.test.js deleted file mode 100644 index 51c95435..00000000 --- a/test/bindings/kafka/0.3.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/kafka/0.3.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.3.0/operation/index.mjs b/test/bindings/kafka/0.3.0/operation/index.mjs new file mode 100644 index 00000000..50e997fc --- /dev/null +++ b/test/bindings/kafka/0.3.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.3.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.3.0/operation/operation.test.js b/test/bindings/kafka/0.3.0/operation/operation.test.js deleted file mode 100644 index 7f7e182c..00000000 --- a/test/bindings/kafka/0.3.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/kafka/0.3.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.3.0/server/index.mjs b/test/bindings/kafka/0.3.0/server/index.mjs new file mode 100644 index 00000000..159d1a69 --- /dev/null +++ b/test/bindings/kafka/0.3.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.3.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.3.0/server/server.test.js b/test/bindings/kafka/0.3.0/server/server.test.js deleted file mode 100644 index 132e0781..00000000 --- a/test/bindings/kafka/0.3.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/kafka/0.3.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.4.0/channel/channel.test.js b/test/bindings/kafka/0.4.0/channel/channel.test.js deleted file mode 100644 index 57dc2196..00000000 --- a/test/bindings/kafka/0.4.0/channel/channel.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/kafka/0.4.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.4.0/channel/index.mjs b/test/bindings/kafka/0.4.0/channel/index.mjs new file mode 100644 index 00000000..0c4302bf --- /dev/null +++ b/test/bindings/kafka/0.4.0/channel/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.4.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.4.0/message/index.mjs b/test/bindings/kafka/0.4.0/message/index.mjs new file mode 100644 index 00000000..38ee15a8 --- /dev/null +++ b/test/bindings/kafka/0.4.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.4.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.4.0/message/message.test.js b/test/bindings/kafka/0.4.0/message/message.test.js deleted file mode 100644 index 69bdb36c..00000000 --- a/test/bindings/kafka/0.4.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/kafka/0.4.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.4.0/operation/index.mjs b/test/bindings/kafka/0.4.0/operation/index.mjs new file mode 100644 index 00000000..a7ba13f7 --- /dev/null +++ b/test/bindings/kafka/0.4.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.4.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.4.0/operation/operation.test.js b/test/bindings/kafka/0.4.0/operation/operation.test.js deleted file mode 100644 index 23c6dd2a..00000000 --- a/test/bindings/kafka/0.4.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/kafka/0.4.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.4.0/server/index.mjs b/test/bindings/kafka/0.4.0/server/index.mjs new file mode 100644 index 00000000..bb9a2ef4 --- /dev/null +++ b/test/bindings/kafka/0.4.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.4.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.4.0/server/server.test.js b/test/bindings/kafka/0.4.0/server/server.test.js deleted file mode 100644 index 63df7502..00000000 --- a/test/bindings/kafka/0.4.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/kafka/0.4.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.5.0/channel/channel.test.js b/test/bindings/kafka/0.5.0/channel/channel.test.js deleted file mode 100644 index cdb1379e..00000000 --- a/test/bindings/kafka/0.5.0/channel/channel.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/kafka/0.5.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.5.0/channel/index.mjs b/test/bindings/kafka/0.5.0/channel/index.mjs new file mode 100644 index 00000000..6d213a8f --- /dev/null +++ b/test/bindings/kafka/0.5.0/channel/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.5.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.5.0/message/index.mjs b/test/bindings/kafka/0.5.0/message/index.mjs new file mode 100644 index 00000000..8bcfd500 --- /dev/null +++ b/test/bindings/kafka/0.5.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.5.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.5.0/message/message.test.js b/test/bindings/kafka/0.5.0/message/message.test.js deleted file mode 100644 index b95ec8ed..00000000 --- a/test/bindings/kafka/0.5.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/kafka/0.5.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.5.0/operation/index.mjs b/test/bindings/kafka/0.5.0/operation/index.mjs new file mode 100644 index 00000000..4b21cd69 --- /dev/null +++ b/test/bindings/kafka/0.5.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.5.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.5.0/operation/operation.test.js b/test/bindings/kafka/0.5.0/operation/operation.test.js deleted file mode 100644 index 6b3aa9a0..00000000 --- a/test/bindings/kafka/0.5.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/kafka/0.5.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/0.5.0/server/index.mjs b/test/bindings/kafka/0.5.0/server/index.mjs new file mode 100644 index 00000000..8c1fde4f --- /dev/null +++ b/test/bindings/kafka/0.5.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/kafka/0.5.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/kafka/0.5.0/server/server.test.js b/test/bindings/kafka/0.5.0/server/server.test.js deleted file mode 100644 index 0f08dd44..00000000 --- a/test/bindings/kafka/0.5.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/kafka/0.5.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/kafka/index.mjs b/test/bindings/kafka/index.mjs index fb372245..5b353007 100644 --- a/test/bindings/kafka/index.mjs +++ b/test/bindings/kafka/index.mjs @@ -2,28 +2,28 @@ import {describe} from 'vitest'; describe('Kafka Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/message/message.test.js'); - await import('./0.1.0/operation/operation.test.js'); + await import('./0.1.0/message'); + await import('./0.1.0/operation'); }); describe('0.3.0', async () => { - await import('./0.3.0/channel/channel.test.js'); - await import('./0.3.0/message/message.test.js'); - await import('./0.3.0/operation/operation.test.js'); - await import('./0.3.0/server/server.test.js'); + await import('./0.3.0/channel'); + await import('./0.3.0/message'); + await import('./0.3.0/operation'); + await import('./0.3.0/server'); }); describe('0.4.0', async () => { - await import('./0.4.0/channel/channel.test.js'); - await import('./0.4.0/message/message.test.js'); - await import('./0.4.0/operation/operation.test.js'); - await import('./0.4.0/server/server.test.js'); + await import('./0.4.0/channel'); + await import('./0.4.0/message'); + await import('./0.4.0/operation'); + await import('./0.4.0/server'); }); describe('0.5.0', async () => { - await import('./0.5.0/channel/channel.test.js'); - await import('./0.5.0/message/message.test.js'); - await import('./0.5.0/operation/operation.test.js'); - await import('./0.5.0/server/server.test.js'); + await import('./0.5.0/channel'); + await import('./0.5.0/message'); + await import('./0.5.0/operation'); + await import('./0.5.0/server'); }); }) \ No newline at end of file diff --git a/test/bindings/mqtt/0.1.0/message/index.mjs b/test/bindings/mqtt/0.1.0/message/index.mjs new file mode 100644 index 00000000..9bd03526 --- /dev/null +++ b/test/bindings/mqtt/0.1.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/mqtt/0.1.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/mqtt/0.1.0/message/message.test.js b/test/bindings/mqtt/0.1.0/message/message.test.js deleted file mode 100644 index a17f7ffc..00000000 --- a/test/bindings/mqtt/0.1.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/mqtt/0.1.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/mqtt/0.1.0/operation/index.mjs b/test/bindings/mqtt/0.1.0/operation/index.mjs new file mode 100644 index 00000000..33765542 --- /dev/null +++ b/test/bindings/mqtt/0.1.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/mqtt/0.1.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/mqtt/0.1.0/operation/operation.test.js b/test/bindings/mqtt/0.1.0/operation/operation.test.js deleted file mode 100644 index 3ac25511..00000000 --- a/test/bindings/mqtt/0.1.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/mqtt/0.1.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/mqtt/0.1.0/server/index.mjs b/test/bindings/mqtt/0.1.0/server/index.mjs new file mode 100644 index 00000000..a9556488 --- /dev/null +++ b/test/bindings/mqtt/0.1.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/mqtt/0.1.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/mqtt/0.1.0/server/server.test.js b/test/bindings/mqtt/0.1.0/server/server.test.js deleted file mode 100644 index b2d772cd..00000000 --- a/test/bindings/mqtt/0.1.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/mqtt/0.1.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/mqtt/0.2.0/message/index.mjs b/test/bindings/mqtt/0.2.0/message/index.mjs new file mode 100644 index 00000000..4576fb21 --- /dev/null +++ b/test/bindings/mqtt/0.2.0/message/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/mqtt/0.2.0/message.json'); + +describe('Message', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/mqtt/0.2.0/message/message.test.js b/test/bindings/mqtt/0.2.0/message/message.test.js deleted file mode 100644 index 43a8ab48..00000000 --- a/test/bindings/mqtt/0.2.0/message/message.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Message' -const validator = TestHelper.validator(require('@bindings/mqtt/0.2.0/message.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/mqtt/0.2.0/operation/index.mjs b/test/bindings/mqtt/0.2.0/operation/index.mjs new file mode 100644 index 00000000..31953a5e --- /dev/null +++ b/test/bindings/mqtt/0.2.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/mqtt/0.2.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/mqtt/0.2.0/operation/operation.test.js b/test/bindings/mqtt/0.2.0/operation/operation.test.js deleted file mode 100644 index b12efde4..00000000 --- a/test/bindings/mqtt/0.2.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/mqtt/0.2.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/mqtt/0.2.0/server/index.mjs b/test/bindings/mqtt/0.2.0/server/index.mjs new file mode 100644 index 00000000..f2eb4a41 --- /dev/null +++ b/test/bindings/mqtt/0.2.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/mqtt/0.2.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/mqtt/0.2.0/server/server.test.js b/test/bindings/mqtt/0.2.0/server/server.test.js deleted file mode 100644 index 744bc7e2..00000000 --- a/test/bindings/mqtt/0.2.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/mqtt/0.2.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/mqtt/index.mjs b/test/bindings/mqtt/index.mjs index 86cb61bf..b969b65b 100644 --- a/test/bindings/mqtt/index.mjs +++ b/test/bindings/mqtt/index.mjs @@ -2,14 +2,14 @@ import {describe} from 'vitest'; describe('MQTT Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/message/message.test.js'); - await import('./0.1.0/operation/operation.test.js'); - await import('./0.1.0/server/server.test.js'); + await import('./0.1.0/message'); + await import('./0.1.0/operation'); + await import('./0.1.0/server'); }); describe('0.2.0', async () => { - await import('./0.2.0/message/message.test.js'); - await import('./0.2.0/operation/operation.test.js'); - await import('./0.2.0/server/server.test.js'); + await import('./0.2.0/message'); + await import('./0.2.0/operation'); + await import('./0.2.0/server'); }); }) \ No newline at end of file diff --git a/test/bindings/nats/0.1.0/operation/index.mjs b/test/bindings/nats/0.1.0/operation/index.mjs new file mode 100644 index 00000000..b0482b72 --- /dev/null +++ b/test/bindings/nats/0.1.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/nats/0.1.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/nats/0.1.0/operation/operation.test.js b/test/bindings/nats/0.1.0/operation/operation.test.js deleted file mode 100644 index 8aef25e7..00000000 --- a/test/bindings/nats/0.1.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/nats/0.1.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/nats/index.mjs b/test/bindings/nats/index.mjs index c9fda70f..32ed92b8 100644 --- a/test/bindings/nats/index.mjs +++ b/test/bindings/nats/index.mjs @@ -2,6 +2,6 @@ import {describe} from 'vitest'; describe('NATS Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/operation/operation.test.js'); + await import('./0.1.0/operation'); }); }) \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/channel/channel.test.js b/test/bindings/pulsar/0.1.0/channel/channel.test.js deleted file mode 100644 index 8cef5735..00000000 --- a/test/bindings/pulsar/0.1.0/channel/channel.test.js +++ /dev/null @@ -1,59 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/pulsar/0.1.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'namespace\''); - assert(validator.errors[1].message === 'must have required property \'persistence\''); - assert(validator.errors.length === 2); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'namespace\''); - assert(validator.errors[1].message === 'must have required property \'persistence\''); - assert(validator.errors.length === 2); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/pulsar/0.1.0/channel/index.mjs b/test/bindings/pulsar/0.1.0/channel/index.mjs new file mode 100644 index 00000000..a16cc42a --- /dev/null +++ b/test/bindings/pulsar/0.1.0/channel/index.mjs @@ -0,0 +1,45 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/pulsar/0.1.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + [ + 'must have required property \'namespace\'', + 'must have required property \'persistence\'' + ] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + [ + 'must have required property \'namespace\'', + 'must have required property \'persistence\'' + ] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/pulsar/0.1.0/server/index.mjs b/test/bindings/pulsar/0.1.0/server/index.mjs new file mode 100644 index 00000000..d465541f --- /dev/null +++ b/test/bindings/pulsar/0.1.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/pulsar/0.1.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/pulsar/0.1.0/server/server.test.js b/test/bindings/pulsar/0.1.0/server/server.test.js deleted file mode 100644 index c36576b3..00000000 --- a/test/bindings/pulsar/0.1.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/pulsar/0.1.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/pulsar/index.mjs b/test/bindings/pulsar/index.mjs index b3295bdb..aa13278a 100644 --- a/test/bindings/pulsar/index.mjs +++ b/test/bindings/pulsar/index.mjs @@ -2,7 +2,7 @@ import {describe} from 'vitest'; describe('Pulsar Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/channel/channel.test.js') - await import('./0.1.0/server/server.test.js') + await import('./0.1.0/channel') + await import('./0.1.0/server') }); }) \ No newline at end of file diff --git a/test/bindings/sns/0.1.0/channel/channel.test.js b/test/bindings/sns/0.1.0/channel/channel.test.js deleted file mode 100644 index 977cf65e..00000000 --- a/test/bindings/sns/0.1.0/channel/channel.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/sns/0.1.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'name\''); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'name\''); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/sns/0.1.0/channel/index.mjs b/test/bindings/sns/0.1.0/channel/index.mjs new file mode 100644 index 00000000..7e42e2c2 --- /dev/null +++ b/test/bindings/sns/0.1.0/channel/index.mjs @@ -0,0 +1,39 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/sns/0.1.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'name\''] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'name\''] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json') + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/sns/0.1.0/operation/index.mjs b/test/bindings/sns/0.1.0/operation/index.mjs new file mode 100644 index 00000000..4e00ce8a --- /dev/null +++ b/test/bindings/sns/0.1.0/operation/index.mjs @@ -0,0 +1,39 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/sns/0.1.0/operation.json'); + +describe.skip('Operation. Reason: wrong name in example`', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'consumers\''] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'consumers\''] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/sns/0.1.0/operation/operation.test.js b/test/bindings/sns/0.1.0/operation/operation.test.js deleted file mode 100644 index b6dabcec..00000000 --- a/test/bindings/sns/0.1.0/operation/operation.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/sns/0.1.0/operation.json')) - -describe.skip(`${title}. Reason: wrong name in example`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'consumers\''); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'consumers\''); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/sns/index.mjs b/test/bindings/sns/index.mjs index 78bdd70a..4d5fad6f 100644 --- a/test/bindings/sns/index.mjs +++ b/test/bindings/sns/index.mjs @@ -2,7 +2,7 @@ import {describe} from 'vitest'; describe('Amazon SNS Test Suite', () => { describe('0.1.0', async () => { - await import('./0.1.0/channel/channel.test.js'); - await import('./0.1.0/operation/operation.test.js'); + await import('./0.1.0/channel'); + await import('./0.1.0/operation'); }); }) \ No newline at end of file diff --git a/test/bindings/solace/0.2.0/operation/index.mjs b/test/bindings/solace/0.2.0/operation/index.mjs new file mode 100644 index 00000000..98295354 --- /dev/null +++ b/test/bindings/solace/0.2.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/solace/0.2.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it.skip('extended. TODO: Can be extended or not?', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it.skip('wrongly extended. TODO: Can be extended or not?', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/solace/0.2.0/operation/operation.test.js b/test/bindings/solace/0.2.0/operation/operation.test.js deleted file mode 100644 index b0d05802..00000000 --- a/test/bindings/solace/0.2.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/solace/0.2.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it.skip('extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it.skip('wrongly extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/solace/0.2.0/server/index.mjs b/test/bindings/solace/0.2.0/server/index.mjs new file mode 100644 index 00000000..caad483d --- /dev/null +++ b/test/bindings/solace/0.2.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/solace/0.2.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/solace/0.2.0/server/server.test.js b/test/bindings/solace/0.2.0/server/server.test.js deleted file mode 100644 index 5baa3724..00000000 --- a/test/bindings/solace/0.2.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/solace/0.2.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/solace/0.3.0/operation/index.mjs b/test/bindings/solace/0.3.0/operation/index.mjs new file mode 100644 index 00000000..60a74474 --- /dev/null +++ b/test/bindings/solace/0.3.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/solace/0.3.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it.skip('extended. TODO: Can be extended or not?', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it.skip('wrongly extended. TODO: Can be extended or not?', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/solace/0.3.0/operation/operation.test.js b/test/bindings/solace/0.3.0/operation/operation.test.js deleted file mode 100644 index ab9eaa27..00000000 --- a/test/bindings/solace/0.3.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/solace/0.3.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it.skip('extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it.skip('wrongly extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/solace/0.3.0/server/index.mjs b/test/bindings/solace/0.3.0/server/index.mjs new file mode 100644 index 00000000..3b0e7ac7 --- /dev/null +++ b/test/bindings/solace/0.3.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/solace/0.3.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/solace/0.3.0/server/server.test.js b/test/bindings/solace/0.3.0/server/server.test.js deleted file mode 100644 index 93978d16..00000000 --- a/test/bindings/solace/0.3.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/solace/0.3.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/solace/0.4.0/operation/index.mjs b/test/bindings/solace/0.4.0/operation/index.mjs new file mode 100644 index 00000000..280d1b05 --- /dev/null +++ b/test/bindings/solace/0.4.0/operation/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/solace/0.4.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it.skip('extended. TODO: Can be extended or not?', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it.skip('wrongly extended. TODO: Can be extended or not?', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/solace/0.4.0/operation/operation.test.js b/test/bindings/solace/0.4.0/operation/operation.test.js deleted file mode 100644 index 1ad4de80..00000000 --- a/test/bindings/solace/0.4.0/operation/operation.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/solace/0.4.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it.skip('extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it.skip('wrongly extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/solace/0.4.0/server/index.mjs b/test/bindings/solace/0.4.0/server/index.mjs new file mode 100644 index 00000000..56522d0a --- /dev/null +++ b/test/bindings/solace/0.4.0/server/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/solace/0.4.0/server.json'); + +describe('Server', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/solace/0.4.0/server/server.test.js b/test/bindings/solace/0.4.0/server/server.test.js deleted file mode 100644 index c64e5ff3..00000000 --- a/test/bindings/solace/0.4.0/server/server.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Server' -const validator = TestHelper.validator(require('@bindings/solace/0.4.0/server.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is not valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/solace/index.mjs b/test/bindings/solace/index.mjs index 34df3fc7..5dbf3214 100644 --- a/test/bindings/solace/index.mjs +++ b/test/bindings/solace/index.mjs @@ -2,17 +2,17 @@ import {describe} from 'vitest'; describe('Solace Test Suite', () => { describe('0.2.0', async () => { - await import('./0.2.0/operation/operation.test.js') - await import('./0.2.0/server/server.test.js') + await import('./0.2.0/operation') + await import('./0.2.0/server') }); describe('0.3.0', async () => { - await import('./0.3.0/operation/operation.test.js') - await import('./0.3.0/server/server.test.js') + await import('./0.3.0/operation') + await import('./0.3.0/server') }); describe('0.4.0', async () => { - await import('./0.4.0/operation/operation.test.js') - await import('./0.4.0/server/server.test.js') + await import('./0.4.0/operation') + await import('./0.4.0/server') }); }) \ No newline at end of file diff --git a/test/bindings/sqs/0.2.0/channel/channel.test.js b/test/bindings/sqs/0.2.0/channel/channel.test.js deleted file mode 100644 index 2c302cd7..00000000 --- a/test/bindings/sqs/0.2.0/channel/channel.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/sqs/0.2.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is not valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'queue\''); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'queue\''); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it.skip('extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it.skip('wrongly extended. TODO: Can be extended or not?', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/sqs/0.2.0/channel/index.mjs b/test/bindings/sqs/0.2.0/channel/index.mjs new file mode 100644 index 00000000..3b1333d6 --- /dev/null +++ b/test/bindings/sqs/0.2.0/channel/index.mjs @@ -0,0 +1,39 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/sqs/0.2.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'queue\''] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'queue\''] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json') + )); + + it.skip('extended. TODO: Can be extended or not?', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it.skip('wrongly extended. TODO: Can be extended or not?', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/sqs/0.2.0/operation/index.mjs b/test/bindings/sqs/0.2.0/operation/index.mjs new file mode 100644 index 00000000..3582693f --- /dev/null +++ b/test/bindings/sqs/0.2.0/operation/index.mjs @@ -0,0 +1,39 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/sqs/0.2.0/operation.json'); + +describe('Operation', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + ['must have required property \'queues\''] + )); + + it('without required properties', () => TestHelper.objectIsNotValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + ['must have required property \'queues\''] + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json') + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/sqs/0.2.0/operation/operation.test.js b/test/bindings/sqs/0.2.0/operation/operation.test.js deleted file mode 100644 index 1e514404..00000000 --- a/test/bindings/sqs/0.2.0/operation/operation.test.js +++ /dev/null @@ -1,57 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Operation' -const validator = TestHelper.validator(require('@bindings/sqs/0.2.0/operation.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is valid with empty body'); - assert(validator.errors[0].message === 'must have required property \'queues\''); - assert(validator.errors.length === 1); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Is valid without required properties.'); - assert(validator.errors[0].message === 'must have required property \'queues\''); - assert(validator.errors.length === 1); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/sqs/index.mjs b/test/bindings/sqs/index.mjs index 5eee80b4..672fca80 100644 --- a/test/bindings/sqs/index.mjs +++ b/test/bindings/sqs/index.mjs @@ -2,7 +2,7 @@ import {describe} from 'vitest'; describe('Amazon SQS Test Suite', () => { describe('0.2.0', async () => { - await import('./0.2.0/channel/channel.test.js'); - await import('./0.2.0/operation/operation.test.js'); + await import('./0.2.0/channel'); + await import('./0.2.0/operation'); }); }) \ No newline at end of file diff --git a/test/bindings/websockets/0.1.0/channel/channel.test.mjs b/test/bindings/websockets/0.1.0/channel/channel.test.mjs deleted file mode 100644 index 562db310..00000000 --- a/test/bindings/websockets/0.1.0/channel/channel.test.mjs +++ /dev/null @@ -1,53 +0,0 @@ -import TestHelper from '@test/test-helper'; - -const fs = require('fs'); -const assert = require('assert'); -const title = 'Channel' -const validator = TestHelper.validator(require('@bindings/websockets/0.1.0/channel.json')) - -describe(`${title}`, () => { - it('example', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, `Example MUST be valid`); - }); - - it('empty', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with empty body'); - }); - - it('without required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/without required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid without required properties.'); - }); - - it('only required properties', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/only required properties.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Is valid with only required properties.'); - }); - - it('extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === true, 'Can be extended'); - }); - - it('wrongly extended', () => { - const model = JSON.parse(fs.readFileSync(`${__dirname}/wrongly extended.json`, 'utf-8')); - const validationResult = validator(model); - - assert(validationResult === false, 'Unknown extension are not supported'); - assert(validator.errors[0].message === 'must NOT have additional properties'); - assert(validator.errors[0].params.additionalProperty === 'ext-number'); - assert(validator.errors.length === 1); - }); -}); diff --git a/test/bindings/websockets/0.1.0/channel/index.mjs b/test/bindings/websockets/0.1.0/channel/index.mjs new file mode 100644 index 00000000..35ace9ee --- /dev/null +++ b/test/bindings/websockets/0.1.0/channel/index.mjs @@ -0,0 +1,37 @@ +import {describe, it} from 'vitest'; +import TestHelper from '@test/test-helper'; +import path from 'path'; + +const jsonSchema = require('@bindings/websockets/0.1.0/channel.json'); + +describe('Channel', () => { + it('example', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './example.json'), + )); + + it('empty', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './empty.json'), + )); + + it('without required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './without required properties.json'), + )); + + it('only required properties', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './only required properties.json'), + )); + + it('extended', () => TestHelper.objectIsValid( + jsonSchema, + path.resolve(__dirname, './extended.json'), + )); + + it('wrongly extended', () => TestHelper.wronglyExtended( + jsonSchema, + path.resolve(__dirname, './wrongly extended.json'), + )); +}); diff --git a/test/bindings/websockets/index.mjs b/test/bindings/websockets/index.mjs index fa5e3ae5..cfc15978 100644 --- a/test/bindings/websockets/index.mjs +++ b/test/bindings/websockets/index.mjs @@ -2,6 +2,6 @@ import {describe} from 'vitest'; describe('WebSockets Test Suite', () => { describe('0.1.0', async () => { - await import('@test/bindings/websockets/0.1.0/channel/channel.test.mjs') + await import('@test/bindings/websockets/0.1.0/channel') }); }) \ No newline at end of file