UNPKG

alsatian

Version:

TypeScript and JavaScript testing framework for beautiful and readable tests

18 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const matcher_1 = require("./matcher"); const stringification_1 = require("../stringification"); class PropertyMatcher extends matcher_1.Matcher { toHaveBeenSet() { this._registerMatcher((this.actualValue.setCalls.length === 0) !== this.shouldMatch, `Expected property ${!this.shouldMatch ? "not " : ""}to be set`, `property ${this.shouldMatch ? "" : "not "}to have been set`); } toHaveBeenSetTo(value) { const stringifiedValue = stringification_1.stringify(value); this._registerMatcher(this.actualValue.setCalls.some(call => call.args[0] === value) === this.shouldMatch, `Expected property ${!this.shouldMatch ? "not " : ""}to be set to ${stringifiedValue}.`, `property ${this.shouldMatch ? "" : "not "}to be set to ${stringifiedValue}.`, { actualValues: this.actualValue.setCalls.map(call => call.args[0]), expectedValue: value }); } } exports.PropertyMatcher = PropertyMatcher; //# sourceMappingURL=property-matcher.js.map