From 130d8bc3fb10e81beccfae1ba89890ae3163f3ad Mon Sep 17 00:00:00 2001 From: bradsawadye Date: Wed, 1 Nov 2023 15:28:43 +0200 Subject: [PATCH] Increase code coverage --- test/unit/appsTest.js | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/unit/appsTest.js diff --git a/test/unit/appsTest.js b/test/unit/appsTest.js new file mode 100644 index 00000000..dd04e819 --- /dev/null +++ b/test/unit/appsTest.js @@ -0,0 +1,56 @@ +'use strict' + +/* eslint-env mocha */ +import should from 'should' + +import {getApps, updateApp} from '../../src/api/apps' +import {AppModelAPI} from '../../src/model/apps' + +describe('Apps', () => { + afterEach(async () => { + await AppModelAPI.deleteMany({}) + }) + + describe('getApps', () => { + it('should fail when retrieving from mongo fails', async () => { + const ctx = { + request: { + query: {} + } + } + + await getApps(ctx) + + ctx.status.should.equal(500) + should.exist(ctx.body.error) + }) + }) + + describe('updateApps', () => { + it('should fail when updating in mongo fails', async () => { + const app = AppModelAPI({ + name: 'Test app1', + description: 'An app for testing the app framework', + icon: 'data:image/png;base64, ', + type: 'link', + category: 'Operations', + access_roles: ['test-app-user'], + url: 'http://test-app.org/app1', + showInPortal: true, + showInSideBar: true + }) + await app.save() + + const ctx = { + request: { + body: {} + }, + status: 200 + } + + await updateApp(ctx, app._id) + + should.exist(ctx.body.error) + }) + }) +})