UNPKG

@gravity-ui/data-source

Version:
33 lines 1.08 kB
import { notReachable } from '../notReachable'; describe('notReachable', function () { it('should throw an error with default message', function () { var callNotReachable = function callNotReachable() { notReachable('test'); }; expect(callNotReachable).toThrow('Not reachable state: test'); }); it('should throw an error with custom message', function () { var callNotReachable = function callNotReachable() { notReachable('test', 'Custom error message'); }; expect(callNotReachable).toThrow('Custom error message'); }); it('should be used for exhaustive type checking', function () { var getNumberName = function getNumberName(num) { switch (num) { case 1: return 'one'; case 2: return 'two'; case 3: return 'three'; default: return notReachable(num); } }; expect(getNumberName(1)).toBe('one'); expect(getNumberName(2)).toBe('two'); expect(getNumberName(3)).toBe('three'); }); }); // #sourceMappingURL=notReachable.test.js.map