add /comments test

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-12-20 22:36:37 +01:00
parent 70b3d0edf4
commit 19a2d8b031
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 17 additions and 2 deletions

View File

@ -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)
})
})
})