Skip to content

Commit 6b67f6c

Browse files
committed
Add more tests
1 parent 03aa551 commit 6b67f6c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/main.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,20 @@ const BaseError = ModernError.subclass('BaseError', {
4646
plugins: [modernErrorsCli],
4747
cli: { timeout: 0 },
4848
})
49-
const error = new BaseError(message)
50-
5149
const BothError = ModernError.subclass('BothError', {
5250
plugins: [modernErrorsCli, modernErrorsBeautiful],
5351
cli: { timeout: 0 },
5452
})
53+
const ExitCodeError = BaseError.subclass('ExitCodeError', {
54+
cli: { icon: 'warning' },
55+
})
56+
const DatabaseError = BaseError.subclass('DatabaseError', {
57+
cli: { icon: 'info' },
58+
})
59+
60+
const error = new BaseError(message)
61+
const innerError = new DatabaseError('inner')
62+
const outerError = new ExitCodeError('test', { errors: [innerError] })
5563

5664
each(
5765
[
@@ -115,7 +123,7 @@ test.serial('Can use together with modern-errors-beautiful', (t) => {
115123
)
116124
})
117125

118-
test.serial('Can use aggregate errors', (t) => {
126+
test.serial('Can use aggregate errors, instance options', (t) => {
119127
const { consoleArg } = errorExit(
120128
new BaseError('test', {
121129
cli: { icon: 'warning' },
@@ -126,6 +134,14 @@ test.serial('Can use aggregate errors', (t) => {
126134
t.true(consoleArg.includes(`${figures.info} BaseError: inner`))
127135
})
128136

137+
test.serial('Can use aggregate errors, class options', (t) => {
138+
const { consoleArg } = errorExit(
139+
new ExitCodeError('test', { errors: [new DatabaseError('inner')] }),
140+
)
141+
t.true(consoleArg.includes(`${figures.warning} ExitCodeError: test`))
142+
t.true(consoleArg.includes(`${figures.info} DatabaseError: inner`))
143+
})
144+
129145
test('Returns beautified errors, static', (t) => {
130146
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
131147
const prettyMessage: string = BaseError.pretty(error)

0 commit comments

Comments
 (0)