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

100% Statements 23/23
94.74% Branches 36/38
100% Functions 4/4
100% Lines 20/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 34 35    55× 55× 49×   40× 29×     11×                    
"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 _errors_1 = require("../_errors");
var ErrorMatchError = (function (_super) {
    __extends(ErrorMatchError, _super);
    function ErrorMatchError(actualError, shouldMatch, expectedErrorType, expectedErrorMessage) {
        _super.call(this, actualError, expectedErrorMessage, "");
        if (expectedErrorType || expectedErrorMessage) {
            if (expectedErrorType === undefined || expectedErrorType === null || (expectedErrorMessage && actualError instanceof expectedErrorType && expectedErrorMessage !== actualError.message)) {
                this._message = "Expected an error with message \"" + expectedErrorMessage + "\" to " + (!shouldMatch ? "not " : "") + "have been thrown, but it was" + (!shouldMatch ? "" : "n't") + ".";
            }
            else if (expectedErrorMessage === undefined || (actualError && !(actualError instanceof expectedErrorType) && expectedErrorMessage === actualError.message)) {
                this._message = "Expected an error of type " + expectedErrorType["name"] + " to " + (!shouldMatch ? "not " : "") + "have been thrown, but " + (shouldMatch ? actualError["name"] + " was thrown instead" : "it was") + ".";
            }
            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") + ".";
            }
        }
        else {
            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.";
            }
        }
    }
    return ErrorMatchError;
}(_errors_1.MatchError));
exports.ErrorMatchError = ErrorMatchError;
//# sourceMappingURL=error-match-error.js.map