Skip to content

Commit

Permalink
feat(#112): improving coverage on issueRoute test
Browse files Browse the repository at this point in the history
Co-authored-by: jbisinotti <victormax2006@gmail.com>
  • Loading branch information
pdaniel37 and jbisinotti committed Nov 27, 2019
1 parent 9537af3 commit 0248571
Showing 1 changed file with 15 additions and 43 deletions.
58 changes: 15 additions & 43 deletions APIs/issues_request/test/issueRoute.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,23 @@
const chai = require('chai')
const axios = require('axios')
const expect = chai.expect
const request = require('supertest')
const app = require('../src/app')

const urlBase = 'http://localhost:3002/routes'
const token = require('../../constants')
const urlEndpoint = urlBase + '?owner=fga-eps-mds&repository=2019.2-Git-Breakdown=' + token
const url = urlBase
const token = require('../../constants').token

describe('Issues route tests', () => {
it('Test: Request valid', (done) => {
axios.get(urlEndpoint).then(response => {

let _body = {}
try{
_body = response.data
}
catch(e){
_body = {}
}

expect(response.status).to.equal(200);
body.should.have.property('open');
}
).catch(err => {
const errorResponse = err
it('should respond with status code 200', async() => {
const res = await request(app).get(`/issues?owner=fga-eps-mds&repository=2019.2-Git-Breakdown&token=${token}`)

expect(res).toEqual(expect.any(Object));
expect(res.statusCode).toEqual(200);
})
done()
})

it('Test: Request without parameters', (done) => {
axios.get(urlBase).then(response => {

let _body = {};
try{
_body = response.data
}
catch(e){
_body = {}
}
}
).catch(err => {
if(err.response.status === 400){
expect(err.response.status).to.equal(400)
}else{
expect(err.response.status).to.equal(404)
}

it('should respond with status code 400', async() => {
const res = await request(app).get(`/issues?owner=fga-eps-mds&repository=2019.2-Git-Breakdown`)

expect(res).toEqual(expect.any(Object));
expect(res.statusCode).toEqual(400);
})
done()
})

})

0 comments on commit 0248571

Please sign in to comment.