Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
304s are only returned if according headers are sent. Caching has to be handled by user
- Loading branch information
Showing
3 changed files
with
45 additions
and
2 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,42 @@ | ||
const chai = require('chai') | ||
const nock = require('nock') | ||
|
||
const GitHub = require('../../') | ||
|
||
const mocha = require('mocha') | ||
const describe = mocha.describe | ||
const it = mocha.it | ||
chai.should() | ||
|
||
describe('request 304s', () => { | ||
it('304 etag', () => { | ||
nock('https://request-errors-test.com') | ||
.get('/orgs/myorg') | ||
.reply(304, '') | ||
|
||
const github = new GitHub({ | ||
host: 'request-errors-test.com' | ||
}) | ||
|
||
return github.orgs.get({org: 'myorg', headers: {'If-None-Match': 'etag'}}) | ||
|
||
.catch(exception => { | ||
exception.code.should.equal(304) | ||
}) | ||
}) | ||
it('304 last-modified', () => { | ||
nock('https://request-errors-test.com') | ||
.get('/orgs/myorg') | ||
.reply(304, '') | ||
|
||
const github = new GitHub({ | ||
host: 'request-errors-test.com' | ||
}) | ||
|
||
return github.orgs.get({org: 'myorg', headers: {'If-Modified-Since': 'Sun Dec 24 2017 22:00:00 GMT-0600 (CST)'}}) | ||
|
||
.catch(exception => { | ||
exception.code.should.equal(304) | ||
}) | ||
}) | ||
}) |