1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const empty_matcher_1 = require("./empty-matcher");
|
4 | const stringification_1 = require("../stringification");
|
5 | class StringMatcher extends empty_matcher_1.EmptyMatcher {
|
6 | toMatch(regex) {
|
7 | if (regex === null || regex === undefined) {
|
8 | throw new TypeError("toMatch regular expression must not be null or undefined.");
|
9 | }
|
10 | this._registerMatcher(regex.test(this.actualValue) === this.shouldMatch, `Expected ${stringification_1.stringify(this.actualValue)} ${!this.shouldMatch ? "not " : ""}to conform to ${regex}.`, regex, {
|
11 | string: this.actualValue,
|
12 | regex: regex.toString()
|
13 | });
|
14 | }
|
15 | toContain(expectedContent) {
|
16 | this._registerMatcher(this.actualValue.indexOf(expectedContent) > -1 === this.shouldMatch, `Expected ${stringification_1.stringify(this.actualValue)} ${!this.shouldMatch ? "not " : ""}` + `to contain ${stringification_1.stringify(expectedContent)}.`, expectedContent, {
|
17 | actualContainer: this.actualValue,
|
18 | expectedContent,
|
19 | });
|
20 | }
|
21 | }
|
22 | exports.StringMatcher = StringMatcher;
|
23 |
|
\ | No newline at end of file |