@chassisjs/hermes
Version:
Production-Ready TypeScript Outbox Pattern
29 lines • 1.08 kB
JavaScript
import { expect, test } from '@jest/globals';
import { noop } from 'ts-essentials';
import { isNil, swallow } from './utils.js';
test(`noop is a function that does nothing`, () => {
expect(typeof noop).toEqual('function');
expect(noop()).toBeUndefined();
});
test(`isNil checks whether the value is null or undefined`, () => {
expect(typeof isNil).toEqual('function');
expect(isNil(null)).toBeTruthy();
expect(isNil(undefined)).toBeTruthy();
expect(isNil(0)).toBeFalsy();
expect(isNil('')).toBeFalsy();
expect(isNil(NaN)).toBeFalsy();
expect(isNil({})).toBeFalsy();
expect(isNil([])).toBeFalsy();
expect(isNil('test')).toBeFalsy();
});
test(`swallow cacthes a sync function error and do nothing`, () => {
swallow(() => {
throw new Error();
});
swallow(() => 'some value');
});
test(`swallow cacthes an async function error and do nothing`, async () => {
await swallow(async () => await Promise.reject(new Error()));
await swallow(async () => await Promise.resolve());
});
//# sourceMappingURL=utils.test.js.map