diff --git a/index.js b/index.js index ec2ccb9..304d039 100644 --- a/index.js +++ b/index.js @@ -254,8 +254,8 @@ router.post('/addComment', async ctx => { try { const body = ctx.request.body await comments.comments(ctx.session.user, body.comments, body.genretitle, body.genre) - ctx.body = "" - return; + ctx.body = '' + return } catch (err) { console.log(err) @@ -266,8 +266,8 @@ router.post('/addComment', async ctx => { router.post('/deleteComment', async ctx => { try { await comments.deleteComments(ctx.request.body.commentID) - ctx.body = "" - return; + ctx.body = '' + return } catch (err) { console.log(err) await ctx.render('error', { message: err.message }) diff --git a/modules/search.js b/modules/search.js index 0a96fbd..55187ab 100644 --- a/modules/search.js +++ b/modules/search.js @@ -21,8 +21,6 @@ module.exports = class Search { searchResult.forEach(async result => this.insertRatings(result, 'audio_ratings', 'uploadId', user)) } - - return searchResult } diff --git a/unitTests/search.spec.js b/unitTests/search.spec.js index 4021ba0..5ca5494 100644 --- a/unitTests/search.spec.js +++ b/unitTests/search.spec.js @@ -8,6 +8,13 @@ describe('search()', () => { await expect(search.search({q: 'test'}, 'default')).resolves.toEqual([]) done() }) + + test('invalid search, q is undefined', async done => { + expect.assertions(1) + const search = await new Search(await new Database()) + await expect(search.search({q: undefined}, 'default')).resolves.toBeUndefined() + done() + }) }) describe('sum()', () => {