diff options
Diffstat (limited to 'src/utils/defaults.test.ts')
-rw-r--r-- | src/utils/defaults.test.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/defaults.test.ts b/src/utils/defaults.test.ts new file mode 100644 index 0000000..b322968 --- /dev/null +++ b/src/utils/defaults.test.ts @@ -0,0 +1,16 @@ +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'); + }); +}); |