Skip to content

Commit 130d8bc

Browse files
committed
Increase code coverage
1 parent 118ca21 commit 130d8bc

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

test/unit/appsTest.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict'
2+
3+
/* eslint-env mocha */
4+
import should from 'should'
5+
6+
import {getApps, updateApp} from '../../src/api/apps'
7+
import {AppModelAPI} from '../../src/model/apps'
8+
9+
describe('Apps', () => {
10+
afterEach(async () => {
11+
await AppModelAPI.deleteMany({})
12+
})
13+
14+
describe('getApps', () => {
15+
it('should fail when retrieving from mongo fails', async () => {
16+
const ctx = {
17+
request: {
18+
query: {}
19+
}
20+
}
21+
22+
await getApps(ctx)
23+
24+
ctx.status.should.equal(500)
25+
should.exist(ctx.body.error)
26+
})
27+
})
28+
29+
describe('updateApps', () => {
30+
it('should fail when updating in mongo fails', async () => {
31+
const app = AppModelAPI({
32+
name: 'Test app1',
33+
description: 'An app for testing the app framework',
34+
icon: 'data:image/png;base64, <base64>',
35+
type: 'link',
36+
category: 'Operations',
37+
access_roles: ['test-app-user'],
38+
url: 'http://test-app.org/app1',
39+
showInPortal: true,
40+
showInSideBar: true
41+
})
42+
await app.save()
43+
44+
const ctx = {
45+
request: {
46+
body: {}
47+
},
48+
status: 200
49+
}
50+
51+
await updateApp(ctx, app._id)
52+
53+
should.exist(ctx.body.error)
54+
})
55+
})
56+
})

0 commit comments

Comments
 (0)