@fgv/ts-utils 5.0.0-23 → 5.0.0-25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +0 -21
- package/package.json +6 -6
- package/.vscode/launch.json +0 -16
- package/.vscode/settings.json +0 -36
- package/config/api-extractor.json +0 -343
- package/config/rig.json +0 -16
- package/lib/test/helpers/jest/helpers/fsHelpers.d.ts +0 -52
- package/lib/test/helpers/jest/helpers/fsHelpers.js +0 -180
- package/lib/test/helpers/jest/helpers/index.d.ts +0 -2
- package/lib/test/helpers/jest/helpers/index.js +0 -18
- package/lib/test/helpers/jest/index.d.ts +0 -3
- package/lib/test/helpers/jest/index.js +0 -27
- package/lib/test/helpers/jest/matchers/index.d.ts +0 -16
- package/lib/test/helpers/jest/matchers/index.js +0 -19
- package/lib/test/helpers/jest/matchers/toFail/index.d.ts +0 -16
- package/lib/test/helpers/jest/matchers/toFail/index.js +0 -25
- package/lib/test/helpers/jest/matchers/toFail/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toFail/predicate.js +0 -9
- package/lib/test/helpers/jest/matchers/toFailTest/index.d.ts +0 -16
- package/lib/test/helpers/jest/matchers/toFailTest/index.js +0 -30
- package/lib/test/helpers/jest/matchers/toFailTest/predicate.d.ts +0 -3
- package/lib/test/helpers/jest/matchers/toFailTest/predicate.js +0 -12
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.d.ts +0 -17
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.js +0 -26
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.js +0 -15
- package/lib/test/helpers/jest/matchers/toFailTestWith/index.d.ts +0 -18
- package/lib/test/helpers/jest/matchers/toFailTestWith/index.js +0 -31
- package/lib/test/helpers/jest/matchers/toFailTestWith/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toFailTestWith/predicate.js +0 -30
- package/lib/test/helpers/jest/matchers/toFailWith/index.d.ts +0 -18
- package/lib/test/helpers/jest/matchers/toFailWith/index.js +0 -29
- package/lib/test/helpers/jest/matchers/toFailWith/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toFailWith/predicate.js +0 -20
- package/lib/test/helpers/jest/matchers/toFailWithDetail/index.d.ts +0 -19
- package/lib/test/helpers/jest/matchers/toFailWithDetail/index.js +0 -29
- package/lib/test/helpers/jest/matchers/toFailWithDetail/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toFailWithDetail/predicate.js +0 -26
- package/lib/test/helpers/jest/matchers/toSucceed/index.d.ts +0 -16
- package/lib/test/helpers/jest/matchers/toSucceed/index.js +0 -25
- package/lib/test/helpers/jest/matchers/toSucceed/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toSucceed/predicate.js +0 -9
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.d.ts +0 -17
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.js +0 -26
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.d.ts +0 -17
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.js +0 -26
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/index.d.ts +0 -19
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/index.js +0 -55
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.js +0 -21
- package/lib/test/helpers/jest/matchers/toSucceedWith/index.d.ts +0 -18
- package/lib/test/helpers/jest/matchers/toSucceedWith/index.js +0 -29
- package/lib/test/helpers/jest/matchers/toSucceedWith/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toSucceedWith/predicate.js +0 -16
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/index.d.ts +0 -18
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/index.js +0 -29
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/predicate.d.ts +0 -4
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/predicate.js +0 -21
- package/lib/test/helpers/jest/resolvers/cli.d.ts +0 -5
- package/lib/test/helpers/jest/resolvers/cli.js +0 -48
- package/lib/test/helpers/jest/resolvers/ide.d.ts +0 -5
- package/lib/test/helpers/jest/resolvers/ide.js +0 -48
- package/lib/test/helpers/jest/ts-utils.d.ts +0 -2
- package/lib/test/helpers/jest/ts-utils.js +0 -18
- package/lib/test/helpers/jest/types/index.d.ts +0 -79
- package/lib/test/helpers/jest/types/index.js +0 -4
- package/lib/test/helpers/jest/utils/matcherHelpers.d.ts +0 -6
- package/lib/test/helpers/jest/utils/matcherHelpers.js +0 -53
- package/lib/test/helpers/jest/utils/snapshotResolver.d.ts +0 -4
- package/lib/test/helpers/jest/utils/snapshotResolver.js +0 -19
- package/lib/test/unit/collections/collectible.test.d.ts +0 -2
- package/lib/test/unit/collections/collector.test.d.ts +0 -2
- package/lib/test/unit/collections/collectors.test.d.ts +0 -2
- package/lib/test/unit/collections/convertingCollector.test.d.ts +0 -2
- package/lib/test/unit/collections/helpers.d.ts +0 -44
- package/lib/test/unit/collections/helpers.js +0 -115
- package/lib/test/unit/collections/resultMap.test.d.ts +0 -2
- package/lib/test/unit/collections/validatingCollector.test.d.ts +0 -2
- package/lib/test/unit/collections/validatingConvertingCollector.test.d.ts +0 -2
- package/lib/test/unit/collections/validatingResultMap.test.d.ts +0 -2
- package/lib/test/unit/consoleLogger.test.d.ts +0 -2
- package/lib/test/unit/converter.test.d.ts +0 -2
- package/lib/test/unit/converters.test.d.ts +0 -2
- package/lib/test/unit/defaultingConverter.test.d.ts +0 -2
- package/lib/test/unit/file-tree/fileItem.test.d.ts +0 -2
- package/lib/test/unit/file-tree/fileTree.test.d.ts +0 -2
- package/lib/test/unit/file-tree/fsTree.test.d.ts +0 -2
- package/lib/test/unit/file-tree/inMemoryTree.test.d.ts +0 -2
- package/lib/test/unit/file-tree/sample/rootFile.json +0 -1
- package/lib/test/unit/file-tree/sample/some/other/path/file2.json +0 -1
- package/lib/test/unit/file-tree/sample/some/path/below/file4.json +0 -1
- package/lib/test/unit/file-tree/sample/some/path/file1.json +0 -1
- package/lib/test/unit/file-tree/sample/some/path/file3.json +0 -1
- package/lib/test/unit/hash.test.d.ts +0 -2
- package/lib/test/unit/hashingNormalizerCollisions.test.d.ts +0 -2
- package/lib/test/unit/logger.test.d.ts +0 -2
- package/lib/test/unit/mapResults.test.d.ts +0 -3
- package/lib/test/unit/messageAggregator.test.d.ts +0 -3
- package/lib/test/unit/normalize.test.d.ts +0 -2
- package/lib/test/unit/result.test.d.ts +0 -3
- package/lib/test/unit/utils.test.d.ts +0 -3
- package/lib/test/unit/validation/array.test.d.ts +0 -2
- package/lib/test/unit/validation/boolean.test.d.ts +0 -2
- package/lib/test/unit/validation/genericValidator.test.d.ts +0 -2
- package/lib/test/unit/validation/number.test.d.ts +0 -2
- package/lib/test/unit/validation/object.test.d.ts +0 -2
- package/lib/test/unit/validation/oneOf.test.d.ts +0 -2
- package/lib/test/unit/validation/recordOf.test.d.ts +0 -2
- package/lib/test/unit/validation/recursiveValidation.test.d.ts +0 -2
- package/lib/test/unit/validation/string.test.d.ts +0 -2
- package/lib/test/unit/validation/traits.test.d.ts +0 -2
- package/lib/test/unit/validation/typeGuard.test.d.ts +0 -2
- package/lib/test/unit/validation/validators.test.d.ts +0 -2
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2020 Erik Fortune
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
* in the Software without restriction, including without limitation the rights
|
|
8
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
* furnished to do so, subject to the following conditions:
|
|
11
|
-
*
|
|
12
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
* copies or substantial portions of the Software.
|
|
14
|
-
*
|
|
15
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
* SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
-
if (k2 === undefined) k2 = k;
|
|
25
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
-
}
|
|
29
|
-
Object.defineProperty(o, k2, desc);
|
|
30
|
-
}) : (function(o, m, k, k2) {
|
|
31
|
-
if (k2 === undefined) k2 = k;
|
|
32
|
-
o[k2] = m[k];
|
|
33
|
-
}));
|
|
34
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
-
}) : function(o, v) {
|
|
37
|
-
o["default"] = v;
|
|
38
|
-
});
|
|
39
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
-
var ownKeys = function(o) {
|
|
41
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
-
var ar = [];
|
|
43
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
-
return ar;
|
|
45
|
-
};
|
|
46
|
-
return ownKeys(o);
|
|
47
|
-
};
|
|
48
|
-
return function (mod) {
|
|
49
|
-
if (mod && mod.__esModule) return mod;
|
|
50
|
-
var result = {};
|
|
51
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
-
__setModuleDefault(result, mod);
|
|
53
|
-
return result;
|
|
54
|
-
};
|
|
55
|
-
})();
|
|
56
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
|
-
};
|
|
59
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
exports.MockFileSystem = exports.ReadWriteSpies = void 0;
|
|
61
|
-
const fs_1 = __importDefault(require("fs"));
|
|
62
|
-
const path = __importStar(require("path"));
|
|
63
|
-
/**
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
class ReadWriteSpies {
|
|
67
|
-
constructor(read, write) {
|
|
68
|
-
this.read = read;
|
|
69
|
-
this.write = write;
|
|
70
|
-
}
|
|
71
|
-
clear() {
|
|
72
|
-
this.read.mockClear();
|
|
73
|
-
this.write.mockClear();
|
|
74
|
-
}
|
|
75
|
-
restore() {
|
|
76
|
-
this.read.mockRestore();
|
|
77
|
-
this.write.mockRestore();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.ReadWriteSpies = ReadWriteSpies;
|
|
81
|
-
/**
|
|
82
|
-
* @public
|
|
83
|
-
*/
|
|
84
|
-
class MockFileSystem {
|
|
85
|
-
constructor(configs, options) {
|
|
86
|
-
this._extraWrites = [];
|
|
87
|
-
this._config = new Map();
|
|
88
|
-
this._data = new Map();
|
|
89
|
-
this._options = options;
|
|
90
|
-
this._realReadFileSync = fs_1.default.readFileSync;
|
|
91
|
-
for (const config of configs) {
|
|
92
|
-
const fullPath = path.resolve(config.path);
|
|
93
|
-
this._config.set(fullPath, config);
|
|
94
|
-
if (config.backingFile) {
|
|
95
|
-
this.readMockFileSync(fullPath);
|
|
96
|
-
}
|
|
97
|
-
else if (config.payload) {
|
|
98
|
-
this._data.set(fullPath, config.payload);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
readMockFileSync(wanted) {
|
|
103
|
-
var _a;
|
|
104
|
-
const fullPathWanted = path.resolve(wanted);
|
|
105
|
-
if (!this._data.has(fullPathWanted)) {
|
|
106
|
-
const config = this._config.get(fullPathWanted);
|
|
107
|
-
if ((config === null || config === void 0 ? void 0 : config.backingFile) === undefined) {
|
|
108
|
-
if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.mockWriteOnly) !== true) {
|
|
109
|
-
throw new Error(`Mock file not found: ${wanted}`);
|
|
110
|
-
}
|
|
111
|
-
const body = this._realReadFileSync(fullPathWanted).toString();
|
|
112
|
-
this._data.set(fullPathWanted, body);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
const fullBackingPath = path.resolve(config.backingFile);
|
|
116
|
-
const body = this._realReadFileSync(fullBackingPath).toString();
|
|
117
|
-
this._data.set(fullPathWanted, body);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const payload = this._data.get(fullPathWanted);
|
|
121
|
-
// not actually reproducible right now
|
|
122
|
-
/* c8 ignore next 3 */
|
|
123
|
-
if (payload === undefined) {
|
|
124
|
-
throw new Error(`Mock file ${wanted} payload is undefined.`);
|
|
125
|
-
}
|
|
126
|
-
return payload;
|
|
127
|
-
}
|
|
128
|
-
writeMockFileSync(wanted, body) {
|
|
129
|
-
var _a;
|
|
130
|
-
const fullPathWanted = path.resolve(wanted);
|
|
131
|
-
const config = this._config.get(fullPathWanted);
|
|
132
|
-
if (config === undefined) {
|
|
133
|
-
if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.allowUnknownMockWrite) !== true) {
|
|
134
|
-
throw new Error(`Mock path not found: ${wanted}`);
|
|
135
|
-
}
|
|
136
|
-
this._extraWrites.push(fullPathWanted);
|
|
137
|
-
}
|
|
138
|
-
else if (config.writable !== true) {
|
|
139
|
-
throw new Error(`Mock permission denied: ${wanted}`);
|
|
140
|
-
}
|
|
141
|
-
this._data.set(fullPathWanted, body);
|
|
142
|
-
}
|
|
143
|
-
getExtraFilesWritten() {
|
|
144
|
-
return Array.from(this._extraWrites);
|
|
145
|
-
}
|
|
146
|
-
tryGetPayload(want) {
|
|
147
|
-
return this._data.get(path.resolve(want));
|
|
148
|
-
}
|
|
149
|
-
reset() {
|
|
150
|
-
const writable = Array.from(this._config.values()).filter((c) => c.writable === true);
|
|
151
|
-
for (const config of writable) {
|
|
152
|
-
this._data.delete(path.resolve(config.path));
|
|
153
|
-
if (config.backingFile) {
|
|
154
|
-
this.readMockFileSync(path.resolve(config.path));
|
|
155
|
-
}
|
|
156
|
-
else if (config.payload) {
|
|
157
|
-
this._data.set(path.resolve(config.path), config.payload);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
for (const path of this._extraWrites) {
|
|
161
|
-
this._data.delete(path);
|
|
162
|
-
}
|
|
163
|
-
this._extraWrites.splice(0, this._extraWrites.length);
|
|
164
|
-
}
|
|
165
|
-
startSpies() {
|
|
166
|
-
return new ReadWriteSpies(jest.spyOn(fs_1.default, 'readFileSync').mockImplementation((wanted) => {
|
|
167
|
-
if (typeof wanted !== 'string') {
|
|
168
|
-
throw new Error('readFileSync mock supports only string parameters');
|
|
169
|
-
}
|
|
170
|
-
return this.readMockFileSync(wanted);
|
|
171
|
-
}), jest.spyOn(fs_1.default, 'writeFileSync').mockImplementation((wanted, payload) => {
|
|
172
|
-
if (typeof wanted !== 'string' || typeof payload !== 'string') {
|
|
173
|
-
throw new Error('writeFileSync mock supports only string parameters');
|
|
174
|
-
}
|
|
175
|
-
return this.writeMockFileSync(wanted, payload);
|
|
176
|
-
}));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
exports.MockFileSystem = MockFileSystem;
|
|
180
|
-
//# sourceMappingURL=fsHelpers.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./fsHelpers"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MockFileSystem = void 0;
|
|
7
|
-
const matchers_1 = __importDefault(require("./matchers"));
|
|
8
|
-
require("./types");
|
|
9
|
-
var helpers_1 = require("./helpers");
|
|
10
|
-
Object.defineProperty(exports, "MockFileSystem", { enumerable: true, get: function () { return helpers_1.MockFileSystem; } });
|
|
11
|
-
// eslint-disable-next-line no-undef
|
|
12
|
-
function isJestGlobal(g) {
|
|
13
|
-
return g.hasOwnProperty('expect');
|
|
14
|
-
}
|
|
15
|
-
/* c8 ignore else */
|
|
16
|
-
if (isJestGlobal(global)) {
|
|
17
|
-
global.expect.extend(matchers_1.default);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
/* eslint-disable no-console */
|
|
21
|
-
console.error([
|
|
22
|
-
"Unable to find Jest's global expect",
|
|
23
|
-
'Please check that you have added ts-utils-jest correctly to your jest configuration.'
|
|
24
|
-
].join('\n'));
|
|
25
|
-
/* eslint-enable no-console */
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
toSucceedWithDetail: <T extends import("../ts-utils").DetailedResult<unknown, unknown>>(received: T, expected: import("../ts-utils").ResultValueType<T> | RegExp, detail: import("../ts-utils").ResultDetailType<T> | undefined) => jest.CustomMatcherResult;
|
|
3
|
-
toSucceedWith: <T extends import("../ts-utils").Result<unknown>>(received: T, expected: import("../ts-utils").ResultValueType<T> | RegExp) => jest.CustomMatcherResult;
|
|
4
|
-
toSucceedAndSatisfy: <T>(this: jest.MatcherContext, received: import("../ts-utils").Result<T>, test: (value: T) => boolean | void) => jest.CustomMatcherResult;
|
|
5
|
-
toSucceedAndMatchSnapshot: <T>(this: jest.MatcherContext, received: import("../ts-utils").Result<T>) => jest.CustomMatcherResult;
|
|
6
|
-
toSucceedAndMatchInlineSnapshot: <T>(this: jest.MatcherContext, received: import("../ts-utils").Result<T>, snapshot: string | undefined) => jest.CustomMatcherResult;
|
|
7
|
-
toSucceed: <T>(received: import("../ts-utils").Result<T>) => jest.CustomMatcherResult;
|
|
8
|
-
toFailWithDetail: <T extends import("../ts-utils").DetailedResult<unknown, unknown>>(received: T, expectedMessage: string | RegExp | undefined, expectedDetail: import("../ts-utils").ResultDetailType<T>) => jest.CustomMatcherResult;
|
|
9
|
-
toFailWith: <T>(received: import("../ts-utils").Result<T>, expected: string | RegExp | undefined) => jest.CustomMatcherResult;
|
|
10
|
-
toFailTestWith: <T>(cb: () => void, expected: RegExp | string | string[]) => jest.CustomMatcherResult;
|
|
11
|
-
toFailTestAndMatchSnapshot: <T>(this: jest.MatcherContext, cb: () => void) => jest.CustomMatcherResult;
|
|
12
|
-
toFailTest: <T>(cb: () => void) => jest.CustomMatcherResult;
|
|
13
|
-
toFail: <T extends import("../ts-utils").Result<unknown>>(received: T) => jest.CustomMatcherResult;
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const toFail_1 = __importDefault(require("./toFail"));
|
|
7
|
-
const toFailTest_1 = __importDefault(require("./toFailTest"));
|
|
8
|
-
const toFailTestAndMatchSnapshot_1 = __importDefault(require("./toFailTestAndMatchSnapshot"));
|
|
9
|
-
const toFailTestWith_1 = __importDefault(require("./toFailTestWith"));
|
|
10
|
-
const toFailWith_1 = __importDefault(require("./toFailWith"));
|
|
11
|
-
const toFailWithDetail_1 = __importDefault(require("./toFailWithDetail"));
|
|
12
|
-
const toSucceed_1 = __importDefault(require("./toSucceed"));
|
|
13
|
-
const toSucceedAndMatchInlineSnapshot_1 = __importDefault(require("./toSucceedAndMatchInlineSnapshot"));
|
|
14
|
-
const toSucceedAndMatchSnapshot_1 = __importDefault(require("./toSucceedAndMatchSnapshot"));
|
|
15
|
-
const toSucceedAndSatisfy_1 = __importDefault(require("./toSucceedAndSatisfy"));
|
|
16
|
-
const toSucceedWith_1 = __importDefault(require("./toSucceedWith"));
|
|
17
|
-
const toSucceedWithDetail_1 = __importDefault(require("./toSucceedWithDetail"));
|
|
18
|
-
exports.default = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, toFail_1.default), toFailTest_1.default), toFailTestAndMatchSnapshot_1.default), toFailTestWith_1.default), toFailWith_1.default), toFailWithDetail_1.default), toSucceed_1.default), toSucceedAndMatchInlineSnapshot_1.default), toSucceedAndMatchSnapshot_1.default), toSucceedAndSatisfy_1.default), toSucceedWith_1.default), toSucceedWithDetail_1.default);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../../../../index';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace jest {
|
|
4
|
-
interface Matchers<R, T> {
|
|
5
|
-
/**
|
|
6
|
-
* Use .toFail to verify that a Result<T> is a failure
|
|
7
|
-
*/
|
|
8
|
-
toFail(): R;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
declare const _default: {
|
|
13
|
-
toFail: <T extends Result<unknown>>(received: T) => jest.CustomMatcherResult;
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const matcherHelpers_1 = require("../../utils/matcherHelpers");
|
|
4
|
-
const predicate_1 = require("./predicate");
|
|
5
|
-
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
6
|
-
function passMessage(received) {
|
|
7
|
-
return () => [
|
|
8
|
-
(0, jest_matcher_utils_1.matcherHint)(`.not.${predicate_1.matcherName}`),
|
|
9
|
-
(0, matcherHelpers_1.printExpectedResult)('failure', false),
|
|
10
|
-
(0, matcherHelpers_1.printReceivedResult)(received)
|
|
11
|
-
].join('\n');
|
|
12
|
-
}
|
|
13
|
-
function failMessage(received) {
|
|
14
|
-
return () => [(0, jest_matcher_utils_1.matcherHint)(`${predicate_1.matcherName}`), (0, matcherHelpers_1.printExpectedResult)('failure', true), (0, matcherHelpers_1.printReceivedResult)(received)].join('\n');
|
|
15
|
-
}
|
|
16
|
-
exports.default = {
|
|
17
|
-
toFail: function (received) {
|
|
18
|
-
const pass = (0, predicate_1.predicate)(received);
|
|
19
|
-
if (pass) {
|
|
20
|
-
return { pass: true, message: passMessage(received) };
|
|
21
|
-
}
|
|
22
|
-
return { pass: false, message: failMessage(received) };
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matcherName = void 0;
|
|
4
|
-
exports.predicate = predicate;
|
|
5
|
-
exports.matcherName = 'toFail';
|
|
6
|
-
function predicate(received) {
|
|
7
|
-
return received.isFailure();
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=predicate.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
namespace jest {
|
|
3
|
-
interface Matchers<R, T> {
|
|
4
|
-
/**
|
|
5
|
-
* Use .toFailTest to test a custom matcher by
|
|
6
|
-
* verifying that a test case fails.
|
|
7
|
-
*/
|
|
8
|
-
toFailTest<T>(): R;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
declare const _default: {
|
|
13
|
-
toFailTest: <T>(cb: () => void) => jest.CustomMatcherResult;
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */
|
|
4
|
-
const predicate_1 = require("./predicate");
|
|
5
|
-
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
6
|
-
const matcherHelpers_1 = require("../../utils/matcherHelpers");
|
|
7
|
-
function passMessage() {
|
|
8
|
-
return () => [
|
|
9
|
-
(0, jest_matcher_utils_1.matcherHint)(`.not.${predicate_1.matcherName}`, 'callback'),
|
|
10
|
-
(0, matcherHelpers_1.printExpectedResult)('failure', false),
|
|
11
|
-
' Received: Test failed'
|
|
12
|
-
].join('\n');
|
|
13
|
-
}
|
|
14
|
-
function failMessage() {
|
|
15
|
-
return () => [
|
|
16
|
-
(0, jest_matcher_utils_1.matcherHint)(`${predicate_1.matcherName}`, 'callback'),
|
|
17
|
-
(0, matcherHelpers_1.printExpectedResult)('failure', true),
|
|
18
|
-
' Received: Test passed'
|
|
19
|
-
].join('\n');
|
|
20
|
-
}
|
|
21
|
-
exports.default = {
|
|
22
|
-
toFailTest: function (cb) {
|
|
23
|
-
const pass = (0, predicate_1.predicate)(cb);
|
|
24
|
-
if (pass) {
|
|
25
|
-
return { pass: true, message: passMessage() };
|
|
26
|
-
}
|
|
27
|
-
return { pass: false, message: failMessage() };
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matcherName = void 0;
|
|
4
|
-
exports.predicate = predicate;
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */
|
|
6
|
-
const ts_utils_1 = require("../../ts-utils");
|
|
7
|
-
exports.matcherName = 'toFailTest';
|
|
8
|
-
function predicate(cb) {
|
|
9
|
-
const cbResult = (0, ts_utils_1.captureResult)(() => cb());
|
|
10
|
-
return cbResult.isFailure();
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=predicate.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
namespace jest {
|
|
3
|
-
interface Matchers<R, T> {
|
|
4
|
-
/**
|
|
5
|
-
* Use .toFailTestWith to test a custom matcher by
|
|
6
|
-
* verifying that a test case fails as expected and
|
|
7
|
-
* reports an error matching a stored snapshot.
|
|
8
|
-
*/
|
|
9
|
-
toFailTestAndMatchSnapshot<T>(): R;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
declare const _default: {
|
|
14
|
-
toFailTestAndMatchSnapshot: <T>(this: jest.MatcherContext, cb: () => void) => jest.CustomMatcherResult;
|
|
15
|
-
};
|
|
16
|
-
export default _default;
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */
|
|
4
|
-
const predicate_1 = require("./predicate");
|
|
5
|
-
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
6
|
-
const jest_snapshot_1 = require("jest-snapshot");
|
|
7
|
-
exports.default = {
|
|
8
|
-
toFailTestAndMatchSnapshot: function (cb) {
|
|
9
|
-
const context = this;
|
|
10
|
-
const cbResult = (0, predicate_1.predicate)(cb);
|
|
11
|
-
if (cbResult.isFailure()) {
|
|
12
|
-
return {
|
|
13
|
-
pass: false,
|
|
14
|
-
message: () => {
|
|
15
|
-
return [
|
|
16
|
-
(0, jest_matcher_utils_1.matcherHint)(`${predicate_1.matcherName}`, 'callback'),
|
|
17
|
-
' Expected: Callback to fail with an error that matches snapshot',
|
|
18
|
-
' Received: Callback succeeded'
|
|
19
|
-
].join('\n');
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return jest_snapshot_1.toMatchSnapshot.call(context, cbResult.value, 'toFailTestAndMatchSnapshot');
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matcherName = void 0;
|
|
4
|
-
exports.predicate = predicate;
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */
|
|
6
|
-
const ts_utils_1 = require("../../ts-utils");
|
|
7
|
-
exports.matcherName = 'toFailTestAndMatchSnapshot';
|
|
8
|
-
function predicate(cb) {
|
|
9
|
-
const cbResult = (0, ts_utils_1.captureResult)(() => cb());
|
|
10
|
-
if (cbResult.isFailure()) {
|
|
11
|
-
return (0, ts_utils_1.succeed)(cbResult.message);
|
|
12
|
-
}
|
|
13
|
-
return (0, ts_utils_1.fail)('Callback did not fail');
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=predicate.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
namespace jest {
|
|
3
|
-
interface Matchers<R, T> {
|
|
4
|
-
/**
|
|
5
|
-
* Use .toFailTestWith to test a custom matcher by
|
|
6
|
-
* verifying that a test case fails as expected and
|
|
7
|
-
* reports an error matching a supplied value.
|
|
8
|
-
* @param expected -
|
|
9
|
-
*/
|
|
10
|
-
toFailTestWith<T>(expected: string | string[] | RegExp): R;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
declare const _default: {
|
|
15
|
-
toFailTestWith: <T>(cb: () => void, expected: RegExp | string | string[]) => jest.CustomMatcherResult;
|
|
16
|
-
};
|
|
17
|
-
export default _default;
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const predicate_1 = require("./predicate");
|
|
4
|
-
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
5
|
-
const matcherHelpers_1 = require("../../utils/matcherHelpers");
|
|
6
|
-
function passMessage(cbResult, expected) {
|
|
7
|
-
return () => [
|
|
8
|
-
(0, jest_matcher_utils_1.matcherHint)(`.not.${predicate_1.matcherName}`, 'callback', 'expectedMessage'),
|
|
9
|
-
(0, matcherHelpers_1.printExpectedResult)('failure', false, expected),
|
|
10
|
-
` Received: Callback failed with:\n>>>>\n${cbResult.value}\n<<<<`
|
|
11
|
-
].join('\n');
|
|
12
|
-
}
|
|
13
|
-
function failMessage(cbResult, expected) {
|
|
14
|
-
return () => [
|
|
15
|
-
(0, jest_matcher_utils_1.matcherHint)(`${predicate_1.matcherName}`, 'callback', 'expectedMessage'),
|
|
16
|
-
(0, matcherHelpers_1.printExpectedResult)('failure', true, expected),
|
|
17
|
-
cbResult.message === ''
|
|
18
|
-
? ' Received: Callback succeeded'
|
|
19
|
-
: ` Received: Callback failed with:\n>>>>\n${cbResult.message}\n<<<<`
|
|
20
|
-
].join('\n');
|
|
21
|
-
}
|
|
22
|
-
exports.default = {
|
|
23
|
-
toFailTestWith: function (cb, expected) {
|
|
24
|
-
const cbResult = (0, predicate_1.predicate)(cb, expected);
|
|
25
|
-
if (cbResult.isSuccess()) {
|
|
26
|
-
return { pass: true, message: passMessage(cbResult, expected) };
|
|
27
|
-
}
|
|
28
|
-
return { pass: false, message: failMessage(cbResult, expected) };
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matcherName = void 0;
|
|
4
|
-
exports.predicate = predicate;
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */
|
|
6
|
-
const expect_utils_1 = require("@jest/expect-utils");
|
|
7
|
-
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
8
|
-
const ts_utils_1 = require("../../ts-utils");
|
|
9
|
-
exports.matcherName = 'toFailTestWith';
|
|
10
|
-
function predicate(cb, expected) {
|
|
11
|
-
const cbResult = (0, ts_utils_1.captureResult)(() => cb());
|
|
12
|
-
if (cbResult.isFailure()) {
|
|
13
|
-
let success = false;
|
|
14
|
-
if (expected instanceof RegExp) {
|
|
15
|
-
success = cbResult.message.match(expected) !== null;
|
|
16
|
-
}
|
|
17
|
-
else if (typeof expected === 'string') {
|
|
18
|
-
success = cbResult.message === expected;
|
|
19
|
-
}
|
|
20
|
-
else if (Array.isArray(expected)) {
|
|
21
|
-
success = (0, expect_utils_1.equals)(cbResult.message.split('\n'), expected);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return (0, ts_utils_1.fail)(`Unsupported expected value "${(0, jest_matcher_utils_1.stringify)(expected)}" for toFailTestWith`);
|
|
25
|
-
}
|
|
26
|
-
return success ? (0, ts_utils_1.succeed)(cbResult.message) : (0, ts_utils_1.fail)(cbResult.message);
|
|
27
|
-
}
|
|
28
|
-
return (0, ts_utils_1.fail)('');
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=predicate.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../../../../index';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace jest {
|
|
4
|
-
interface Matchers<R, T> {
|
|
5
|
-
/**
|
|
6
|
-
* Use .toFailWith to verify that a Result<T> is a failure
|
|
7
|
-
* that matches a supplied string, RegExp or undefined value
|
|
8
|
-
* @param message -
|
|
9
|
-
*/
|
|
10
|
-
toFailWith(message: string | RegExp | undefined): R;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
declare const _default: {
|
|
15
|
-
toFailWith: <T>(received: Result<T>, expected: string | RegExp | undefined) => jest.CustomMatcherResult;
|
|
16
|
-
};
|
|
17
|
-
export default _default;
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const matcherHelpers_1 = require("../../utils/matcherHelpers");
|
|
4
|
-
const predicate_1 = require("./predicate");
|
|
5
|
-
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
6
|
-
function passMessage(received, expected) {
|
|
7
|
-
return () => [
|
|
8
|
-
(0, jest_matcher_utils_1.matcherHint)(`.not.${predicate_1.matcherName}`),
|
|
9
|
-
(0, matcherHelpers_1.printExpectedResult)('failure', false, expected),
|
|
10
|
-
(0, matcherHelpers_1.printReceivedResult)(received)
|
|
11
|
-
].join('\n');
|
|
12
|
-
}
|
|
13
|
-
function failMessage(received, expected) {
|
|
14
|
-
return () => [
|
|
15
|
-
(0, jest_matcher_utils_1.matcherHint)(`${predicate_1.matcherName}`),
|
|
16
|
-
(0, matcherHelpers_1.printExpectedResult)('failure', true, expected),
|
|
17
|
-
(0, matcherHelpers_1.printReceivedResult)(received)
|
|
18
|
-
].join('\n');
|
|
19
|
-
}
|
|
20
|
-
exports.default = {
|
|
21
|
-
toFailWith: function (received, expected) {
|
|
22
|
-
const pass = (0, predicate_1.predicate)(received, expected);
|
|
23
|
-
if (pass) {
|
|
24
|
-
return { pass: true, message: passMessage(received, expected) };
|
|
25
|
-
}
|
|
26
|
-
return { pass: false, message: failMessage(received, expected) };
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matcherName = void 0;
|
|
4
|
-
exports.predicate = predicate;
|
|
5
|
-
exports.matcherName = 'toFailWith';
|
|
6
|
-
function predicate(received, expected) {
|
|
7
|
-
if (received.isFailure()) {
|
|
8
|
-
if (expected === undefined) {
|
|
9
|
-
return received.message === undefined;
|
|
10
|
-
}
|
|
11
|
-
else if (expected instanceof RegExp) {
|
|
12
|
-
return received.message.match(expected) !== null;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return received.message === expected;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=predicate.js.map
|