Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bradsawadye committed Nov 1, 2023
1 parent 118ca21 commit 130d8bc
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/unit/appsTest.js
Original file line number Diff line number Diff line change
@@ -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, <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)
})
})
})

0 comments on commit 130d8bc

Please sign in to comment.