Skip to content

Commit 15f60fe

Browse files
committed
Refactor tests
1 parent 5770120 commit 15f60fe

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/main.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const DatabaseError = BaseError.subclass('DatabaseError', {
1515
beautiful: { icon: 'info' },
1616
})
1717
const error = new BaseError('test')
18+
const innerError = new DatabaseError('inner')
19+
const outerError = new ExitCodeError('test', { errors: [innerError] })
1820

1921
each(
2022
[true, { stack: 'true' }, { unknown: true }, { classes: {} }],
@@ -51,19 +53,16 @@ test('Can pass "icon" as class option', (t) => {
5153
t.true(message.includes(`${figures.warning} ExitCodeError: test`))
5254
})
5355

54-
const inner = new DatabaseError('inner')
55-
const outer = new ExitCodeError('test', { errors: [inner] })
56-
5756
test('Can use aggregate errors', (t) => {
58-
const message = BaseError.beautiful(outer)
57+
const message = BaseError.beautiful(outerError)
5958
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
60-
t.is(message, outer.beautiful())
59+
t.is(message, outerError.beautiful())
6160
t.true(message.includes(`${figures.warning} ExitCodeError: test`))
6261
t.true(message.includes(`${figures.info} DatabaseError: inner`))
6362
})
6463

6564
test('Can pass "cause"', (t) => {
66-
const message = BaseError.beautiful(outer, { cause: false })
65+
const message = BaseError.beautiful(outerError, { cause: false })
6766
t.true(message.includes(`${figures.warning} ExitCodeError: test`))
6867
t.false(message.includes('DatabaseError'))
6968
})

0 commit comments

Comments
 (0)