This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add tests to the ping http API
- Loading branch information
Showing
3 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
const dirtyChai = require('dirty-chai') | ||
|
||
const expect = chai.expect | ||
chai.use(dirtyChai) | ||
|
||
module.exports = (http) => { | ||
describe('/ping', function () { | ||
let api | ||
|
||
before(() => { | ||
api = http.api.server.select('API') | ||
}) | ||
|
||
it('returns 400 if both n and count are provided', (done) => { | ||
api.inject({ | ||
method: 'GET', | ||
url: `/api/v0/ping?arg=someRandomId&n=1&count=1` | ||
}, (res) => { | ||
expect(res.statusCode).to.equal(400) | ||
done() | ||
}) | ||
}) | ||
|
||
it('returns 400 if arg is not provided', (done) => { | ||
api.inject({ | ||
method: 'GET', | ||
url: `/api/v0/ping?count=1` | ||
}, (res) => { | ||
expect(res.statusCode).to.equal(400) | ||
done() | ||
}) | ||
}) | ||
|
||
it('returns 200 and the response stream with the ping result', (done) => { | ||
api.inject({ | ||
method: 'GET', | ||
url: `/api/v0/ping?arg=someRandomId` | ||
}, (res) => { | ||
expect(res.statusCode).to.equal(200) | ||
expect(res.headers['x-chunked-output']).to.equal('1') | ||
expect(res.headers['transfer-encoding']).to.equal('chunked') | ||
expect(res.headers['content-type']).to.include('application/json') | ||
done() | ||
}) | ||
}) | ||
}) | ||
} |