mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
17 lines
469 B
TypeScript
17 lines
469 B
TypeScript
![]() |
import { describe, expect, it } from 'vitest';
|
||
|
import { withDefaultOnError } from './defaults';
|
||
|
|
||
|
describe('defaults util', () => {
|
||
|
describe('withDefaultOnError', () => {
|
||
|
it('should return the callback or the default one if the callback throws', () => {
|
||
|
expect(withDefaultOnError(() => 'original', 'default')).to.eql('original');
|
||
|
});
|
||
|
|
||
|
expect(
|
||
|
withDefaultOnError(() => {
|
||
|
throw '';
|
||
|
}, 'default'),
|
||
|
).to.eql('default');
|
||
|
});
|
||
|
});
|