mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-07 06:47:13 -04:00
refactor(base64): mutualized base64 functions into global utilities
This commit is contained in:
parent
ca7cb44389
commit
447bdf2148
8 changed files with 138 additions and 12 deletions
16
src/utils/defaults.test.ts
Normal file
16
src/utils/defaults.test.ts
Normal file
|
@ -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');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue