Home Reference Source Test Repository

buildDocs/attempt.spec.js

import * as tslib_1 from "tslib";
import { expect } from 'chai';
import { Attempt } from './attempt';
describe('attempt', () => {
    it('should catch the error and return it', () => {
        class MyClass {
            fn() {
                throw new Error();
            }
            fn2() {
                return 10;
            }
        }
        tslib_1.__decorate([
            Attempt()
        ], MyClass.prototype, "fn", null);
        tslib_1.__decorate([
            Attempt()
        ], MyClass.prototype, "fn2", null);
        const myClass = new MyClass();
        expect(myClass.fn()).to.be.an.instanceOf(Error);
        expect(myClass.fn2()).to.equal(10);
    });
});