From 2e7953ce8e85d0640e7225608b315c769b628409 Mon Sep 17 00:00:00 2001 From: Sergio Moya <1083296+smoya@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:56:44 +0100 Subject: [PATCH] improve test by testing multiple messages in operation --- ...ion-messages-from-referred-channel.spec.ts | 97 ++++++++++++++++++- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/test/ruleset/rules/v3/asyncapi3-operation-messages-from-referred-channel.spec.ts b/test/ruleset/rules/v3/asyncapi3-operation-messages-from-referred-channel.spec.ts index 975ac32db..fc51d47b5 100644 --- a/test/ruleset/rules/v3/asyncapi3-operation-messages-from-referred-channel.spec.ts +++ b/test/ruleset/rules/v3/asyncapi3-operation-messages-from-referred-channel.spec.ts @@ -153,8 +153,7 @@ testRule('asyncapi3-operation-messages-from-referred-channel', [ }, errors: [ { - message: - 'Operation message does not belong to the specified channel.', + message: 'Operation message does not belong to the specified channel.', path: ['operations', 'UserSignedUp', 'messages', '0'], severity: DiagnosticSeverity.Error, } @@ -224,11 +223,101 @@ testRule('asyncapi3-operation-messages-from-referred-channel', [ }, errors: [ { - message: - 'Operation message does not belong to the specified channel.', + message: 'Operation message does not belong to the specified channel.', path: ['components', 'operations', 'UserSignedUp', 'messages', '0'], severity: DiagnosticSeverity.Error, } ], }, + { + name: 'invalid case - multiple messages from operation in components pointing to multiple message from a different channel defined under components', + document: { + asyncapi: '3.0.0', + info: { + title: 'Account Service', + version: '1.0.0' + }, + channels: { + UserSignedUp: { + messages: { + UserSignedUp: { + payload: { + type: 'object', + properties: { + displayName: { + type: 'string' + }, + email: { + type: 'string' + } + } + } + } + } + } + }, + components: { + channels: { + UserRemoved: { + messages: { + UserRemoved: { + payload: { + type: 'object', + properties: { + displayName: { + type: 'string' + }, + email: { + type: 'string' + } + } + } + }, + UserDeleted: { + payload: { + type: 'object', + properties: { + displayName: { + type: 'string' + }, + email: { + type: 'string' + } + } + } + } + } + } + }, + operations: { + UserSignedUp: { + action: 'send', + channel: { + $ref: '#/channels/UserSignedUp' + }, + messages: [ + { + $ref: '#/components/channels/UserRemoved/messages/UserRemoved' + }, + { + $ref: '#/components/channels/UserRemoved/messages/UserDeleted' + } + ] + } + }, + } + }, + errors: [ + { + message: 'Operation message does not belong to the specified channel.', + path: ['components', 'operations', 'UserSignedUp', 'messages', '0'], + severity: DiagnosticSeverity.Error, + }, + { + message: 'Operation message does not belong to the specified channel.', + path: ['components', 'operations', 'UserSignedUp', 'messages', '1'], + severity: DiagnosticSeverity.Error, + } + ], + }, ]);