Repository URL to install this package:
|
Version:
0.6.0 ▾
|
gateway-proxy
/
usr
/
share
/
gateway-proxy
/
app
/
node_modules
/
furious-commander
/
test
/
error-handler.spec.ts
|
|---|
import cli, { LeafCommand } from '../src'
class TestCommand implements LeafCommand {
public name = 'test'
public description = 'Test'
run() {
throw Error('Expected')
}
}
describe('Error handler', () => {
it('should invoke custom error handler', async () => {
let caughtError = null
await cli({
rootCommandClasses: [TestCommand],
testArguments: ['test'],
errorHandler: error => {
caughtError = error
},
})
expect(caughtError).toHaveProperty('message', 'Expected')
})
it('should invoke default error handler', async () => {
let caughtError = null
await cli({
rootCommandClasses: [TestCommand],
testArguments: ['test'],
printer: {
print: () => {
/* empty */
},
printHeading: () => {
/* empty */
},
formatDim: () => '',
formatImportant: () => '',
printError: message => {
caughtError = message
},
getGenericErrorMessage: () => '',
},
})
expect(caughtError).toBe('Expected')
})
})