@approval-tests/approvals 7.5.11 → 7.5.13

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.
Files changed (68) hide show
  1. package/bin/index.d.ts +1 -1
  2. package/bin/index.js +1 -1
  3. package/package.json +9 -4
  4. package/bin/index.ts +0 -108
  5. package/lib/AUtils.ts +0 -178
  6. package/lib/Approvals.ts +0 -321
  7. package/lib/Core/Namer.ts +0 -14
  8. package/lib/Core/Options.ts +0 -94
  9. package/lib/Core/Reporter.ts +0 -13
  10. package/lib/Core/Writer.ts +0 -5
  11. package/lib/FileApprover.ts +0 -116
  12. package/lib/FinalMessages.ts +0 -16
  13. package/lib/Logs/ApprovedFileLog.ts +0 -38
  14. package/lib/Logs/FailedFileLog.ts +0 -36
  15. package/lib/Logs/LogUtils.ts +0 -44
  16. package/lib/ManualNamer.ts +0 -12
  17. package/lib/Namer.ts +0 -28
  18. package/lib/Providers/BeforeEachVerifierBase.ts +0 -68
  19. package/lib/Providers/Jest/CombinationApprovals.ts +0 -161
  20. package/lib/Providers/Jest/JestApprovals.ts +0 -50
  21. package/lib/Providers/Jest/JestNamer.ts +0 -15
  22. package/lib/Providers/Jest/JestReporter.ts +0 -25
  23. package/lib/Providers/Jest/JestSetup.ts +0 -40
  24. package/lib/Providers/Mocha/MochaApprovals.ts +0 -74
  25. package/lib/Providers/Mocha/MochaNamer.ts +0 -84
  26. package/lib/Providers/OptionalFramework.ts +0 -11
  27. package/lib/Providers/Vitest/VitestApprovals.ts +0 -39
  28. package/lib/Providers/Vitest/VitestNamer.ts +0 -27
  29. package/lib/Providers/Vitest/VitestReporter.ts +0 -25
  30. package/lib/Reporting/DiffReporterAggregate.ts +0 -36
  31. package/lib/Reporting/GenericDiffReporterBase.ts +0 -154
  32. package/lib/Reporting/ReportByOpeningTheReceivedFile.ts +0 -22
  33. package/lib/Reporting/ReportLaunchingCircuitBreaker.ts +0 -40
  34. package/lib/Reporting/ReporterFactory.ts +0 -85
  35. package/lib/Reporting/Reporters/beyondcompareReporter.ts +0 -30
  36. package/lib/Reporting/Reporters/codiumReporter.ts +0 -26
  37. package/lib/Reporting/Reporters/copycommandReporter.ts +0 -46
  38. package/lib/Reporting/Reporters/diffmergeReporter.ts +0 -25
  39. package/lib/Reporting/Reporters/donothingReporter.ts +0 -13
  40. package/lib/Reporting/Reporters/gitdiffReporter.ts +0 -28
  41. package/lib/Reporting/Reporters/icdiffReporter.ts +0 -10
  42. package/lib/Reporting/Reporters/kdiff3Reporter.ts +0 -10
  43. package/lib/Reporting/Reporters/kompareReporter.ts +0 -10
  44. package/lib/Reporting/Reporters/meldReporter.ts +0 -10
  45. package/lib/Reporting/Reporters/multiReporter.ts +0 -55
  46. package/lib/Reporting/Reporters/nodediffReporter.ts +0 -61
  47. package/lib/Reporting/Reporters/opendiffReporter.ts +0 -10
  48. package/lib/Reporting/Reporters/p4mergeReporter.ts +0 -39
  49. package/lib/Reporting/Reporters/tortoisemergeReporter.ts +0 -25
  50. package/lib/Reporting/Reporters/vimdiffReporter.ts +0 -25
  51. package/lib/Reporting/Reporters/visualstudioReporter.ts +0 -48
  52. package/lib/Reporting/Reporters/vscodeReporter.ts +0 -26
  53. package/lib/Scrubbers/DateScrubber.ts +0 -83
  54. package/lib/Scrubbers/Scrubbers.ts +0 -106
  55. package/lib/StringWriter.ts +0 -73
  56. package/lib/Utilities/ConsoleUtils.ts +0 -15
  57. package/lib/Utilities/JestUtils.ts +0 -5
  58. package/lib/Utilities/Logger/LoggingInstance.ts +0 -247
  59. package/lib/Utilities/Logger/SimpleLogger.ts +0 -83
  60. package/lib/Utilities/Logger/SimpleLoggerApprovals.ts +0 -15
  61. package/lib/Utilities/Logger/StringWrapper.ts +0 -12
  62. package/lib/Utilities/Logger/Wrapper.ts +0 -27
  63. package/lib/Utilities/Printers.ts +0 -77
  64. package/lib/Utilities/StringUtils.ts +0 -8
  65. package/lib/Writers/BinaryWriter.ts +0 -42
  66. package/lib/config.ts +0 -95
  67. package/lib/osTools.ts +0 -11
  68. package/lib/postRunCleanup.ts +0 -63
