all files / core/errors/ error-match-error.js

56.52% Statements 13/23
18.52% Branches 5/27
75% Functions 3/4
50% Lines 10/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                             
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) Eif (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var match_error_1 = require("./match-error");
var ErrorMatchError = (function (_super) {
    __extends(ErrorMatchError, _super);
    function ErrorMatchError(actualError, shouldMatch, expectedErrorType, expectedErrorMessage) {
        _super.call(this, actualError, expectedErrorMessage, "");
        if (!actualError === shouldMatch) {
            if (shouldMatch) {
                this._message = "Expected an error to be thrown but no errors were thown.";
            }
            else {
                this._message = "Expected an error not to be thrown but an error was thown.";
            }
        }
        else if (actualError instanceof expectedErrorType !== shouldMatch) {
            this._message = "Expected an error of type " + expectedErrorType["name"] + " to " + (!shouldMatch ? "not " : "") + "have been thrown, but it was" + (!shouldMatch ? "" : "n't") + ".";
        }
        else if (actualError.message === expectedErrorMessage !== shouldMatch) {
            this._message = "Expected an error with message \"" + expectedErrorMessage + "\" to " + (!shouldMatch ? "not " : "") + "have been thrown, but it was" + (!shouldMatch ? "" : "n't") + ".";
        }
        else {
            this._message = "Expected an error with message \"" + expectedErrorMessage + "\" and type " + expectedErrorType["name"] + " to " + (!shouldMatch ? "not " : "") + "have been thrown, but it was" + (!shouldMatch ? "" : "n't") + ".";
        }
    }
    return ErrorMatchError;
}(match_error_1.MatchError));
exports.ErrorMatchError = ErrorMatchError;
//# sourceMappingURL=error-match-error.js.map