test: request error logs

This commit is contained in:
Gregor 2019-01-23 21:57:37 -08:00
parent 328d9f519b
commit 7ce6902b71
1 changed files with 17 additions and 0 deletions

View File

@ -8,6 +8,10 @@ describe('GitHubAPI', () => {
beforeEach(() => {
const options: Options = {
logger,
retry: {
// disable retries to test error states
enabled: false
},
throttle: {
// disable throttling, otherwise tests are _slow_
enabled: false
@ -25,6 +29,19 @@ describe('GitHubAPI', () => {
expect((await github.users.getAuthenticated({})).data).toEqual(user)
})
test('logs request errors', async () => {
nock('https://api.github.com')
.get('/')
.reply(500, {})
try {
await github.request('/')
throw new Error('should throw')
} catch (error) {
expect(error.status).toBe(500)
}
})
describe('paginate', () => {
// Prepare an array of issue objects
const issues = new Array(5).fill(0).map((_, i, arr) => {