UNPKG

@future-widget-lab/safe-ops

Version:

A set of helper functions for performing operations safely, preventing runtime errors from disrupting your application.

19 lines (17 loc) 590 B
import { safeguard } from './safeguard.helper'; describe('Unit | Helper | safeguard', () => { it.each([ { input: false, expected: false }, { input: undefined, expected: false }, { input: null, expected: false }, { input: '', expected: false }, { input: 0, expected: false }, { input: 1, expected: true }, { input: new Date(), expected: true }, { input: [], expected: true }, { input: {}, expected: true }, { input: () => {}, expected: true } ])('should return $expected given $input', ({ input, expected }) => { expect(safeguard(input)).toEqual(expected); }); });