Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve log of tests executed for bundle command #1446

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});

Loading