Skip to content

Commit

Permalink
Merge branch 'master' of github.com:orpheus-gql/orpheus-gql-app
Browse files Browse the repository at this point in the history
  • Loading branch information
tttaaannnggg committed Apr 13, 2019
2 parents eb91264 + 4a20ab4 commit be75401
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions __tests__/supertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('/graphql', () => {
return request(server)
.get('/graphql')
.expect('Content-Type', /application\/json/)
.expect(200);
.expect(400);
})
})
})
Expand All @@ -34,12 +34,12 @@ describe('/requests', () => {
.get('/requests')
.expect(res => {
if (typeof res.body !== 'object'){
throw new Error('items in the array are not object')
throw new Error('response is not an object')
}
if (typeof res.body[0] !== 'object'){
if (typeof res.body.counts !== 'object'){
throw new Error('items in the array are not object')
}
if (!Array.isArray(res.body[1])){
if (!Array.isArray(res.body.history)){
throw new Error('items in the object are not array')
}
})
Expand All @@ -53,10 +53,20 @@ describe('/reset', () => {
it('resets the entire counts object', () => {
return request(server)
.get('/reset')
.expect(typeof res.body).toEqual('object');
.expect(res => {
if (Object.keys(res.body.counts).length !== 0) {
throw new Error('counts not reset')
}
if (res.body.history.length !== 0) {
throw new Error('history not reset')
}
if (res.body.requests.length !== 0) {
throw new Error('requests not reset')
}
})
.expect(200);
})
})
})
})

describe('/netstats', () => {
Expand All @@ -68,10 +78,10 @@ describe('/netstats', () => {
if (typeof res.body !== 'object'){
throw new Error('items in the array are not object')
}
if (!Array.isArray(res.body[0])){
if (!Array.isArray(res.body.history)){
throw new Error('items in the array are not object')
}
if (typeof res.body[1] !== 'number'){
if (typeof res.body.average !== 'number'){
throw new Error('item in the array is not number')
}
})
Expand Down

0 comments on commit be75401

Please sign in to comment.