1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const matcher_1 = require("./matcher");
|
4 | const stringification_1 = require("../stringification");
|
5 | class EmptyMatcher extends matcher_1.Matcher {
|
6 | toBeEmpty() {
|
7 | const actualValue = this.actualValue;
|
8 | const length = this._getLength(actualValue);
|
9 | this._registerMatcher((length === 0) === this.shouldMatch, `Expected "${typeof actualValue === "string"
|
10 | ? actualValue
|
11 | : stringification_1.stringify(actualValue)}" ` + `${this.shouldMatch ? "" : "not "}to be empty.`, "value to be empty", {
|
12 | actualLength: length,
|
13 | expectedLength: this.shouldMatch ? 0 : "> 0"
|
14 | });
|
15 | }
|
16 | _getLength(value) {
|
17 | if (value instanceof Map) {
|
18 | return value.size;
|
19 | }
|
20 | if (value.length !== undefined) {
|
21 | return value.length;
|
22 | }
|
23 | return Object.keys(value).length;
|
24 | }
|
25 | }
|
26 | exports.EmptyMatcher = EmptyMatcher;
|
27 |
|
\ | No newline at end of file |