Skip to content

Commit

Permalink
test: replicate incorrect bundling and missing assertions part of asy…
Browse files Browse the repository at this point in the history
  • Loading branch information
francocm committed Apr 24, 2024
1 parent b9c5dd4 commit b432838
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
6 changes: 4 additions & 2 deletions test/integration/bundle/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from 'path';
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) {
const generatedSPec = fs.readFileSync(path.resolve(filePath), { encoding: 'utf-8' });
Expand Down Expand Up @@ -67,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));
expect(validateGeneratedSpec('test/integration/bundle/final.yaml', spec)).to.be.true;
fileCleanup('./test/integration/bundle/final.yaml');
done();
});
Expand All @@ -79,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));
expect(validateGeneratedSpec('test/integration/bundle/final-asyncapi.yaml', spec)).to.be.true;
fileCleanup('./test/integration/bundle/final.yaml');
done();
});
Expand All @@ -93,6 +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.be.true
fileCleanup('./test/integration/bundle/final.yaml');
done();
});
Expand Down
62 changes: 62 additions & 0 deletions test/integration/bundle/final-asyncapiv3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
userSignedup:
address: 'user/signedup'
messages:
userSignedUpMessage:
$ref: '#/components/messages/UserSignedUp'
test:
address: '/test'
messages:
testMessage:
$ref: '#/components/messages/TestMessage'
operations:
UserSignedUp:
action: send
channel:
$ref: '#/channels/userSignedup'
TestOpp:
action: send
channel:
$ref: '#/channels/test'
components:
messages:
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user
UserLoggedOut:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
userId:
type: string
description: Id the user
timestamp:
type: number
description: Time stamp when the user logged out
TestMessage:
payload:
type: object
properties:
foo:
type: string
extObjRef:
oneOf:
- $ref: '#/components/messages/UserSignedUp'
- $ref: '#/components/messages/UserLoggedOut'

15 changes: 9 additions & 6 deletions test/integration/bundle/first-asyncapiv3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ channels:
test:
address: '/test'
messages:
testMessage:
message:
$ref: '#/components/messages/TestMessage'
operations:
UserSignedUp:
action: send
channel:
$ref: '#/channels/userSignedup'
messages:
- $ref: './test/integration/bundle/messages.yaml#/messages/UserSignedUp'
TestOpp:
action: send
channel:
$ref: '#/channels/test'
messages:
- $ref: '#/components/messages/TestMessage'
components:
messages:
TestMessage:
payload:
type: string
type: object
properties:
foo:
type: string
extObjRef:
oneOf:
- $ref: './test/integration/bundle/messages.yaml#/messages/UserSignedUp'
- $ref: './test/integration/bundle/messages.yaml#/messages/UserLoggedOut'

0 comments on commit b432838

Please sign in to comment.