From cf7cee3d9e5da1e62bf47e181cd1e6738c907c9a Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Wed, 22 May 2024 18:34:30 +0200 Subject: [PATCH] Add more 'describe' blocks --- test/integration/bundle/bundle.test.ts | 127 ++++++++++++++----------- 1 file changed, 69 insertions(+), 58 deletions(-) diff --git a/test/integration/bundle/bundle.test.ts b/test/integration/bundle/bundle.test.ts index f1ac4bf776a..5f1af2d866f 100644 --- a/test/integration/bundle/bundle.test.ts +++ b/test/integration/bundle/bundle.test.ts @@ -11,70 +11,80 @@ function validateGeneratedSpec(filePath: string, spec: string) { } describe('bundle', () => { - test - .stdout() - .command([ - 'bundle', './test/integration/bundle/first-asyncapi.yaml', - '--output=./test/integration/bundle/final.yaml', - ]) - .it('should successfully bundle specification', (ctx, done) => { - expect(ctx.stdout).to.contain( - 'Check out your shiny new bundled files at ./test/integration/bundle/final.yaml' - ); - fileCleanup('./test/integration/bundle/final.yaml'); - done(); - }); + describe('bundle successful', () => { + test + .stdout() + .command([ + 'bundle', './test/integration/bundle/first-asyncapi.yaml', + '--output=./test/integration/bundle/final.yaml', + ]) + .it('should successfully bundle specification', (ctx, done) => { + expect(ctx.stdout).to.contain( + 'Check out your shiny new bundled files at ./test/integration/bundle/final.yaml' + ); + fileCleanup('./test/integration/bundle/final.yaml'); + done(); + }); + }); - test - .stdout() - .command([ - 'bundle', './test/integration/bundle/first-asyncapi.yaml', - '--output=./test/integration/bundle/final.json' - ]) - .it('should successfully bundle specification into json file', (ctx, done) => { - expect(ctx.stdout).to.contain( - 'Check out your shiny new bundled files at ./test/integration/bundle/final.json' - ); - fileCleanup('./test/integration/bundle/final.json'); - done(); - }); + describe('bundle into json file', () => { + test + .stdout() + .command([ + 'bundle', './test/integration/bundle/first-asyncapi.yaml', + '--output=./test/integration/bundle/final.json' + ]) + .it('should successfully bundle specification into json file', (ctx, done) => { + expect(ctx.stdout).to.contain( + 'Check out your shiny new bundled files at ./test/integration/bundle/final.json' + ); + fileCleanup('./test/integration/bundle/final.json'); + done(); + }); + }); - test - .stderr() - .command([ - 'bundle', './test/integration/bundle/asyncapi.yml' - ]) - .it('should throw error message if the file path is wrong', (ctx, done) => { - expect(ctx.stderr).to.contain('Error: ENOENT: no such file or directory'); - done(); - }); + describe('when file path is wrong', () => { + test + .stderr() + .command([ + 'bundle', './test/integration/bundle/asyncapi.yml' + ]) + .it('should throw error message if the file path is wrong', (ctx, done) => { + expect(ctx.stderr).to.contain('Error: ENOENT: no such file or directory'); + done(); + }); + }); - test - .stdout() - .command([ - 'bundle', './test/integration/bundle/first-asyncapi.yaml', './test/integration/bundle/feature.yaml', '--output=test/integration/bundle/final.yaml' - ]) - .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)); - fileCleanup('./test/integration/bundle/final.yaml'); - done(); - }); + describe('with custom reference', () => { + test + .stdout() + .command([ + 'bundle', './test/integration/bundle/first-asyncapi.yaml', './test/integration/bundle/feature.yaml', '--output=test/integration/bundle/final.yaml' + ]) + .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)); + fileCleanup('./test/integration/bundle/final.yaml'); + done(); + }); + }); - test - .stdout() - .command([ - 'bundle', './test/integration/bundle/first-asyncapi.yaml', './test/integration/bundle/feature.yaml', '--output=test/integration/bundle/final.yaml', '--base=./test/integration/bundle/first-asyncapi.yaml' - ]) - .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)); - fileCleanup('./test/integration/bundle/final.yaml'); - done(); - }); + describe('with base file', () => { + test + .stdout() + .command([ + 'bundle', './test/integration/bundle/first-asyncapi.yaml', './test/integration/bundle/feature.yaml', '--output=test/integration/bundle/final.yaml', '--base=./test/integration/bundle/first-asyncapi.yaml' + ]) + .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)); + fileCleanup('./test/integration/bundle/final.yaml'); + done(); + }); + }); }); -describe('bundle spec v3', () => { +describe('bundle, with spec v3', () => { test .stdout() .command([ @@ -86,3 +96,4 @@ describe('bundle spec v3', () => { done(); }); }); +