Skip to content

Commit

Permalink
deps: update http-errors to v2.0.0 (#1486)
Browse files Browse the repository at this point in the history
  • Loading branch information
3imed-jaberi authored Nov 4, 2024
1 parent ce6b3b6 commit 4c34546
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 51 deletions.
6 changes: 2 additions & 4 deletions __tests__/application/use.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ describe('app.use(fn)', () => {
it('should catch thrown errors in non-async functions', () => {
const app = new Koa()

app.use(ctx => ctx.throw('Not Found', 404))
app.use(ctx => ctx.throw(404, 'Not Found'))

return request(app.callback())
.get('/')
.expect(404)
return request(app.callback()).get('/').expect(404)
})

it('should throw error for non-function', () => {
Expand Down
29 changes: 0 additions & 29 deletions __tests__/context/throw.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@ describe('ctx.throw(err)', () => {
})
})

describe('ctx.throw(err, status)', () => {
it('should throw the error and set .status', () => {
const ctx = context()
const error = new Error('test')

try {
ctx.throw(error, 422)
} catch (err) {
assert.strictEqual(err.status, 422)
assert.strictEqual(err.message, 'test')
assert.strictEqual(err.expose, true)
}
})
})

describe('ctx.throw(status, err)', () => {
it('should throw the error and set .status', () => {
const ctx = context()
Expand All @@ -62,20 +47,6 @@ describe('ctx.throw(status, err)', () => {
})
})

describe('ctx.throw(msg, status)', () => {
it('should throw an error', () => {
const ctx = context()

try {
ctx.throw('name required', 400)
} catch (err) {
assert.strictEqual(err.message, 'name required')
assert.strictEqual(err.status, 400)
assert.strictEqual(err.expose, true)
}
})
})

describe('ctx.throw(status, msg)', () => {
it('should throw an error', () => {
const ctx = context()
Expand Down
48 changes: 31 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"escape-html": "^1.0.3",
"fresh": "~0.5.2",
"http-assert": "^1.3.0",
"http-errors": "^1.6.3",
"http-errors": "^2.0.0",
"koa-compose": "^4.1.0",
"on-finished": "^2.3.0",
"parseurl": "^1.3.2",
Expand Down

0 comments on commit 4c34546

Please sign in to comment.