Skip to content

Commit

Permalink
Add more 'describe' blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-rr committed May 22, 2024
1 parent 50d9fb1 commit cf7cee3
Showing 1 changed file with 69 additions and 58 deletions.
127 changes: 69 additions & 58 deletions test/integration/bundle/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -86,3 +96,4 @@ describe('bundle spec v3', () => {
done();
});
});

0 comments on commit cf7cee3

Please sign in to comment.