mirror of
https://github.com/status-im/github-comment-manager.git
synced 2025-02-19 20:58:09 +00:00
add tests for /builds paths
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
302742243a
commit
905cf97a30
39
test/app.js
39
test/app.js
@ -7,20 +7,21 @@ import App from '../src/app'
|
||||
import Builds from '../src/builds'
|
||||
import Comments from '../src/comments'
|
||||
|
||||
let comments, app
|
||||
let ghc, app
|
||||
|
||||
describe('App', () => {
|
||||
beforeEach(() => {
|
||||
comments = sinon.createStubInstance(Comments)
|
||||
comments.db = sinon.createStubInstance(Builds, {
|
||||
ghc = sinon.createStubInstance(Comments)
|
||||
ghc.db = sinon.createStubInstance(Builds, {
|
||||
getComments: sample.COMMENTS,
|
||||
}),
|
||||
app = App(comments)
|
||||
app = App(ghc)
|
||||
})
|
||||
|
||||
describe('GET /health', () => {
|
||||
it('should return OK', async () => {
|
||||
const 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)
|
||||
})
|
||||
@ -28,11 +29,37 @@ describe('App', () => {
|
||||
|
||||
describe('GET /comments', () => {
|
||||
it('should return list of builds', async () => {
|
||||
const resp = await request(app.callback()).get('/comments')
|
||||
const resp = await request(app.callback())
|
||||
.get('/comments')
|
||||
expect(resp.body).to.eql({
|
||||
count: sample.COMMENTS.length, comments: sample.COMMENTS
|
||||
})
|
||||
expect(resp.status).to.eq(200)
|
||||
})
|
||||
})
|
||||
|
||||
describe('POST /builds/:pr', () => {
|
||||
it('should store the POSTed build', async () => {
|
||||
const resp = await request(app.callback())
|
||||
.post('/builds/PR-1')
|
||||
.send(sample.BUILD)
|
||||
expect(resp.body).to.eql({status:'ok'})
|
||||
expect(resp.status).to.eq(201)
|
||||
expect(ghc.db.addBuild).calledOnceWith('PR-1', sample.BUILD)
|
||||
expect(ghc.update).calledOnceWith('PR-1')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('POST /builds/:pr/refresh', () => {
|
||||
it('should update github comment', async () => {
|
||||
const resp = await request(app.callback())
|
||||
.post('/builds/PR-1/refresh')
|
||||
.send(sample.BUILD)
|
||||
expect(resp.body).to.eql({status:'ok'})
|
||||
expect(resp.status).to.eq(201)
|
||||
expect(ghc.db.addBuild).not.calledOnceWith('PR-1', sample.BUILD)
|
||||
expect(ghc.update).calledOnceWith('PR-1')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user