Skip to content

Commit 02af93b

Browse files
committed
Fix types
1 parent c898f1f commit 02af93b

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

test/helpers/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import modernErrors from 'modern-errors'
1+
import ModernError from 'modern-errors'
22
import modernErrorsHttp from 'modern-errors-http'
33

4-
const BaseError = modernErrors([modernErrorsHttp])
5-
BaseError.subclass('UnknownError')
6-
export const TestError = BaseError.subclass('TestError')
7-
export const testError = new TestError('test')
4+
export const BaseError = ModernError.subclass('BaseError', {
5+
plugins: [modernErrorsHttp],
6+
})
7+
export const baseError = new BaseError('test')

test/main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import test from 'ava'
22
import { each } from 'test-each'
33

4-
import { TestError, testError } from './helpers/main.js'
4+
import { BaseError, baseError } from './helpers/main.js'
55

66
each(
77
[
@@ -21,7 +21,7 @@ each(
2121
],
2222
({ title }, [propName, propValue]) => {
2323
test(`Valid options are kept | ${title}`, (t) => {
24-
const httpResponse = testError.httpResponse({ [propName]: propValue })
24+
const httpResponse = baseError.httpResponse({ [propName]: propValue })
2525
t.deepEqual(httpResponse[propName], propValue)
2626
})
2727
},
@@ -37,28 +37,28 @@ each(
3737
],
3838
({ title }, http) => {
3939
test(`Assign default options | ${title}`, (t) => {
40-
const { name, message, stack } = testError
41-
const httpResponse = testError.httpResponse(http)
40+
const { name, message, stack } = baseError
41+
const httpResponse = baseError.httpResponse(http)
4242
t.deepEqual(httpResponse, { title: name, detail: message, stack })
4343
})
4444
},
4545
)
4646

4747
test('Assign default extra', (t) => {
4848
const props = { prop: true }
49-
t.deepEqual(new TestError('test', { props }).httpResponse().extra, props)
49+
t.deepEqual(new BaseError('test', { props }).httpResponse().extra, props)
5050
})
5151

5252
test('Keep extra JSON-safe', (t) => {
53-
t.deepEqual(testError.httpResponse({ extra: { one: true, two: 0n } }).extra, {
53+
t.deepEqual(baseError.httpResponse({ extra: { one: true, two: 0n } }).extra, {
5454
one: true,
5555
})
5656
})
5757

5858
test('Keep object keys order', (t) => {
5959
t.deepEqual(
6060
Object.keys(
61-
testError.httpResponse({
61+
baseError.httpResponse({
6262
extra: {},
6363
stack: '',
6464
instance: '',

test/options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import test from 'ava'
22
import { each } from 'test-each'
33

4-
import { testError } from './helpers/main.js'
4+
import { baseError } from './helpers/main.js'
55

66
each(
77
[
@@ -20,7 +20,7 @@ each(
2020
],
2121
({ title }, http) => {
2222
test(`Options are validated | ${title}`, (t) => {
23-
t.throws(testError.httpResponse.bind(testError, http))
23+
t.throws(baseError.httpResponse.bind(baseError, http))
2424
})
2525
},
2626
)

0 commit comments

Comments
 (0)