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

31 lines
635 B
JavaScript
Raw Normal View History

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)
}
})
})