@gravity-ui/data-source
Version:
A wrapper around data fetching
35 lines (34 loc) • 1.15 kB
JavaScript
;
var _notReachable = require("../notReachable");
describe('notReachable', function () {
it('should throw an error with default message', function () {
var callNotReachable = function callNotReachable() {
(0, _notReachable.notReachable)('test');
};
expect(callNotReachable).toThrow('Not reachable state: test');
});
it('should throw an error with custom message', function () {
var callNotReachable = function callNotReachable() {
(0, _notReachable.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 (0, _notReachable.notReachable)(num);
}
};
expect(getNumberName(1)).toBe('one');
expect(getNumberName(2)).toBe('two');
expect(getNumberName(3)).toBe('three');
});
});
// #sourceMappingURL=notReachable.test.js.map