Skip to content

Commit

Permalink
add more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmatatjahu committed Mar 28, 2022
1 parent d70de20 commit 02323fd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/controllers/tests/convert.controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ describe('ConvertController', () => {
});
});

it('should pass when converting to latest version', () => {
const app = new App([new ConvertController()]);

return request(app.getServer())
.post('/v1/convert')
.send({
asyncapi: validJsonAsyncAPI2_0_0,
})
.expect(200, {
converted: {
asyncapi: '2.3.0',
info: {
title: 'Super test',
version: '1.0.0'
},
channels: {},
},
});
});

it('should correctly convert JSON to YAML', () => {
const app = new App([new ConvertController()]);

Expand Down
13 changes: 13 additions & 0 deletions src/services/tests/convert.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ describe('ConvertService', () => {
});
});

it('should pass when converting to latest version', async () => {
const converted = await convertService.convert(validJsonAsyncAPI2_0_0);

expect(converted).toEqual({
asyncapi: '2.3.0',
info: {
title: 'Super test',
version: '1.0.0'
},
channels: {},
});
});

it('should correctly convert JSON to YAML', async () => {
const converted = await convertService.convert(validJsonAsyncAPI2_0_0, '2.3.0', 'yaml');

Expand Down

0 comments on commit 02323fd

Please sign in to comment.