From 19a2d8b03185007efe069c40675a9df51e52a3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 20 Dec 2018 22:36:37 +0100 Subject: [PATCH] add /comments test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- test/app.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/app.js b/test/app.js index 32c21b1..0da16d6 100644 --- a/test/app.js +++ b/test/app.js @@ -8,19 +8,34 @@ import Comments from '../src/comments' let comments let app +const COMMENTS = [ + { pr: 'PR-1', comment_id: 1234 }, + { pr: 'PR-2', comment_id: 4321 }, + { pr: 'PR-3', comment_id: 9753 }, +] describe('App', () => { beforeEach(() => { comments = sinon.createStubInstance(Comments) - comments.db = sinon.createStubInstance(Builds), + comments.db = sinon.createStubInstance(Builds, { + getComments: COMMENTS, + }), app = App(comments) }) describe('/health', () => { it('should return OK', async () => { - let resp = await request(app.callback()).get('/health') + const resp = await request(app.callback()).get('/health') expect(resp.text).to.eq('OK') expect(resp.status).to.eq(200) }) }) + + describe('/comments', () => { + it('should return list of builds', async () => { + const resp = await request(app.callback()).get('/comments') + expect(resp.body).to.eql({ count: COMMENTS.length, comments: COMMENTS}) + expect(resp.status).to.eq(200) + }) + }) })