Skip to content

Commit

Permalink
Fixed incorrect test and incorrect expected files as part of asyncapi…
Browse files Browse the repository at this point in the history
  • Loading branch information
francocm committed Apr 26, 2024
1 parent 03ce3a6 commit e719f24
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions test/integration/bundle/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand Down
3 changes: 1 addition & 2 deletions test/integration/bundle/final-asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions test/integration/bundle/final-asyncapiv3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -59,4 +59,3 @@ components:
oneOf:
- $ref: '#/components/messages/UserSignedUp'
- $ref: '#/components/messages/UserLoggedOut'

0 comments on commit e719f24

Please sign in to comment.