@fgv/ts-utils-jest 2.0.1-alpha.0 → 2.1.0
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 +36 -0
- package/CHANGELOG.md +16 -1
- package/lib/helpers/fsHelpers.js +1 -1
- package/lib/helpers/fsHelpers.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/matchers/toSucceedAndSatisfy/index.js +1 -1
- package/lib/matchers/toSucceedAndSatisfy/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils/matcherHelpers.d.ts.map +1 -1
- package/lib/utils/matcherHelpers.js +1 -1
- package/lib/utils/matcherHelpers.js.map +1 -1
- package/package.json +25 -25
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-utils-jest",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "2.1.0",
|
|
6
|
+
"tag": "@fgv/ts-utils-jest_v2.1.0",
|
|
7
|
+
"date": "Tue, 31 Oct 2023 19:56:26 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "gitignore tweaks"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "fix types for ts-utils-jest"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"comment": "fix peers"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"comment": "bump versions"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"comment": "bump dependencies, fix tests"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"comment": "version upgrades"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"comment": "update dependencies"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"comment": "update peer dependencies"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"comment": "bump version"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
4
40
|
{
|
|
5
41
|
"version": "2.0.0",
|
|
6
42
|
"tag": "@fgv/ts-utils-jest_v2.0.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Change Log - @fgv/ts-utils-jest
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 31 Oct 2023 19:56:26 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 2.1.0
|
|
6
|
+
Tue, 31 Oct 2023 19:56:26 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- gitignore tweaks
|
|
11
|
+
- fix types for ts-utils-jest
|
|
12
|
+
- fix peers
|
|
13
|
+
- bump versions
|
|
14
|
+
- bump dependencies, fix tests
|
|
15
|
+
- version upgrades
|
|
16
|
+
- update dependencies
|
|
17
|
+
- update peer dependencies
|
|
18
|
+
- bump version
|
|
4
19
|
|
|
5
20
|
## 2.0.0
|
|
6
21
|
Mon, 10 Apr 2023 03:33:11 GMT
|
package/lib/helpers/fsHelpers.js
CHANGED
|
@@ -109,7 +109,7 @@ class MockFileSystem {
|
|
|
109
109
|
}
|
|
110
110
|
const payload = this._data.get(fullPathWanted);
|
|
111
111
|
// not actually reproducible right now
|
|
112
|
-
|
|
112
|
+
/* c8 ignore next 3 */
|
|
113
113
|
if (payload === undefined) {
|
|
114
114
|
throw new Error(`Mock file ${wanted} payload is undefined.`);
|
|
115
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fsHelpers.js","sourceRoot":"","sources":["../../src/helpers/fsHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,2CAA6B;AAY7B;;GAE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,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;aAC3D;SACF;QAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACzB;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,cAAc,CACvB,IAAI,CAAC,KAAK,CAAC,YAAE,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAe,EAAE,EAAE;YACpE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;gBAC9B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;aACtE;YACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC,EACF,IAAI,CAAC,KAAK,CAAC,YAAE,EAAE,eAAe,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAe,EAAE,OAAgB,EAAE,EAAE;YACvF,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;gBAC7D,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;aACvE;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AAxGD,wCAwGC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport fs from 'fs';\nimport * as path from 'path';\n\n/**\n * @public\n */\nexport interface IMockFileConfig {\n path: string;\n backingFile?: string;\n payload?: string;\n writable?: boolean;\n}\n\n/**\n * @public\n */\nexport class ReadWriteSpies {\n public readonly read: jest.SpyInstance;\n public readonly write: jest.SpyInstance;\n\n public constructor(read: jest.SpyInstance, write: jest.SpyInstance) {\n this.read = read;\n this.write = write;\n }\n\n public clear(): void {\n this.read.mockClear();\n this.write.mockClear();\n }\n\n public restore(): void {\n this.read.mockRestore();\n this.write.mockRestore();\n }\n}\n\n/**\n * @public\n */\nexport interface IMockFileSystemOptions {\n mockWriteOnly?: boolean;\n allowUnknownMockWrite?: boolean;\n}\n\n/**\n * @public\n */\n// eslint-disable-next-line @rushstack/no-new-null\ntype ReadFunc = (\n path: string | number | Buffer | URL,\n // eslint-disable-next-line @rushstack/no-new-null\n options?: { encoding?: null; flag?: string } | null\n) => Buffer;\n\n/**\n * @public\n */\nexport class MockFileSystem {\n protected readonly _options?: IMockFileSystemOptions;\n protected readonly _config: Map<string, IMockFileConfig>;\n protected readonly _data: Map<string, string>;\n protected readonly _realReadFileSync: ReadFunc;\n protected readonly _extraWrites: string[] = [];\n\n public constructor(configs: Iterable<IMockFileConfig>, options?: IMockFileSystemOptions) {\n this._config = new Map<string, IMockFileConfig>();\n this._data = new Map<string, string>();\n this._options = options;\n this._realReadFileSync = fs.readFileSync;\n\n for (const config of configs) {\n const fullPath = path.resolve(config.path);\n this._config.set(fullPath, config);\n if (config.backingFile) {\n this.readMockFileSync(fullPath);\n } else if (config.payload) {\n this._data.set(fullPath, config.payload);\n }\n }\n }\n\n public readMockFileSync(wanted: string): string {\n const fullPathWanted = path.resolve(wanted);\n if (!this._data.has(fullPathWanted)) {\n const config = this._config.get(fullPathWanted);\n if (config?.backingFile === undefined) {\n if (this._options?.mockWriteOnly !== true) {\n throw new Error(`Mock file not found: ${wanted}`);\n }\n const body = this._realReadFileSync(fullPathWanted).toString();\n this._data.set(fullPathWanted, body);\n } else {\n const fullBackingPath = path.resolve(config.backingFile);\n const body = this._realReadFileSync(fullBackingPath).toString();\n this._data.set(fullPathWanted, body);\n }\n }\n\n const payload = this._data.get(fullPathWanted);\n // not actually reproducible right now\n // istanbul ignore next\n if (payload === undefined) {\n throw new Error(`Mock file ${wanted} payload is undefined.`);\n }\n return payload;\n }\n\n public writeMockFileSync(wanted: string, body: string): void {\n const fullPathWanted = path.resolve(wanted);\n const config = this._config.get(fullPathWanted);\n if (config === undefined) {\n if (this._options?.allowUnknownMockWrite !== true) {\n throw new Error(`Mock path not found: ${wanted}`);\n }\n this._extraWrites.push(fullPathWanted);\n } else if (config.writable !== true) {\n throw new Error(`Mock permission denied: ${wanted}`);\n }\n this._data.set(fullPathWanted, body);\n }\n\n public getExtraFilesWritten(): string[] {\n return Array.from(this._extraWrites);\n }\n public tryGetPayload(want: string): string | undefined {\n return this._data.get(path.resolve(want));\n }\n\n public reset(): void {\n const writable = Array.from(this._config.values()).filter((c) => c.writable === true);\n for (const config of writable) {\n this._data.delete(path.resolve(config.path));\n if (config.backingFile) {\n this.readMockFileSync(path.resolve(config.path));\n } else if (config.payload) {\n this._data.set(path.resolve(config.path), config.payload);\n }\n }\n\n for (const path of this._extraWrites) {\n this._data.delete(path);\n }\n this._extraWrites.splice(0, this._extraWrites.length);\n }\n\n public startSpies(): ReadWriteSpies {\n return new ReadWriteSpies(\n jest.spyOn(fs, 'readFileSync').mockImplementation((wanted: unknown) => {\n if (typeof wanted !== 'string') {\n throw new Error('readFileSync mock supports only string parameters');\n }\n return this.readMockFileSync(wanted);\n }),\n jest.spyOn(fs, 'writeFileSync').mockImplementation((wanted: unknown, payload: unknown) => {\n if (typeof wanted !== 'string' || typeof payload !== 'string') {\n throw new Error('writeFileSync mock supports only string parameters');\n }\n return this.writeMockFileSync(wanted, payload);\n })\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fsHelpers.js","sourceRoot":"","sources":["../../src/helpers/fsHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,2CAA6B;AAY7B;;GAEG;AACH,MAAa,cAAc;IAIzB,YAAmB,IAAsB,EAAE,KAAuB;QAChE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;IACzB,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;CACF;AAlBD,wCAkBC;AAoBD;;GAEG;AACH,MAAa,cAAc;IAOzB,YAAmB,OAAkC,EAAE,OAAgC;QAFpE,iBAAY,GAAa,EAAE,CAAC;QAG7C,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;QACvC,IAAI,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AAC,CAAC;QACvC,CAAC,CAAC,EACF,IAAI,CAAC,KAAK,CAAC,YAAE,EAAE,eAAe,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAe,EAAE,OAAgB,EAAE,EAAE;YACvF,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;gBAC7D,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;aACvE;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AAxGD,wCAwGC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport fs from 'fs';\nimport * as path from 'path';\n\n/**\n * @public\n */\nexport interface IMockFileConfig {\n path: string;\n backingFile?: string;\n payload?: string;\n writable?: boolean;\n}\n\n/**\n * @public\n */\nexport class ReadWriteSpies {\n public readonly read: jest.SpyInstance;\n public readonly write: jest.SpyInstance;\n\n public constructor(read: jest.SpyInstance, write: jest.SpyInstance) {\n this.read = read;\n this.write = write;\n }\n\n public clear(): void {\n this.read.mockClear();\n this.write.mockClear();\n }\n\n public restore(): void {\n this.read.mockRestore();\n this.write.mockRestore();\n }\n}\n\n/**\n * @public\n */\nexport interface IMockFileSystemOptions {\n mockWriteOnly?: boolean;\n allowUnknownMockWrite?: boolean;\n}\n\n/**\n * @public\n */\n// eslint-disable-next-line @rushstack/no-new-null\ntype ReadFunc = (\n path: string | number | Buffer | URL,\n // eslint-disable-next-line @rushstack/no-new-null\n options?: { encoding?: null; flag?: string } | null\n) => Buffer;\n\n/**\n * @public\n */\nexport class MockFileSystem {\n protected readonly _options?: IMockFileSystemOptions;\n protected readonly _config: Map<string, IMockFileConfig>;\n protected readonly _data: Map<string, string>;\n protected readonly _realReadFileSync: ReadFunc;\n protected readonly _extraWrites: string[] = [];\n\n public constructor(configs: Iterable<IMockFileConfig>, options?: IMockFileSystemOptions) {\n this._config = new Map<string, IMockFileConfig>();\n this._data = new Map<string, string>();\n this._options = options;\n this._realReadFileSync = fs.readFileSync;\n\n for (const config of configs) {\n const fullPath = path.resolve(config.path);\n this._config.set(fullPath, config);\n if (config.backingFile) {\n this.readMockFileSync(fullPath);\n } else if (config.payload) {\n this._data.set(fullPath, config.payload);\n }\n }\n }\n\n public readMockFileSync(wanted: string): string {\n const fullPathWanted = path.resolve(wanted);\n if (!this._data.has(fullPathWanted)) {\n const config = this._config.get(fullPathWanted);\n if (config?.backingFile === undefined) {\n if (this._options?.mockWriteOnly !== true) {\n throw new Error(`Mock file not found: ${wanted}`);\n }\n const body = this._realReadFileSync(fullPathWanted).toString();\n this._data.set(fullPathWanted, body);\n } else {\n const fullBackingPath = path.resolve(config.backingFile);\n const body = this._realReadFileSync(fullBackingPath).toString();\n this._data.set(fullPathWanted, body);\n }\n }\n\n const payload = this._data.get(fullPathWanted);\n // not actually reproducible right now\n /* c8 ignore next 3 */\n if (payload === undefined) {\n throw new Error(`Mock file ${wanted} payload is undefined.`);\n }\n return payload;\n }\n\n public writeMockFileSync(wanted: string, body: string): void {\n const fullPathWanted = path.resolve(wanted);\n const config = this._config.get(fullPathWanted);\n if (config === undefined) {\n if (this._options?.allowUnknownMockWrite !== true) {\n throw new Error(`Mock path not found: ${wanted}`);\n }\n this._extraWrites.push(fullPathWanted);\n } else if (config.writable !== true) {\n throw new Error(`Mock permission denied: ${wanted}`);\n }\n this._data.set(fullPathWanted, body);\n }\n\n public getExtraFilesWritten(): string[] {\n return Array.from(this._extraWrites);\n }\n public tryGetPayload(want: string): string | undefined {\n return this._data.get(path.resolve(want));\n }\n\n public reset(): void {\n const writable = Array.from(this._config.values()).filter((c) => c.writable === true);\n for (const config of writable) {\n this._data.delete(path.resolve(config.path));\n if (config.backingFile) {\n this.readMockFileSync(path.resolve(config.path));\n } else if (config.payload) {\n this._data.set(path.resolve(config.path), config.payload);\n }\n }\n\n for (const path of this._extraWrites) {\n this._data.delete(path);\n }\n this._extraWrites.splice(0, this._extraWrites.length);\n }\n\n public startSpies(): ReadWriteSpies {\n return new ReadWriteSpies(\n jest.spyOn(fs, 'readFileSync').mockImplementation((wanted: unknown) => {\n if (typeof wanted !== 'string') {\n throw new Error('readFileSync mock supports only string parameters');\n }\n return this.readMockFileSync(wanted);\n }),\n jest.spyOn(fs, 'writeFileSync').mockImplementation((wanted: unknown, payload: unknown) => {\n if (typeof wanted !== 'string' || typeof payload !== 'string') {\n throw new Error('writeFileSync mock supports only string parameters');\n }\n return this.writeMockFileSync(wanted, payload);\n })\n );\n }\n}\n"]}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAkC;AAClC,mBAAiB;AAEjB,4DAA8C;AACrC,wBAAM;AAKf,oCAAoC;AACpC,SAAS,YAAY,CAAC,CAAgB;IACpC,OAAO,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAkC;AAClC,mBAAiB;AAEjB,4DAA8C;AACrC,wBAAM;AAKf,oCAAoC;AACpC,SAAS,YAAY,CAAC,CAAgB;IACpC,OAAO,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED,oBAAoB;AACpB,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE;IACxB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAC;CAChC;KAAM;IACL,+BAA+B;IAC/B,OAAO,CAAC,KAAK,CACX;QACE,qCAAqC;QACrC,sFAAsF;KACvF,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,8BAA8B;CAC/B","sourcesContent":["import matchers from './matchers';\nimport './types';\n\nimport * as MockFs from './helpers/fsHelpers';\nexport { MockFs };\n\n// eslint-disable-next-line no-undef\ntype JestGlobal = typeof global & { expect: jest.Expect };\n\n// eslint-disable-next-line no-undef\nfunction isJestGlobal(g: typeof global): g is JestGlobal {\n return g.hasOwnProperty('expect');\n}\n\n/* c8 ignore else */\nif (isJestGlobal(global)) {\n global.expect.extend(matchers);\n} else {\n /* eslint-disable no-console */\n console.error(\n [\n \"Unable to find Jest's global expect\",\n 'Please check that you have added ts-utils-jest correctly to your jest configuration.'\n ].join('\\n')\n );\n /* eslint-enable no-console */\n}\n"]}
|
|
@@ -16,7 +16,7 @@ function passMessage(received) {
|
|
|
16
16
|
function failMessage(received, cbResult) {
|
|
17
17
|
const expected = 'successful callback';
|
|
18
18
|
const got = [(0, matcherHelpers_1.printReceivedResult)(received)];
|
|
19
|
-
|
|
19
|
+
/* c8 ignore else */
|
|
20
20
|
if (cbResult.isFailure()) {
|
|
21
21
|
got.push(cbResult.message);
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndSatisfy/index.ts"],"names":[],"mappings":";;AACA,+DAAsF;AACtF,2CAAqD;AAErD,2DAAiD;AAkBjD,SAAS,WAAW,CAAI,QAAmB;IACzC,MAAM,QAAQ,GAAG,qBAAqB,CAAC;IACvC,MAAM,GAAG,GAAG,CAAC,IAAA,oCAAmB,EAAC,QAAQ,CAAC,CAAC,CAAC;IAC5C,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAErC,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC;QACxD,IAAA,oCAAmB,EAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;QAC/C,GAAG,GAAG;KACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAI,QAAmB,EAAE,QAAgC;IAC3E,MAAM,QAAQ,GAAG,qBAAqB,CAAC;IACvC,MAAM,GAAG,GAAG,CAAC,IAAA,oCAAmB,EAAC,QAAQ,CAAC,CAAC,CAAC;IAE5C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndSatisfy/index.ts"],"names":[],"mappings":";;AACA,+DAAsF;AACtF,2CAAqD;AAErD,2DAAiD;AAkBjD,SAAS,WAAW,CAAI,QAAmB;IACzC,MAAM,QAAQ,GAAG,qBAAqB,CAAC;IACvC,MAAM,GAAG,GAAG,CAAC,IAAA,oCAAmB,EAAC,QAAQ,CAAC,CAAC,CAAC;IAC5C,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAErC,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,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AAO,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,EAAE,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC;QAC7D,IAAI,IAAI,EAAE;YACR,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;SACvD;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;IACnE,CAAC;CACF,CAAC","sourcesContent":["import { Result, ResultValueType } from '@fgv/ts-utils';\nimport { printExpectedResult, printReceivedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars, @typescript-eslint/ban-types, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceedAndSatisfy to verify that a Result<T> is a success\n * and that the supplied test function returns true (or void)\n * for the resulting value\n * @param test -\n */\n toSucceedAndSatisfy(test: (value: ResultValueType<T>) => boolean | void): R;\n }\n }\n}\n\nfunction passMessage<T>(received: Result<T>): () => string {\n const expected = 'successful callback';\n const got = [printReceivedResult(received)];\n got.push(' Callback returned true');\n\n return () =>\n [\n matcherHint(`.not.${matcherName}`, 'result', 'callback'),\n printExpectedResult('success', false, expected),\n ...got\n ].join('\\n');\n}\n\nfunction failMessage<T>(received: Result<T>, cbResult: Result<boolean | void>): () => string {\n const expected = 'successful callback';\n const got = [printReceivedResult(received)];\n\n /* c8 ignore else */\n if (cbResult.isFailure()) {\n got.push(cbResult.message);\n } else if (cbResult.value === false) {\n got.push(' Callback returned false');\n } else if (cbResult.value === undefined) {\n got.push(' Callback was not invoked');\n } else {\n throw new Error('Internal error: toSucceedAndSatisfy.failMessage passed success with true');\n }\n\n return () =>\n [\n matcherHint(`${matcherName}`, 'result', 'callback'),\n printExpectedResult('success', true, expected),\n ...got\n ].join('\\n');\n}\n\nexport default {\n toSucceedAndSatisfy: function <T>(\n this: jest.MatcherContext,\n received: Result<T>,\n test: (value: T) => boolean | void\n ): jest.CustomMatcherResult {\n // For the normal (not '.not') case, we do not want to capture exceptions\n // so that the IDE can display exactly the line on which the failure case.\n // For the .not case, we want to swallow exceptions or expect failures since\n // we're just testing failure and not the reason.\n const capture = this.isNot;\n const cbResult = predicate(received, test, !!capture);\n const pass = cbResult.isSuccess() && cbResult.value === true;\n if (pass) {\n return { pass: true, message: passMessage(received) };\n }\n\n return { pass: false, message: failMessage(received, cbResult) };\n }\n};\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matcherHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/matcherHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"matcherHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/matcherHelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,MAAM,CAW1G;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,EAAE,EAC/C,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,KAAK,EAAE,OAAO,EACd,eAAe,CAAC,EAAE,CAAC,EACnB,cAAc,CAAC,EAAE,EAAE,GAClB,MAAM,CAaR;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAOlE;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAO1F"}
|
|
@@ -19,7 +19,7 @@ function printExpectedResult(expect, isNot, expected) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.printExpectedResult = printExpectedResult;
|
|
21
21
|
function printExpectedDetailedResult(expect, isNot, expectedMessage, expectedDetail) {
|
|
22
|
-
|
|
22
|
+
/* c8 ignore next */
|
|
23
23
|
return [
|
|
24
24
|
'Expected:',
|
|
25
25
|
isNot
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matcherHelpers.js","sourceRoot":"","sources":["../../src/utils/matcherHelpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"matcherHelpers.js","sourceRoot":"","sources":["../../src/utils/matcherHelpers.ts"],"names":[],"mappings":";;;AAAA,2DAAkE;AAGlE,SAAS,kBAAkB,CAAI,OAAe,EAAE,QAAY;IAC1D,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,IAAA,kCAAa,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;AAClG,CAAC;AAED,SAAgB,mBAAmB,CAAI,MAA6B,EAAE,KAAc,EAAE,QAAY;IAChG,OAAO;QACL,WAAW;QACX,KAAK;YACH,CAAC,CAAC,MAAM,KAAK,SAAS;gBACpB,CAAC,CAAC,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC;gBACzC,CAAC,CAAC,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC;YAC3C,CAAC,CAAC,MAAM,KAAK,SAAS;gBACtB,CAAC,CAAC,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC;gBAC7C,CAAC,CAAC,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC;KAChD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAXD,kDAWC;AAED,SAAgB,2BAA2B,CACzC,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port { DetailedResult, Result } from '../ts-utils';\n\nfunction printExpectedValue<T>(outcome: string, expected?: T): string {\n return expected !== undefined ? ` ${outcome} with ${printExpected(expected)}` : ` ${outcome}`;\n}\n\nexport function printExpectedResult<T>(expect: 'success' | 'failure', isNot: boolean, expected?: T): string {\n return [\n 'Expected:',\n isNot\n ? expect === 'success'\n ? printExpectedValue('Success', expected)\n : printExpectedValue('Failure', expected)\n : expect === 'success'\n ? printExpectedValue('Not success', expected)\n : printExpectedValue('Not failure', expected)\n ].join('\\n');\n}\n\nexport function printExpectedDetailedResult<T, TD>(\n expect: 'success' | 'failure',\n isNot: boolean,\n expectedMessage?: T,\n expectedDetail?: TD\n): string {\n /* c8 ignore next */\n return [\n 'Expected:',\n isNot\n ? expect === 'success'\n ? printExpectedValue('Success', expectedMessage)\n : printExpectedValue('Failure', expectedMessage)\n : expect === 'success'\n ? printExpectedValue('Not success', expectedMessage)\n : printExpectedValue('Not failure', expectedMessage),\n ` Detail: \"${printExpected(expectedDetail)}\"`\n ].join('\\n');\n}\n\nexport function printReceivedResult<T>(received: Result<T>): string {\n return [\n 'Received:',\n received.isSuccess()\n ? ` Success with ${printReceived(received.value)}`\n : ` Failure with \"${received.message}\"`\n ].join('\\n');\n}\n\nexport function printReceivedDetailedResult<T, TD>(received: DetailedResult<T, TD>): string {\n return [\n 'Received:',\n received.isSuccess()\n ? ` Success with \"${printReceived(received.value)}\"\\n Detail: \"${printReceived(received.detail)}\"`\n : ` Failure with \"${received.message}\"\\n Detail: \"${printReceived(received.detail)}\"`\n ].join('\\n');\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-utils-jest",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Custom matchers for ts-utils result class",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -11,38 +11,38 @@
|
|
|
11
11
|
"author": "Erik Fortune",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@jest/expect-utils": "^29.
|
|
15
|
-
"@rushstack/eslint-config": "~3.
|
|
16
|
-
"@rushstack/heft": "~0.
|
|
17
|
-
"@rushstack/heft-jest-plugin": "~0.
|
|
18
|
-
"@rushstack/heft-node-rig": "~
|
|
19
|
-
"@types/heft-jest": "1.0.
|
|
20
|
-
"eslint-plugin-n": "^
|
|
14
|
+
"@jest/expect-utils": "^29.7.0",
|
|
15
|
+
"@rushstack/eslint-config": "~3.4.1",
|
|
16
|
+
"@rushstack/heft": "~0.63.0",
|
|
17
|
+
"@rushstack/heft-jest-plugin": "~0.10.2",
|
|
18
|
+
"@rushstack/heft-node-rig": "~2.3.8",
|
|
19
|
+
"@types/heft-jest": "1.0.5",
|
|
20
|
+
"eslint-plugin-n": "^16.2.0",
|
|
21
21
|
"eslint-plugin-tsdoc": "~0.2.17",
|
|
22
|
-
"expect": "^29.
|
|
23
|
-
"jest-matcher-utils": "^29.
|
|
24
|
-
"jest-snapshot": "~29.
|
|
22
|
+
"expect": "^29.7.0",
|
|
23
|
+
"jest-matcher-utils": "^29.7.0",
|
|
24
|
+
"jest-snapshot": "~29.7.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@fgv/ts-utils": "2.
|
|
28
|
-
"@types/jest": "^29.5.
|
|
29
|
-
"@types/node": "^
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
31
|
-
"@typescript-eslint/parser": "^
|
|
32
|
-
"eslint": "^8.
|
|
33
|
-
"eslint-config-standard": "^17.
|
|
34
|
-
"eslint-plugin-import": "^2.
|
|
27
|
+
"@fgv/ts-utils": "2.1.0",
|
|
28
|
+
"@types/jest": "^29.5.7",
|
|
29
|
+
"@types/node": "^20.8.9",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
31
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
32
|
+
"eslint": "^8.52.0",
|
|
33
|
+
"eslint-config-standard": "^17.1.0",
|
|
34
|
+
"eslint-plugin-import": "^2.29.0",
|
|
35
35
|
"eslint-plugin-node": "^11.1.0",
|
|
36
36
|
"eslint-plugin-promise": "^6.1.1",
|
|
37
|
-
"jest": "^29.
|
|
38
|
-
"prettier": "^
|
|
39
|
-
"rimraf": "^
|
|
40
|
-
"ts-jest": "^29.
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"prettier": "^3.0.3",
|
|
39
|
+
"rimraf": "^5.0.5",
|
|
40
|
+
"ts-jest": "^29.1.1",
|
|
41
41
|
"ts-node": "^10.9.1",
|
|
42
|
-
"typescript": "^
|
|
42
|
+
"typescript": "^5.2.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@fgv/ts-utils": "^2.
|
|
45
|
+
"@fgv/ts-utils": "^2.1.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "heft build",
|