From 02323fd5e96c57072da002f1b937f791004c99c1 Mon Sep 17 00:00:00 2001 From: Matatjahu Date: Mon, 28 Mar 2022 10:41:37 +0200 Subject: [PATCH] add more unit tests --- .../tests/convert.controller.test.ts | 20 +++++++++++++++++++ src/services/tests/convert.service.test.ts | 13 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/controllers/tests/convert.controller.test.ts b/src/controllers/tests/convert.controller.test.ts index 1ce90f23..5d651daf 100644 --- a/src/controllers/tests/convert.controller.test.ts +++ b/src/controllers/tests/convert.controller.test.ts @@ -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()]); diff --git a/src/services/tests/convert.service.test.ts b/src/services/tests/convert.service.test.ts index 29591188..d466a4c0 100644 --- a/src/services/tests/convert.service.test.ts +++ b/src/services/tests/convert.service.test.ts @@ -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');