@@ -1,94 +0,0 @@
1
- import type { Scrubber } from "../Scrubbers/Scrubbers";
2
- import { Namer } from "../Namer";
3
- import { Namer as CoreNamer } from "./Namer";
4
- import { Config } from "../config";
5
- import { Reporter } from "./Reporter";
6
- export type ConfigModifier = (t: any) => any;
7
-
8
- class FileOptions {
9
- private options: Options;
10
-
11
- constructor(options: Options) {
12
- this.options = options;
13
- }
14
-
15
- /** @deprecated Use withFileExtension instead. This method has a typo and will be removed in a future version. */
16
- withFileExtention(extensionWithDot: string): Options {
17
- return this.withFileExtension(extensionWithDot);
18
- }
19
- withFileExtension(extensionWithDot: string): Options {
20
- return this.options.modify("FileExtension", extensionWithDot);
21
- }
22
-
23
- getFileExtension(): string {
24
- return this.options.get("FileExtension", () => ".txt");
25
- }
26
- }
27
-
28
- export class Options {
29
- protected fields: { [n: string]: any };
30
-
31
- constructor() {
32
- this.fields = {};
33
- }
34
-
35
- modify(key: string, value: any): Options {
36
- const next = new Options();
37
- for (const key1 in this.fields) {
38
- next.fields[key1] = this.fields[key1];
39
- }
40
- next.fields[key] = value;
41
- return next;
42
- }
43
-
44
- forFile(): FileOptions {
45
- return new FileOptions(this);
46
- }
47
-
48
- get<Type>(key: string, default1: () => Type): Type {
49
- if (this.fields[key] == undefined) {
50
- return default1();
51
- }
52
- return this.fields[key];
53
- }
54
-
55
- withScrubber(scrubber: Scrubber): Options {
56
- return this.modify("Scrubber", scrubber);
57
- }
58
-
59
- getScrubber(): Scrubber {
60
- return this.get("Scrubber", () => (t) => t);
61
- }
62
-
63
- scrub(text: string): string {
64
- const scrubber = this.getScrubber();
65
- return scrubber(text);
66
- }
67
-
68
- withConfig(configModifier: ConfigModifier): Options {
69
- return this.modify("ConfigModifier", configModifier);
70
- }
71
-
72
- getConfig(config: any): Config {
73
- const modifier = this.get("ConfigModifier", () => (t: any) => t);
74
- return modifier(config);
75
- }
76
-
77
- withNamer(namer: CoreNamer): Options {
78
- return this.modify("Namer", namer);
79
- }
80
-
81
- getNamer(): CoreNamer {
82
- return this.get("Namer", () => new Namer("", ""));
83
- }
84
-
85
- withReporter(reporter: Reporter): Options {
86
- const previousModifier = this.get("ConfigModifier", () => (t: any) => t);
87
- const previousModifierWithReporter: ConfigModifier = (c) => {
88
- c = previousModifier(c);
89
- c.reporters = [reporter];
90
- return c;
91
- };
92
- return this.withConfig(previousModifierWithReporter);
93
- }
94
- }
@@ -1,13 +0,0 @@
1
- import { Config } from "../config";
2
-
3
- export interface Reporter {
4
- name: string;
5
-
6
- canReportOn(fileName: string): boolean;
7
-
8
- report(
9
- approvedFileName: string,
10
- receivedFileName: string,
11
- options?: Partial<Config>,
12
- ): void;
13
- }
@@ -1,5 +0,0 @@
1
- export interface Writer {
2
- getFileExtension(): string;
3
-
4
- write(filePath: string): void;
5
- }
@@ -1,116 +0,0 @@
1
- import fs from "fs";
2
- import { Config } from "./config";
3
- import { Namer } from "./Core/Namer";
4
- import { Writer } from "./Core/Writer";
5
- import { Reporter } from "./Core/Reporter";
6
- import { ReporterLoader } from "./Reporting/ReporterFactory";
7
- import { yellowText } from "./Utilities/ConsoleUtils";
8
- import { ApprovedFileLog } from "./Logs/ApprovedFileLog";
9
- import { FailedFileLog } from "./Logs/FailedFileLog";
10
-
11
- function normalizeLineEndings(value: string): string {
12
- return value.replace(/(?:\r\n|\r|\n)/g, "\n");
13
- }
14
-
15
- export class FileApprover {
16
- static verify(
17
- namer: Namer,
18
- writer: Writer,
19
- reporterFactory: ReporterLoader,
20
- options?: Partial<Config>,
21
- ): void {
22
- if (!namer || !writer || !reporterFactory) {
23
- const missing = [
24
- !namer ? "namer" : null,
25
- !writer ? "writer" : null,
26
- !reporterFactory ? "reporterFactory" : null,
27
- ]
28
- .filter(Boolean)
29
- .join(", ");
30
- throw new Error(`Missing required arguments: ${missing}.`);
31
- }
32
- if (!options) {
33
- options = {};
34
- }
35
-
36
- const approvedFileName = namer.getApprovedFile(writer.getFileExtension());
37
- const receivedFileName = namer.getReceivedFile(writer.getFileExtension());
38
- FailedFileLog.touch();
39
- ApprovedFileLog.log(approvedFileName);
40
- writer.write(receivedFileName);
41
-
42
- if (options.forceApproveAll) {
43
- console.log(yellowText(`WARNING: Force approving: ${approvedFileName}`));
44
- writer.write(approvedFileName);
45
- }
46
-
47
- const selectFirstCompatibleReporter = (): Reporter => {
48
- const allReporters = reporterFactory();
49
- const reporter = allReporters.find((reporter) =>
50
- reporter.canReportOn(receivedFileName),
51
- );
52
- if (!reporter) {
53
- throw new Error(
54
- `No compatible reporter found in configured list [${allReporters.map((r) => r.name).join(", ")}] for: ${receivedFileName}`,
55
- );
56
- }
57
- return reporter;
58
- };
59
-
60
- const throwReporterError = (msg: string): never => {
61
- FailedFileLog.log(approvedFileName, receivedFileName);
62
- const reporter = selectFirstCompatibleReporter();
63
- try {
64
- reporter.report(approvedFileName, receivedFileName, options);
65
- } catch (ex) {
66
- const reporterError = `Error raised by reporter [${reporter.name}]: ${ex}`;
67
- throw new Error(
68
- `${reporterError}\n${msg}\nApproved: ${approvedFileName}\nReceived: ${receivedFileName}`,
69
- );
70
- }
71
- throw new Error(msg);
72
- };
73
-
74
- if (!fs.existsSync(approvedFileName)) {
75
- throwReporterError(`Approved file does not exist: ${approvedFileName}`);
76
- }
77
-
78
- let approvedFileContents = fs.readFileSync(approvedFileName, "utf8") || "";
79
- let receivedFileContents = fs.readFileSync(receivedFileName, "utf8") || "";
80
-
81
- if (options.stripBOM) {
82
- approvedFileContents = approvedFileContents.replace(/^\uFEFF/, "");
83
- receivedFileContents = receivedFileContents.replace(/^\uFEFF/, "");
84
- }
85
-
86
- if (
87
- options.failOnLineEndingDifferences &&
88
- approvedFileContents !== receivedFileContents
89
- ) {
90
- throwReporterError("Files do not match.");
91
- }
92
-
93
- const approvedFileBufferNormalized =
94
- normalizeLineEndings(approvedFileContents);
95
- const receivedFileBufferNormalized =
96
- normalizeLineEndings(receivedFileContents);
97
-
98
- if (approvedFileBufferNormalized !== receivedFileBufferNormalized) {
99
- throwReporterError("Files do not match.");
100
- }
101
-
102
- // Delete the received file
103
- fs.unlinkSync(receivedFileName);
104
-
105
- (process.emit as Function)("approvalFileApproved", approvedFileName);
106
- }
107
- }
108
-
109
- export function verify(
110
- namer: Namer,
111
- writer: Writer,
112
- reporterFactory: () => Reporter[],
113
- options?: Partial<Config>,
114
- ): void {
115
- FileApprover.verify(namer, writer, reporterFactory, options);
116
- }
@@ -1,16 +0,0 @@
1
- const messages: string[] = [];
2
-
3
- export class FinalMessages {
4
- static addMessage(message) {
5
- messages.push(message);
6
- }
7
-
8
- static addKeyMessage(key, message) {
9
- messages[key] = message;
10
- }
11
-
12
- static getMessages() {
13
- //return messages;
14
- return Object.keys(messages).map((x) => messages[x]);
15
- }
16
- }
@@ -1,38 +0,0 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import { JestUtils } from "../Utilities/JestUtils";
4
- import { helpUserSetupJest } from "../Providers/Jest/JestSetup";
5
- import { LogUtils } from "./LogUtils";
6
-
7
- let runOnce = false;
8
- export class ApprovedFileLog {
9
- private static clearLogFile(): void {
10
- if (runOnce) {
11
- return;
12
- }
13
- if (JestUtils.isJestRunning()) {
14
- helpUserSetupJest(this.getLogFilePath());
15
- return;
16
- }
17
- runOnce = true;
18
- this.forceClearLogFile();
19
- }
20
-
21
- public static forceClearLogFile() {
22
- const logFilePath = this.getLogFilePath();
23
- fs.writeFileSync(logFilePath, "");
24
- }
25
-
26
- private static getLogFilePath(): string {
27
- return path.join(
28
- LogUtils.ensureTempDirectoryExists(),
29
- ".approved_files.log",
30
- );
31
- }
32
-
33
- public static log(filePath: string): void {
34
- this.clearLogFile();
35
- const logFilePath = this.getLogFilePath();
36
- fs.appendFileSync(logFilePath, filePath + "\n");
37
- }
38
- }
@@ -1,36 +0,0 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import { JestUtils } from "../Utilities/JestUtils";
4
- import { LogUtils } from "./LogUtils";
5
-
6
- let runOnce = false;
7
- export class FailedFileLog {
8
- private static clearLogFile(): void {
9
- if (!runOnce || JestUtils.isJestRunning()) {
10
- return;
11
- }
12
- runOnce = true;
13
- this.forceClearFileLog();
14
- }
15
-
16
- public static forceClearFileLog() {
17
- fs.writeFileSync(this.getLogFilePath(), "");
18
- }
19
-
20
- public static getLogFilePath(): string {
21
- return path.join(
22
- LogUtils.ensureTempDirectoryExists(),
23
- ".failed_comparison.log",
24
- );
25
- }
26
-
27
- public static log(approved: string, received: string): void {
28
- const logFilePath = this.getLogFilePath();
29
- const logEntry = `${received} -> ${approved}\n`;
30
- fs.appendFileSync(logFilePath, logEntry);
31
- }
32
-
33
- public static touch(): void {
34
- this.clearLogFile();
35
- }
36
- }
@@ -1,44 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import axios from "axios";
4
-
5
- export class LogUtils {
6
- private static runOnce: boolean = false;
7
- public static readonly APPROVAL_TEMP_DIRECTORY: string =
8
- ".approval_tests_temp";
9
-
10
- public static ensureTempDirectoryExists() {
11
- if (this.runOnce) {
12
- return this.APPROVAL_TEMP_DIRECTORY;
13
- }
14
- this.runOnce = true;
15
-
16
- if (!fs.existsSync(this.APPROVAL_TEMP_DIRECTORY)) {
17
- fs.mkdirSync(this.APPROVAL_TEMP_DIRECTORY);
18
- }
19
- this.downloadApproveAllScriptIfMissing().then();
20
- return this.APPROVAL_TEMP_DIRECTORY;
21
- }
22
-
23
- private static async downloadApproveAllScriptIfMissing(): Promise<void> {
24
- await this.downloadFile(`approve_all.py`);
25
- await this.downloadFile(`remove_abandoned_files.py`);
26
- }
27
-
28
- private static async downloadFile(script: string) {
29
- try {
30
- const scriptPath = path.join(this.APPROVAL_TEMP_DIRECTORY, script);
31
-
32
- if (!fs.existsSync(scriptPath)) {
33
- const githubUrl =
34
- "https://raw.githubusercontent.com/approvals/ApprovalTests.CommonScripts/refs/heads/main/";
35
- const response = await axios.get(`${githubUrl}${script}`);
36
-
37
- fs.writeFileSync(scriptPath, response.data);
38
- fs.chmodSync(scriptPath, 0o755);
39
- }
40
- } catch (error) {
41
- // Do nothing
42
- }
43
- }
44
- }
@@ -1,12 +0,0 @@
1
- import { Namer } from "./Namer";
2
-
3
- export class ManualNamer extends Namer {
4
- constructor(dirName: string, testFileName: string) {
5
- super(dirName, testFileName);
6
- // Redefining these properties is actually redundant here because the superclass constructor
7
- // already sets them based on the arguments provided. You might want to remove these lines
8
- // unless there is some side effect or behavior in the superclass constructor that requires them.
9
- this.basePath = dirName;
10
- this.name = testFileName;
11
- }
12
- }
package/lib/Namer.ts DELETED
@@ -1,28 +0,0 @@
1
- import path from "path";
2
- import { Namer as CoreNamer } from "./Core/Namer";
3
-
4
- export class Namer implements CoreNamer {
5
- public basePath: string;
6
- protected name: string;
7
-
8
- constructor(basePath: string, name: string) {
9
- this.basePath = basePath || "";
10
- this.name = name || "";
11
- if (this.name.endsWith(".")) {
12
- this.name = this.name.slice(0, -1);
13
- }
14
- }
15
-
16
- protected pathCreator(type: string, ext: string = "txt"): string {
17
- const cleanedExt = ext.startsWith(".") ? ext.substring(1) : ext;
18
- return path.join(this.basePath, `${this.name}.${type}.${cleanedExt}`);
19
- }
20
-
21
- getReceivedFile(ext: string): string {
22
- return this.pathCreator("received", ext);
23
- }
24
-
25
- getApprovedFile(ext: string): string {
26
- return this.pathCreator("approved", ext);
27
- }
28
- }
@@ -1,68 +0,0 @@
1
- import * as _ from "lodash";
2
- import * as fs from "fs";
3
- import * as cfg from "../config";
4
- import { StringWriter } from "../StringWriter";
5
- import { FileApprover } from "../FileApprover";
6
- import { ReporterFactory } from "../Reporting/ReporterFactory";
7
- import * as aUtils from "../AUtils";
8
-
9
- import { MochaNamer } from "./Mocha/MochaNamer";
10
-
11
- function beforeEachLoaderFunction(
12
- Namer: typeof MochaNamer,
13
- dirName: string,
14
- that: any,
15
- ): void {
16
- // Add methods to the test context
17
- that.approvals = { getCurrentReporters };
18
- that.verify = verify;
19
- that.verifyAsJSON = verifyAsJSON;
20
-
21
- function getCurrentReporters(options?: any) {
22
- options = options || cfg.currentConfig();
23
- const reporterCandidates = ReporterFactory.loadAllReporters(
24
- options.reporters,
25
- );
26
- return reporterCandidates;
27
- }
28
- function verify(data: any, overrideOptions?: any) {
29
- // @ts-ignore
30
- const context = this as Mocha.Context;
31
- const namer = new Namer(context, dirName);
32
-
33
- const newOptions = _.defaults(overrideOptions || {}, cfg.currentConfig());
34
-
35
- const reporterFactory = function () {
36
- return { getCurrentReporters }.getCurrentReporters(newOptions);
37
- };
38
-
39
- const writer = new StringWriter(newOptions, data);
40
- FileApprover.verify(namer, writer, reporterFactory);
41
- }
42
-
43
- function verifyAsJSON(data: any, overrideOptions?: any) {
44
- // @ts-ignore
45
- this.verify(aUtils.stringifyKeysInOrder(data), overrideOptions);
46
- }
47
- }
48
-
49
- export function beforeEachVerifierBase(
50
- Namer: typeof MochaNamer,
51
- usageSample: string,
52
- dirName: string,
53
- ): void {
54
- if (!fs.existsSync(dirName)) {
55
- fs.mkdirSync(dirName);
56
- }
57
-
58
- // Make sure it's a valid directory
59
- const stats = fs.lstatSync(dirName);
60
- if (!stats.isDirectory()) {
61
- throw new Error(
62
- `Invalid directory [${dirName}]. Try using the following syntax. > ${usageSample}`,
63
- );
64
- }
65
- beforeEach(function (this: any) {
66
- return beforeEachLoaderFunction(Namer, dirName, this);
67
- });
68
- }
@@ -1,161 +0,0 @@
1
- import { verify } from "./JestApprovals";
2
- import { printCombinations } from "../../Utilities/Printers";
3
-
4
- export type Printer<T extends any[]> = (...args: T) => any;
5
- export type VariationsForEachParameter<T extends any[]> = {
6
- [K in keyof T]: T[K][];
7
- };
8
-
9
- export function verifyAllCombinations<T extends any[]>(
10
- func: Printer<T>,
11
- ...variations: VariationsForEachParameter<T>
12
- ): void {
13
- verify(printCombinations(func, ...variations));
14
- }
15
-
16
- export function verifyAllCombinations1<T1>(
17
- func: (t1: T1) => any,
18
- params1: T1[],
19
- ) {
20
- verifyAllCombinations(func, params1);
21
- }
22
-
23
- export function verifyAllCombinations2<T1, T2>(
24
- func: (t1: T1, t2: T2) => any,
25
- params1: T1[],
26
- params2: T2[],
27
- ) {
28
- verifyAllCombinations(func, params1, params2);
29
- }
30
-
31
- export function verifyAllCombinations3<T1, T2, T3>(
32
- func: (t1: T1, t2: T2, t3: T3) => any,
33
- params1: T1[],
34
- params2: T2[],
35
- params3: T3[],
36
- ) {
37
- verifyAllCombinations(func, params1, params2, params3);
38
- }
39
-
40
- export function verifyAllCombinations4<T1, T2, T3, T4>(
41
- func: (t1: T1, t2: T2, t3: T3, t4: T4) => any,
42
- params1: T1[],
43
- params2: T2[],
44
- params3: T3[],
45
- params4: T4[],
46
- ) {
47
- verifyAllCombinations(func, params1, params2, params3, params4);
48
- }
49
-
50
- export function verifyAllCombinations5<T1, T2, T3, T4, T5>(
51
- func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => any,
52
- params1: T1[],
53
- params2: T2[],
54
- params3: T3[],
55
- params4: T4[],
56
- params5: T5[],
57
- ) {
58
- verifyAllCombinations(func, params1, params2, params3, params4, params5);
59
- }
60
-
61
- export function verifyAllCombinations6<T1, T2, T3, T4, T5, T6>(
62
- func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6) => any,
63
- params1: T1[],
64
- params2: T2[],
65
- params3: T3[],
66
- params4: T4[],
67
- params5: T5[],
68
- params6: T6[],
69
- ) {
70
- verifyAllCombinations(
71
- func,
72
- params1,
73
- params2,
74
- params3,
75
- params4,
76
- params5,
77
- params6,
78
- );
79
- }
80
-
81
- export function verifyAllCombinations7<T1, T2, T3, T4, T5, T6, T7>(
82
- func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7) => any,
83
- params1: T1[],
84
- params2: T2[],
85
- params3: T3[],
86
- params4: T4[],
87
- params5: T5[],
88
- params6: T6[],
89
- params7: T7[],
90
- ) {
91
- verifyAllCombinations(
92
- func,
93
- params1,
94
- params2,
95
- params3,
96
- params4,
97
- params5,
98
- params6,
99
- params7,
100
- );
101
- }
102
-
103
- export function verifyAllCombinations8<T1, T2, T3, T4, T5, T6, T7, T8>(
104
- func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8) => any,
105
- params1: T1[],
106
- params2: T2[],
107
- params3: T3[],
108
- params4: T4[],
109
- params5: T5[],
110
- params6: T6[],
111
- params7: T7[],
112
- params8: T8[],
113
- ) {
114
- verifyAllCombinations(
115
- func,
116
- params1,
117
- params2,
118
- params3,
119
- params4,
120
- params5,
121
- params6,
122
- params7,
123
- params8,
124
- );
125
- }
126
-
127
- export function verifyAllCombinations9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
128
- func: (
129
- t1: T1,
130
- t2: T2,
131
- t3: T3,
132
- t4: T4,
133
- t5: T5,
134
- t6: T6,
135
- t7: T7,
136
- t8: T8,
137
- t9: T9,
138
- ) => any,
139
- params1: T1[],
140
- params2: T2[],
141
- params3: T3[],
142
- params4: T4[],
143
- params5: T5[],
144
- params6: T6[],
145
- params7: T7[],
146
- params8: T8[],
147
- params9: T9[],
148
- ) {
149
- verifyAllCombinations(
150
- func,
151
- params1,
152
- params2,
153
- params3,
154
- params4,
155
- params5,
156
- params6,
157
- params7,
158
- params8,
159
- params9,
160
- );
161
- }
@@ -1,50 +0,0 @@
1
- import { printArray, printJson } from "../../Utilities/Printers";
2
- /* ^^^ If the above line is failing, please add
3
- # 1. Jest Config
4
- ```
5
- "transformIgnorePatterns": ["node_modules/@3ds"]
6
- ```
7
-
8
- # 2. tsconfig.json
9
- ```
10
- "esModuleInterop": true
11
- ```
12
- */
13
- import { Options } from "../../Core/Options";
14
- import { getJestNamer } from "./JestNamer";
15
-
16
- import { StringWriter } from "../../StringWriter";
17
- import * as approvals from "../../Approvals";
18
- import { isFrameworkAvailable } from "../OptionalFramework";
19
-
20
- export function verify(sut: any, options?: Options): void {
21
- if (!isFrameworkAvailable("jest")) return;
22
- options = options || new Options();
23
- options = options.withNamer(getJestNamer());
24
- const config = options.getConfig(approvals.getConfig());
25
- const scrubbed = options.scrub(`${sut}`);
26
- const writer = new StringWriter(
27
- config,
28
- scrubbed,
29
- options.forFile().getFileExtension(),
30
- );
31
- let namer = options.getNamer();
32
- approvals.verifyWithControl(namer, writer, null, config);
33
- }
34
-
35
- export function verifyAsJson(data: any, options?: Options): void {
36
- const text = printJson(data);
37
- options = options || new Options();
38
- options = options.forFile().withFileExtension(".json");
39
- verify(text, options);
40
- }
41
-
42
- export function verifyAll<T>(
43
- header: string,
44
- list: T[],
45
- formatter?: (element: T) => string,
46
- options?: Options,
47
- ): void {
48
- const text = printArray(header, list, formatter);
49
- verify(text, options);
50
- }