@fgv/ts-utils 5.0.0-22 → 5.0.0-24
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/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/packlets/base/index.d.ts +0 -2
- package/lib/packlets/base/index.js +1 -25
- package/lib/packlets/base/result.d.ts +49 -0
- package/lib/packlets/base/result.js +36 -0
- package/lib/packlets/collections/collector.d.ts +9 -0
- package/lib/packlets/collections/collector.js +6 -0
- package/lib/packlets/collections/validatingCollector.d.ts +5 -1
- package/lib/packlets/hash/hashingNormalizer.js +4 -3
- package/lib/packlets/logging/index.d.ts +3 -0
- package/{src/packlets/base/index.ts → lib/packlets/logging/index.js} +19 -10
- package/lib/packlets/logging/logReporter.d.ts +69 -0
- package/lib/packlets/logging/logReporter.js +72 -0
- package/lib/packlets/logging/logger.d.ts +183 -0
- package/lib/packlets/logging/logger.js +237 -0
- package/package.json +6 -6
- package/.vscode/launch.json +0 -16
- package/.vscode/settings.json +0 -36
- package/dist/ts-utils.d.ts +0 -4832
- package/dist/tsdoc-metadata.json +0 -11
- package/lib/packlets/base/logger.d.ts +0 -52
- package/lib/packlets/base/logger.js +0 -128
- 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/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/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
- package/src/index.ts +0 -63
- package/src/packlets/base/brand.ts +0 -28
- package/src/packlets/base/logger.ts +0 -156
- package/src/packlets/base/mapResults.ts +0 -302
- package/src/packlets/base/messageAggregator.ts +0 -120
- package/src/packlets/base/normalize.ts +0 -144
- package/src/packlets/base/result.ts +0 -961
- package/src/packlets/base/utils.ts +0 -236
- package/src/packlets/collections/collectible.ts +0 -238
- package/src/packlets/collections/collector.ts +0 -273
- package/src/packlets/collections/collectorValidator.ts +0 -178
- package/src/packlets/collections/common.ts +0 -27
- package/src/packlets/collections/convertingCollector.ts +0 -223
- package/src/packlets/collections/convertingCollectorValidator.ts +0 -164
- package/src/packlets/collections/index.ts +0 -39
- package/src/packlets/collections/keyValueConverters.ts +0 -142
- package/src/packlets/collections/readonlyResultMap.ts +0 -99
- package/src/packlets/collections/resultMap.ts +0 -322
- package/src/packlets/collections/resultMapValidator.ts +0 -188
- package/src/packlets/collections/utils.ts +0 -33
- package/src/packlets/collections/validatingCollector.ts +0 -123
- package/src/packlets/collections/validatingConvertingCollector.ts +0 -113
- package/src/packlets/collections/validatingResultMap.ts +0 -94
- package/src/packlets/conversion/baseConverter.ts +0 -330
- package/src/packlets/conversion/converter.ts +0 -260
- package/src/packlets/conversion/converters.ts +0 -1039
- package/src/packlets/conversion/defaultingConverter.ts +0 -188
- package/src/packlets/conversion/index.ts +0 -30
- package/src/packlets/conversion/objectConverter.ts +0 -259
- package/src/packlets/conversion/stringConverter.ts +0 -165
- package/src/packlets/file-tree/directoryItem.ts +0 -84
- package/src/packlets/file-tree/fileItem.ts +0 -119
- package/src/packlets/file-tree/fileTree.ts +0 -152
- package/src/packlets/file-tree/fileTreeAccessors.ts +0 -176
- package/src/packlets/file-tree/fsTree.ts +0 -118
- package/src/packlets/file-tree/in-memory/inMemoryTree.ts +0 -171
- package/src/packlets/file-tree/in-memory/index.ts +0 -23
- package/src/packlets/file-tree/in-memory/treeBuilder.ts +0 -203
- package/src/packlets/file-tree/index.ts +0 -31
- package/src/packlets/hash/crcNormalizer.ts +0 -81
- package/src/packlets/hash/hashingNormalizer.ts +0 -102
- package/src/packlets/hash/index.ts +0 -24
- package/src/packlets/validation/array.ts +0 -84
- package/src/packlets/validation/boolean.ts +0 -63
- package/src/packlets/validation/classes.ts +0 -38
- package/src/packlets/validation/common.ts +0 -28
- package/src/packlets/validation/field.ts +0 -99
- package/src/packlets/validation/genericValidator.ts +0 -204
- package/src/packlets/validation/index.ts +0 -31
- package/src/packlets/validation/number.ts +0 -66
- package/src/packlets/validation/object.ts +0 -208
- package/src/packlets/validation/oneOf.ts +0 -78
- package/src/packlets/validation/string.ts +0 -66
- package/src/packlets/validation/traits.ts +0 -113
- package/src/packlets/validation/typeGuard.ts +0 -83
- package/src/packlets/validation/validator.ts +0 -157
- package/src/packlets/validation/validatorBase.ts +0 -66
- package/src/packlets/validation/validators.ts +0 -254
package/dist/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.52.10"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Failure, Success } from './result';
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export type LogLevel = 'detail' | 'info' | 'warning' | 'error' | 'silent';
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export interface Logger {
|
|
10
|
-
log(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
11
|
-
detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
12
|
-
info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
13
|
-
warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
14
|
-
warnAndFail<T>(message?: unknown, ...parameters: unknown[]): Failure<T>;
|
|
15
|
-
error<T>(message?: unknown, ...parameters: unknown[]): Failure<T>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export declare abstract class LoggerBase {
|
|
21
|
-
logLevel: LogLevel;
|
|
22
|
-
constructor(logLevel?: LogLevel);
|
|
23
|
-
detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
24
|
-
info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
25
|
-
warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
26
|
-
warnAndFail<T>(message?: unknown, ...parameters: unknown[]): Failure<T>;
|
|
27
|
-
error<T>(message?: unknown, ...parameters: unknown[]): Failure<T>;
|
|
28
|
-
log(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
29
|
-
protected _format(message?: unknown, ...parameters: unknown[]): string;
|
|
30
|
-
protected _innerSilent(__message: string): Success<string | undefined>;
|
|
31
|
-
protected abstract _innerLog(message: string): Success<string | undefined>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export declare class InMemoryLogger extends LoggerBase {
|
|
37
|
-
protected _messages: string[];
|
|
38
|
-
protected _silent: string[];
|
|
39
|
-
constructor(logLevel?: LogLevel);
|
|
40
|
-
get messages(): string[];
|
|
41
|
-
get silent(): string[];
|
|
42
|
-
clear(): void;
|
|
43
|
-
protected _innerLog(message: string): Success<string | undefined>;
|
|
44
|
-
protected _innerSilent(message: string): Success<string | undefined>;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
49
|
-
export declare class NoOpLogger extends LoggerBase {
|
|
50
|
-
protected _innerLog(message: string): Success<string | undefined>;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoOpLogger = exports.InMemoryLogger = exports.LoggerBase = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (c) 2020 Erik Fortune
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
const result_1 = require("./result");
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
class LoggerBase {
|
|
30
|
-
constructor(logLevel) {
|
|
31
|
-
this.logLevel = 'info';
|
|
32
|
-
this.logLevel = logLevel !== null && logLevel !== void 0 ? logLevel : 'info';
|
|
33
|
-
}
|
|
34
|
-
detail(message, ...parameters) {
|
|
35
|
-
if (this.logLevel === 'detail') {
|
|
36
|
-
return this.log(message, parameters);
|
|
37
|
-
}
|
|
38
|
-
return (0, result_1.succeed)(undefined);
|
|
39
|
-
}
|
|
40
|
-
info(message, ...parameters) {
|
|
41
|
-
if (this.logLevel === 'detail' || this.logLevel === 'info') {
|
|
42
|
-
return this.log(message, parameters);
|
|
43
|
-
}
|
|
44
|
-
return (0, result_1.succeed)(undefined);
|
|
45
|
-
}
|
|
46
|
-
warn(message, ...parameters) {
|
|
47
|
-
if (this.logLevel !== 'error' && this.logLevel !== 'silent') {
|
|
48
|
-
return this.log(message, parameters);
|
|
49
|
-
}
|
|
50
|
-
return (0, result_1.succeed)(undefined);
|
|
51
|
-
}
|
|
52
|
-
warnAndFail(message, ...parameters) {
|
|
53
|
-
var _a;
|
|
54
|
-
const formatted = this._format(message, ...parameters);
|
|
55
|
-
if (this.logLevel !== 'error' && this.logLevel !== 'silent') {
|
|
56
|
-
const result = this.log(formatted);
|
|
57
|
-
return (0, result_1.fail)((_a = result.value) !== null && _a !== void 0 ? _a : formatted);
|
|
58
|
-
}
|
|
59
|
-
return (0, result_1.fail)(formatted);
|
|
60
|
-
}
|
|
61
|
-
error(message, ...parameters) {
|
|
62
|
-
var _a;
|
|
63
|
-
const formatted = this._format(message, ...parameters);
|
|
64
|
-
if (this.logLevel !== 'silent') {
|
|
65
|
-
const result = this.log(formatted);
|
|
66
|
-
return (0, result_1.fail)((_a = result.value) !== null && _a !== void 0 ? _a : formatted);
|
|
67
|
-
}
|
|
68
|
-
return (0, result_1.fail)(formatted);
|
|
69
|
-
}
|
|
70
|
-
log(message, ...parameters) {
|
|
71
|
-
const messageString = this._format(message, ...parameters);
|
|
72
|
-
if (this.logLevel === 'silent') {
|
|
73
|
-
return this._innerSilent(messageString);
|
|
74
|
-
}
|
|
75
|
-
return this._innerLog(messageString);
|
|
76
|
-
}
|
|
77
|
-
_format(message, ...parameters) {
|
|
78
|
-
const raw = [message, ...parameters];
|
|
79
|
-
const filtered = raw.filter((m) => m !== undefined);
|
|
80
|
-
const strings = filtered.map((m) => m.toString());
|
|
81
|
-
const joined = strings.join('');
|
|
82
|
-
return joined;
|
|
83
|
-
}
|
|
84
|
-
_innerSilent(__message) {
|
|
85
|
-
return (0, result_1.succeed)(undefined);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.LoggerBase = LoggerBase;
|
|
89
|
-
/**
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
class InMemoryLogger extends LoggerBase {
|
|
93
|
-
constructor(logLevel) {
|
|
94
|
-
super(logLevel);
|
|
95
|
-
this._messages = [];
|
|
96
|
-
this._silent = [];
|
|
97
|
-
}
|
|
98
|
-
get messages() {
|
|
99
|
-
return this._messages;
|
|
100
|
-
}
|
|
101
|
-
get silent() {
|
|
102
|
-
return this._silent;
|
|
103
|
-
}
|
|
104
|
-
clear() {
|
|
105
|
-
this._messages = [];
|
|
106
|
-
this._silent = [];
|
|
107
|
-
}
|
|
108
|
-
_innerLog(message) {
|
|
109
|
-
this._messages.push(message);
|
|
110
|
-
return (0, result_1.succeed)(message);
|
|
111
|
-
}
|
|
112
|
-
_innerSilent(message) {
|
|
113
|
-
this._silent.push(message);
|
|
114
|
-
return (0, result_1.succeed)(undefined);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.InMemoryLogger = InMemoryLogger;
|
|
118
|
-
/**
|
|
119
|
-
* @public
|
|
120
|
-
*/
|
|
121
|
-
class NoOpLogger extends LoggerBase {
|
|
122
|
-
_innerLog(message) {
|
|
123
|
-
// no-op
|
|
124
|
-
return (0, result_1.succeed)(message);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.NoOpLogger = NoOpLogger;
|
|
128
|
-
//# sourceMappingURL=logger.js.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export interface IMockFileConfig {
|
|
5
|
-
path: string;
|
|
6
|
-
backingFile?: string;
|
|
7
|
-
payload?: string;
|
|
8
|
-
writable?: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export declare class ReadWriteSpies {
|
|
14
|
-
readonly read: jest.SpyInstance;
|
|
15
|
-
readonly write: jest.SpyInstance;
|
|
16
|
-
constructor(read: jest.SpyInstance, write: jest.SpyInstance);
|
|
17
|
-
clear(): void;
|
|
18
|
-
restore(): void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export interface IMockFileSystemOptions {
|
|
24
|
-
mockWriteOnly?: boolean;
|
|
25
|
-
allowUnknownMockWrite?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
type ReadFunc = (path: string | number | Buffer | URL, options?: {
|
|
31
|
-
encoding?: null;
|
|
32
|
-
flag?: string;
|
|
33
|
-
} | null) => Buffer;
|
|
34
|
-
/**
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export declare class MockFileSystem {
|
|
38
|
-
protected readonly _options?: IMockFileSystemOptions;
|
|
39
|
-
protected readonly _config: Map<string, IMockFileConfig>;
|
|
40
|
-
protected readonly _data: Map<string, string>;
|
|
41
|
-
protected readonly _realReadFileSync: ReadFunc;
|
|
42
|
-
protected readonly _extraWrites: string[];
|
|
43
|
-
constructor(configs: Iterable<IMockFileConfig>, options?: IMockFileSystemOptions);
|
|
44
|
-
readMockFileSync(wanted: string): string;
|
|
45
|
-
writeMockFileSync(wanted: string, body: string): void;
|
|
46
|
-
getExtraFilesWritten(): string[];
|
|
47
|
-
tryGetPayload(want: string): string | undefined;
|
|
48
|
-
reset(): void;
|
|
49
|
-
startSpies(): ReadWriteSpies;
|
|
50
|
-
}
|
|
51
|
-
export {};
|
|
52
|
-
//# sourceMappingURL=fsHelpers.d.ts.map
|
|
@@ -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
|