overleaf/libraries/o-error/test/http.test.js

33 lines
671 B
JavaScript
Raw Normal View History

2020-04-28 15:38:34 -04:00
const { expect } = require('chai')
2019-07-26 12:14:56 -04:00
const HttpErrors = require('../http')
const { expectError } = require('./support')
2020-04-17 03:44:50 -04:00
describe('OError/http', function () {
it('is a valid OError', function () {
function foo() {
2019-07-26 12:14:56 -04:00
throw new HttpErrors.ConflictError()
}
try {
foo()
} catch (error) {
expectError(error, {
name: 'ConflictError',
klass: HttpErrors.ConflictError,
message: 'ConflictError: Conflict',
firstFrameRx: /foo/,
})
2019-07-26 12:14:56 -04:00
}
})
2020-04-17 03:44:50 -04:00
it('has status code', function () {
2019-07-26 12:14:56 -04:00
try {
throw new HttpErrors.ConflictError()
} catch (e) {
expect(e.statusCode).to.equal(409)
}
})
})