From e719f24b75305a583bb91957a1ff1cc2b74e890b Mon Sep 17 00:00:00 2001 From: Franco Cassar Manghi Date: Fri, 26 Apr 2024 20:21:29 +0100 Subject: [PATCH] Fixed incorrect test and incorrect expected files as part of https://github.com/asyncapi/cli/issues/1323 --- test/integration/bundle/bundle.test.ts | 10 +++++----- test/integration/bundle/final-asyncapi.yaml | 3 +-- test/integration/bundle/final-asyncapiv3.yaml | 7 +++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/integration/bundle/bundle.test.ts b/test/integration/bundle/bundle.test.ts index 0a8f77b58c5..e11a31a07ef 100644 --- a/test/integration/bundle/bundle.test.ts +++ b/test/integration/bundle/bundle.test.ts @@ -6,9 +6,9 @@ import { fileCleanup } from '../../helpers'; const spec = fs.readFileSync('./test/integration/bundle/final-asyncapi.yaml', {encoding: 'utf-8'}); const specv3 = fs.readFileSync('./test/integration/bundle/final-asyncapiv3.yaml', {encoding: 'utf-8'}); -function validateGeneratedSpec(filePath: string, spec: string) { +function assertSpecsEqual(filePath: string, spec: string) { const generatedSPec = fs.readFileSync(path.resolve(filePath), { encoding: 'utf-8' }); - return generatedSPec === spec; + expect(generatedSPec).to.equal(spec); } describe('bundle', () => { @@ -68,7 +68,7 @@ describe('bundle', () => { ]) .it('should be able to bundle multiple specs along with custom reference', (ctx, done) => { expect(ctx.stdout).to.contain('Check out your shiny new bundled files at test/integration/bundle/final.yaml\n'); - expect(validateGeneratedSpec('test/integration/bundle/final.yaml', spec)).to.equal(true); + assertSpecsEqual('test/integration/bundle/final.yaml', spec); fileCleanup('./test/integration/bundle/final.yaml'); done(); }); @@ -80,7 +80,7 @@ describe('bundle', () => { ]) .it('should be able to bundle correctly with overwriting base file', (ctx, done) => { expect(ctx.stdout).to.contain('Check out your shiny new bundled files at test/integration/bundle/final.yaml\n'); - expect(validateGeneratedSpec('test/integration/bundle/final-asyncapi.yaml', spec)).to.equal(true); + assertSpecsEqual('test/integration/bundle/final.yaml', spec); fileCleanup('./test/integration/bundle/final.yaml'); done(); }); @@ -94,7 +94,7 @@ describe('bundle spec v3', () => { '--output=test/integration/bundle/final.yaml', ]).it('should be able to bundle v3 spec correctly', (ctx, done) => { expect(ctx.stdout).to.contain('Check out your shiny new bundled files at test/integration/bundle/final.yaml\n'); - expect(validateGeneratedSpec('test/integration/bundle/final.yaml', specv3)).to.equal(true); + assertSpecsEqual('test/integration/bundle/final.yaml', specv3); fileCleanup('./test/integration/bundle/final.yaml'); done(); }); diff --git a/test/integration/bundle/final-asyncapi.yaml b/test/integration/bundle/final-asyncapi.yaml index 4624b746503..abf2b44148b 100644 --- a/test/integration/bundle/final-asyncapi.yaml +++ b/test/integration/bundle/final-asyncapi.yaml @@ -37,5 +37,4 @@ components: description: Id the user timestamp: type: number - descriptio: Time stamp when the user logged out - + description: Time stamp when the user logged out diff --git a/test/integration/bundle/final-asyncapiv3.yaml b/test/integration/bundle/final-asyncapiv3.yaml index 9d09321960f..f435bd592bf 100644 --- a/test/integration/bundle/final-asyncapiv3.yaml +++ b/test/integration/bundle/final-asyncapiv3.yaml @@ -5,14 +5,14 @@ info: description: This service is in charge of processing user signups channels: userSignedup: - address: 'user/signedup' + address: user/signedup messages: userSignedUpMessage: $ref: '#/components/messages/UserSignedUp' test: - address: '/test' + address: /test messages: - testMessage: + message: $ref: '#/components/messages/TestMessage' operations: UserSignedUp: @@ -59,4 +59,3 @@ components: oneOf: - $ref: '#/components/messages/UserSignedUp' - $ref: '#/components/messages/UserLoggedOut' -