2019-07-26 12:14:56 -04:00
|
|
|
const HttpErrors = require('../http')
|
|
|
|
|
2020-04-17 04:00:28 -04:00
|
|
|
const { expectError } = require('./support')
|
|
|
|
|
2020-04-17 03:44:50 -04:00
|
|
|
describe('OError/http', function () {
|
2020-04-17 04:00:28 -04:00
|
|
|
it('is a valid OError', function () {
|
|
|
|
function foo() {
|
2019-07-26 12:14:56 -04:00
|
|
|
throw new HttpErrors.ConflictError()
|
2020-04-17 04:00:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|