@infctr/eslint-docs
Version:
Keep your rule names and descriptions up-to-date across your repo
35 lines (34 loc) • 1.24 kB
JavaScript
;
var __importStar = undefined && undefined.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const abort_1 = __importStar(require("./abort"));
const abortingFunction = () => abort_1.default();
describe('abort()', () => {
afterEach(() => {
process.exitCode = 0;
});
it('throws an error', () => {
expect(abortingFunction).toThrowError();
});
it('sets the exit code', () => {
try {
abort_1.default();
} catch (e) {}
expect(process.exitCode).toMatchSnapshot();
});
});
describe('unabort', () => {
it('wraps without error', () => expect(() => {
abort_1.unabort(abortingFunction);
}).not.toThrow(abort_1.Abort));
it('catches Abort errors', () => expect(abort_1.unabort(abortingFunction)()).resolves.toBe(undefined));
it('doesn’t catch non-Abort errors', () => expect(abort_1.unabort(() => {
throw new TypeError();
})()).rejects.toBeInstanceOf(TypeError));
});