@casual-simulation/expect 2.0.18
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/LICENSE +21 -0
- package/README.md +4 -0
- package/index.d.ts +6 -0
- package/index.js +5 -0
- package/index.js.map +1 -0
- package/package.json +35 -0
- package/src/asymmetricMatchers.d.ts +67 -0
- package/src/asymmetricMatchers.js +188 -0
- package/src/asymmetricMatchers.js.map +1 -0
- package/src/diff/cleanupSemantic.d.ts +58 -0
- package/src/diff/cleanupSemantic.js +526 -0
- package/src/diff/cleanupSemantic.js.map +1 -0
- package/src/diff/constants.d.ts +9 -0
- package/src/diff/constants.js +10 -0
- package/src/diff/constants.js.map +1 -0
- package/src/diff/diffLines.d.ts +13 -0
- package/src/diff/diffLines.js +138 -0
- package/src/diff/diffLines.js.map +1 -0
- package/src/diff/diffStrings.d.ts +10 -0
- package/src/diff/diffStrings.js +36 -0
- package/src/diff/diffStrings.js.map +1 -0
- package/src/diff/getAlignedDiffs.d.ts +11 -0
- package/src/diff/getAlignedDiffs.js +187 -0
- package/src/diff/getAlignedDiffs.js.map +1 -0
- package/src/diff/index.d.ts +16 -0
- package/src/diff/index.js +139 -0
- package/src/diff/index.js.map +1 -0
- package/src/diff/joinAlignedDiffs.d.ts +11 -0
- package/src/diff/joinAlignedDiffs.js +191 -0
- package/src/diff/joinAlignedDiffs.js.map +1 -0
- package/src/diff/normalizeDiffOptions.d.ts +10 -0
- package/src/diff/normalizeDiffOptions.js +40 -0
- package/src/diff/normalizeDiffOptions.js.map +1 -0
- package/src/diff/printDiffs.d.ts +11 -0
- package/src/diff/printDiffs.js +46 -0
- package/src/diff/printDiffs.js.map +1 -0
- package/src/diff/types.d.ts +49 -0
- package/src/diff/types.js +2 -0
- package/src/diff/types.js.map +1 -0
- package/src/diff-sequences/index.d.ts +19 -0
- package/src/diff-sequences/index.js +506 -0
- package/src/diff-sequences/index.js.map +1 -0
- package/src/extractExpectedAssertionsErrors.d.ts +11 -0
- package/src/extractExpectedAssertionsErrors.js +58 -0
- package/src/extractExpectedAssertionsErrors.js.map +1 -0
- package/src/get-type/index.d.ts +11 -0
- package/src/get-type/index.js +57 -0
- package/src/get-type/index.js.map +1 -0
- package/src/index.d.ts +16 -0
- package/src/index.js +247 -0
- package/src/index.js.map +1 -0
- package/src/jasmineUtils.d.ts +9 -0
- package/src/jasmineUtils.js +218 -0
- package/src/jasmineUtils.js.map +1 -0
- package/src/jestMatchersObject.d.ts +14 -0
- package/src/jestMatchersObject.js +78 -0
- package/src/jestMatchersObject.js.map +1 -0
- package/src/matcher-utils/Replaceable.d.ts +18 -0
- package/src/matcher-utils/Replaceable.js +57 -0
- package/src/matcher-utils/Replaceable.js.map +1 -0
- package/src/matcher-utils/deepCyclicCopyReplaceable.d.ts +8 -0
- package/src/matcher-utils/deepCyclicCopyReplaceable.js +96 -0
- package/src/matcher-utils/deepCyclicCopyReplaceable.js.map +1 -0
- package/src/matcher-utils/index.d.ts +53 -0
- package/src/matcher-utils/index.js +341 -0
- package/src/matcher-utils/index.js.map +1 -0
- package/src/matchers.d.ts +11 -0
- package/src/matchers.js +575 -0
- package/src/matchers.js.map +1 -0
- package/src/message-util/index.d.ts +11 -0
- package/src/message-util/index.js +34 -0
- package/src/message-util/index.js.map +1 -0
- package/src/pretty-format/collections.d.ts +33 -0
- package/src/pretty-format/collections.js +130 -0
- package/src/pretty-format/collections.js.map +1 -0
- package/src/pretty-format/index.d.ts +25 -0
- package/src/pretty-format/index.js +390 -0
- package/src/pretty-format/index.js.map +1 -0
- package/src/pretty-format/plugins/AsymmetricMatcher.d.ts +12 -0
- package/src/pretty-format/plugins/AsymmetricMatcher.js +53 -0
- package/src/pretty-format/plugins/AsymmetricMatcher.js.map +1 -0
- package/src/pretty-format/plugins/ConvertAnsi.d.ts +12 -0
- package/src/pretty-format/plugins/ConvertAnsi.js +58 -0
- package/src/pretty-format/plugins/ConvertAnsi.js.map +1 -0
- package/src/pretty-format/plugins/DOMCollection.d.ts +12 -0
- package/src/pretty-format/plugins/DOMCollection.js +39 -0
- package/src/pretty-format/plugins/DOMCollection.js.map +1 -0
- package/src/pretty-format/plugins/DOMElement.d.ts +12 -0
- package/src/pretty-format/plugins/DOMElement.js +68 -0
- package/src/pretty-format/plugins/DOMElement.js.map +1 -0
- package/src/pretty-format/plugins/Immutable.d.ts +12 -0
- package/src/pretty-format/plugins/Immutable.js +113 -0
- package/src/pretty-format/plugins/Immutable.js.map +1 -0
- package/src/pretty-format/plugins/ReactTestComponent.d.ts +19 -0
- package/src/pretty-format/plugins/ReactTestComponent.js +29 -0
- package/src/pretty-format/plugins/ReactTestComponent.js.map +1 -0
- package/src/pretty-format/plugins/lib/escapeHTML.d.ts +8 -0
- package/src/pretty-format/plugins/lib/escapeHTML.js +10 -0
- package/src/pretty-format/plugins/lib/escapeHTML.js.map +1 -0
- package/src/pretty-format/plugins/lib/markup.d.ts +14 -0
- package/src/pretty-format/plugins/lib/markup.js +98 -0
- package/src/pretty-format/plugins/lib/markup.js.map +1 -0
- package/src/pretty-format/types.d.ts +109 -0
- package/src/pretty-format/types.js +8 -0
- package/src/pretty-format/types.js.map +1 -0
- package/src/print.d.ts +16 -0
- package/src/print.js +71 -0
- package/src/print.js.map +1 -0
- package/src/spyMatchers.d.ts +10 -0
- package/src/spyMatchers.js +766 -0
- package/src/spyMatchers.js.map +1 -0
- package/src/test-utils/ConditionalTest.d.ts +10 -0
- package/src/test-utils/ConditionalTest.js +25 -0
- package/src/test-utils/ConditionalTest.js.map +1 -0
- package/src/test-utils/alignedAnsiStyleSerializer.d.ts +9 -0
- package/src/test-utils/alignedAnsiStyleSerializer.js +46 -0
- package/src/test-utils/alignedAnsiStyleSerializer.js.map +1 -0
- package/src/test-utils/config.d.ts +10 -0
- package/src/test-utils/config.js +143 -0
- package/src/test-utils/config.js.map +1 -0
- package/src/test-utils/index.d.ts +10 -0
- package/src/test-utils/index.js +10 -0
- package/src/test-utils/index.js.map +1 -0
- package/src/toThrowMatchers.d.ts +12 -0
- package/src/toThrowMatchers.js +258 -0
- package/src/toThrowMatchers.js.map +1 -0
- package/src/types.d.ts +327 -0
- package/src/types.js +9 -0
- package/src/types.js.map +1 -0
- package/src/utils.d.ts +26 -0
- package/src/utils.js +303 -0
- package/src/utils.js.map +1 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import diff from '../diff-sequences';
|
|
8
|
+
import { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff } from './cleanupSemantic';
|
|
9
|
+
import { joinAlignedDiffsExpand, joinAlignedDiffsNoExpand, } from './joinAlignedDiffs';
|
|
10
|
+
import { normalizeDiffOptions } from './normalizeDiffOptions';
|
|
11
|
+
const isEmptyString = (lines) => lines.length === 1 && lines[0].length === 0;
|
|
12
|
+
const countChanges = (diffs) => {
|
|
13
|
+
let a = 0;
|
|
14
|
+
let b = 0;
|
|
15
|
+
diffs.forEach((diff) => {
|
|
16
|
+
switch (diff[0]) {
|
|
17
|
+
case DIFF_DELETE:
|
|
18
|
+
a += 1;
|
|
19
|
+
break;
|
|
20
|
+
case DIFF_INSERT:
|
|
21
|
+
b += 1;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return { a, b };
|
|
26
|
+
};
|
|
27
|
+
const printAnnotation = ({ aAnnotation, aColor, aIndicator, bAnnotation, bColor, bIndicator, includeChangeCounts, omitAnnotationLines, }, changeCounts) => {
|
|
28
|
+
if (omitAnnotationLines) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
let aRest = '';
|
|
32
|
+
let bRest = '';
|
|
33
|
+
if (includeChangeCounts) {
|
|
34
|
+
const aCount = String(changeCounts.a);
|
|
35
|
+
const bCount = String(changeCounts.b);
|
|
36
|
+
// Padding right aligns the ends of the annotations.
|
|
37
|
+
const baAnnotationLengthDiff = bAnnotation.length - aAnnotation.length;
|
|
38
|
+
const aAnnotationPadding = ' '.repeat(Math.max(0, baAnnotationLengthDiff));
|
|
39
|
+
const bAnnotationPadding = ' '.repeat(Math.max(0, -baAnnotationLengthDiff));
|
|
40
|
+
// Padding left aligns the ends of the counts.
|
|
41
|
+
const baCountLengthDiff = bCount.length - aCount.length;
|
|
42
|
+
const aCountPadding = ' '.repeat(Math.max(0, baCountLengthDiff));
|
|
43
|
+
const bCountPadding = ' '.repeat(Math.max(0, -baCountLengthDiff));
|
|
44
|
+
aRest =
|
|
45
|
+
aAnnotationPadding +
|
|
46
|
+
' ' +
|
|
47
|
+
aIndicator +
|
|
48
|
+
' ' +
|
|
49
|
+
aCountPadding +
|
|
50
|
+
aCount;
|
|
51
|
+
bRest =
|
|
52
|
+
bAnnotationPadding +
|
|
53
|
+
' ' +
|
|
54
|
+
bIndicator +
|
|
55
|
+
' ' +
|
|
56
|
+
bCountPadding +
|
|
57
|
+
bCount;
|
|
58
|
+
}
|
|
59
|
+
return (aColor(aIndicator + ' ' + aAnnotation + aRest) +
|
|
60
|
+
'\n' +
|
|
61
|
+
bColor(bIndicator + ' ' + bAnnotation + bRest) +
|
|
62
|
+
'\n\n');
|
|
63
|
+
};
|
|
64
|
+
export const printDiffLines = (diffs, options) => printAnnotation(options, countChanges(diffs)) +
|
|
65
|
+
(options.expand
|
|
66
|
+
? joinAlignedDiffsExpand(diffs, options)
|
|
67
|
+
: joinAlignedDiffsNoExpand(diffs, options));
|
|
68
|
+
// Compare two arrays of strings line-by-line. Format as comparison lines.
|
|
69
|
+
export const diffLinesUnified = (aLines, bLines, options) => printDiffLines(diffLinesRaw(isEmptyString(aLines) ? [] : aLines, isEmptyString(bLines) ? [] : bLines), normalizeDiffOptions(options));
|
|
70
|
+
// Given two pairs of arrays of strings:
|
|
71
|
+
// Compare the pair of comparison arrays line-by-line.
|
|
72
|
+
// Format the corresponding lines in the pair of displayable arrays.
|
|
73
|
+
export const diffLinesUnified2 = (aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options) => {
|
|
74
|
+
if (isEmptyString(aLinesDisplay) && isEmptyString(aLinesCompare)) {
|
|
75
|
+
aLinesDisplay = [];
|
|
76
|
+
aLinesCompare = [];
|
|
77
|
+
}
|
|
78
|
+
if (isEmptyString(bLinesDisplay) && isEmptyString(bLinesCompare)) {
|
|
79
|
+
bLinesDisplay = [];
|
|
80
|
+
bLinesCompare = [];
|
|
81
|
+
}
|
|
82
|
+
if (aLinesDisplay.length !== aLinesCompare.length ||
|
|
83
|
+
bLinesDisplay.length !== bLinesCompare.length) {
|
|
84
|
+
// Fall back to diff of display lines.
|
|
85
|
+
return diffLinesUnified(aLinesDisplay, bLinesDisplay, options);
|
|
86
|
+
}
|
|
87
|
+
const diffs = diffLinesRaw(aLinesCompare, bLinesCompare);
|
|
88
|
+
// Replace comparison lines with displayable lines.
|
|
89
|
+
let aIndex = 0;
|
|
90
|
+
let bIndex = 0;
|
|
91
|
+
diffs.forEach((diff) => {
|
|
92
|
+
switch (diff[0]) {
|
|
93
|
+
case DIFF_DELETE:
|
|
94
|
+
diff[1] = aLinesDisplay[aIndex];
|
|
95
|
+
aIndex += 1;
|
|
96
|
+
break;
|
|
97
|
+
case DIFF_INSERT:
|
|
98
|
+
diff[1] = bLinesDisplay[bIndex];
|
|
99
|
+
bIndex += 1;
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
diff[1] = bLinesDisplay[bIndex];
|
|
103
|
+
aIndex += 1;
|
|
104
|
+
bIndex += 1;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return printDiffLines(diffs, normalizeDiffOptions(options));
|
|
108
|
+
};
|
|
109
|
+
// Compare two arrays of strings line-by-line.
|
|
110
|
+
export const diffLinesRaw = (aLines, bLines) => {
|
|
111
|
+
const aLength = aLines.length;
|
|
112
|
+
const bLength = bLines.length;
|
|
113
|
+
const isCommon = (aIndex, bIndex) => aLines[aIndex] === bLines[bIndex];
|
|
114
|
+
const diffs = [];
|
|
115
|
+
let aIndex = 0;
|
|
116
|
+
let bIndex = 0;
|
|
117
|
+
const foundSubsequence = (nCommon, aCommon, bCommon) => {
|
|
118
|
+
for (; aIndex !== aCommon; aIndex += 1) {
|
|
119
|
+
diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
|
|
120
|
+
}
|
|
121
|
+
for (; bIndex !== bCommon; bIndex += 1) {
|
|
122
|
+
diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
|
|
123
|
+
}
|
|
124
|
+
for (; nCommon !== 0; nCommon -= 1, aIndex += 1, bIndex += 1) {
|
|
125
|
+
diffs.push(new Diff(DIFF_EQUAL, bLines[bIndex]));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
diff(aLength, bLength, isCommon, foundSubsequence);
|
|
129
|
+
// After the last common subsequence, push remaining change items.
|
|
130
|
+
for (; aIndex !== aLength; aIndex += 1) {
|
|
131
|
+
diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
|
|
132
|
+
}
|
|
133
|
+
for (; bIndex !== bLength; bIndex += 1) {
|
|
134
|
+
diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
|
|
135
|
+
}
|
|
136
|
+
return diffs;
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=diffLines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffLines.js","sourceRoot":"","sources":["diffLines.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,mBAAmB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EACH,sBAAsB,EACtB,wBAAwB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,M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O,OAAO,KAAK,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE;YAC1D,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACpD;IACL,CAAC,CAAC;IAEF,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAEnD,kEAAkE;IAClE,OAAO,MAAM,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE;QACpC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACrD;IACD,OAAO,MAAM,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE;QACpC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACrD;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { Diff } from './cleanupSemantic';
|
|
8
|
+
declare const diffStrings: (a: string, b: string) => Array<Diff>;
|
|
9
|
+
export default diffStrings;
|
|
10
|
+
//# sourceMappingURL=diffStrings.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import diffSequences from '../diff-sequences';
|
|
8
|
+
import { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff } from './cleanupSemantic';
|
|
9
|
+
const diffStrings = (a, b) => {
|
|
10
|
+
const isCommon = (aIndex, bIndex) => a[aIndex] === b[bIndex];
|
|
11
|
+
let aIndex = 0;
|
|
12
|
+
let bIndex = 0;
|
|
13
|
+
const diffs = [];
|
|
14
|
+
const foundSubsequence = (nCommon, aCommon, bCommon) => {
|
|
15
|
+
if (aIndex !== aCommon) {
|
|
16
|
+
diffs.push(new Diff(DIFF_DELETE, a.slice(aIndex, aCommon)));
|
|
17
|
+
}
|
|
18
|
+
if (bIndex !== bCommon) {
|
|
19
|
+
diffs.push(new Diff(DIFF_INSERT, b.slice(bIndex, bCommon)));
|
|
20
|
+
}
|
|
21
|
+
aIndex = aCommon + nCommon; // number of characters compared in a
|
|
22
|
+
bIndex = bCommon + nCommon; // number of characters compared in b
|
|
23
|
+
diffs.push(new Diff(DIFF_EQUAL, b.slice(bCommon, bIndex)));
|
|
24
|
+
};
|
|
25
|
+
diffSequences(a.length, b.length, isCommon, foundSubsequence);
|
|
26
|
+
// After the last common subsequence, push remaining change items.
|
|
27
|
+
if (aIndex !== a.length) {
|
|
28
|
+
diffs.push(new Diff(DIFF_DELETE, a.slice(aIndex)));
|
|
29
|
+
}
|
|
30
|
+
if (bIndex !== b.length) {
|
|
31
|
+
diffs.push(new Diff(DIFF_INSERT, b.slice(bIndex)));
|
|
32
|
+
}
|
|
33
|
+
return diffs;
|
|
34
|
+
};
|
|
35
|
+
export default diffStrings;
|
|
36
|
+
//# sourceMappingURL=diffStrings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffStrings.js","sourceRoot":"","sources":["diffStrings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,I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KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACtD;IACD,IAAI,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;QACrB,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACtD;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { Diff } from './cleanupSemantic';
|
|
8
|
+
import type { DiffOptionsColor } from './types';
|
|
9
|
+
declare const getAlignedDiffs: (diffs: Array<Diff>, changeColor: DiffOptionsColor) => Array<Diff>;
|
|
10
|
+
export default getAlignedDiffs;
|
|
11
|
+
//# sourceMappingURL=getAlignedDiffs.d.ts.map
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff } from './cleanupSemantic';
|
|
8
|
+
// Given change op and array of diffs, return concatenated string:
|
|
9
|
+
// * include common strings
|
|
10
|
+
// * include change strings which have argument op with changeColor
|
|
11
|
+
// * exclude change strings which have opposite op
|
|
12
|
+
const concatenateRelevantDiffs = (op, diffs, changeColor) => diffs.reduce((reduced, diff) => reduced +
|
|
13
|
+
(diff[0] === DIFF_EQUAL
|
|
14
|
+
? diff[1]
|
|
15
|
+
: diff[0] === op && diff[1].length !== 0 // empty if change is newline
|
|
16
|
+
? changeColor(diff[1])
|
|
17
|
+
: ''), '');
|
|
18
|
+
// Encapsulate change lines until either a common newline or the end.
|
|
19
|
+
class ChangeBuffer {
|
|
20
|
+
constructor(op, changeColor) {
|
|
21
|
+
this.op = op;
|
|
22
|
+
this.line = [];
|
|
23
|
+
this.lines = [];
|
|
24
|
+
this.changeColor = changeColor;
|
|
25
|
+
}
|
|
26
|
+
pushSubstring(substring) {
|
|
27
|
+
this.pushDiff(new Diff(this.op, substring));
|
|
28
|
+
}
|
|
29
|
+
pushLine() {
|
|
30
|
+
// Assume call only if line has at least one diff,
|
|
31
|
+
// therefore an empty line must have a diff which has an empty string.
|
|
32
|
+
// If line has multiple diffs, then assume it has a common diff,
|
|
33
|
+
// therefore change diffs have change color;
|
|
34
|
+
// otherwise then it has line color only.
|
|
35
|
+
this.lines.push(this.line.length !== 1
|
|
36
|
+
? new Diff(this.op, concatenateRelevantDiffs(this.op, this.line, this.changeColor))
|
|
37
|
+
: this.line[0][0] === this.op
|
|
38
|
+
? this.line[0] // can use instance
|
|
39
|
+
: new Diff(this.op, this.line[0][1]) // was common diff
|
|
40
|
+
);
|
|
41
|
+
this.line.length = 0;
|
|
42
|
+
}
|
|
43
|
+
isLineEmpty() {
|
|
44
|
+
return this.line.length === 0;
|
|
45
|
+
}
|
|
46
|
+
// Minor input to buffer.
|
|
47
|
+
pushDiff(diff) {
|
|
48
|
+
this.line.push(diff);
|
|
49
|
+
}
|
|
50
|
+
// Main input to buffer.
|
|
51
|
+
align(diff) {
|
|
52
|
+
const string = diff[1];
|
|
53
|
+
if (string.includes('\n')) {
|
|
54
|
+
const substrings = string.split('\n');
|
|
55
|
+
const iLast = substrings.length - 1;
|
|
56
|
+
substrings.forEach((substring, i) => {
|
|
57
|
+
if (i < iLast) {
|
|
58
|
+
// The first substring completes the current change line.
|
|
59
|
+
// A middle substring is a change line.
|
|
60
|
+
this.pushSubstring(substring);
|
|
61
|
+
this.pushLine();
|
|
62
|
+
}
|
|
63
|
+
else if (substring.length !== 0) {
|
|
64
|
+
// The last substring starts a change line, if it is not empty.
|
|
65
|
+
// Important: This non-empty condition also automatically omits
|
|
66
|
+
// the newline appended to the end of expected and received strings.
|
|
67
|
+
this.pushSubstring(substring);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Append non-multiline string to current change line.
|
|
73
|
+
this.pushDiff(diff);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Output from buffer.
|
|
77
|
+
moveLinesTo(lines) {
|
|
78
|
+
if (!this.isLineEmpty()) {
|
|
79
|
+
this.pushLine();
|
|
80
|
+
}
|
|
81
|
+
lines.push(...this.lines);
|
|
82
|
+
this.lines.length = 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Encapsulate common and change lines.
|
|
86
|
+
class CommonBuffer {
|
|
87
|
+
constructor(deleteBuffer, insertBuffer) {
|
|
88
|
+
this.deleteBuffer = deleteBuffer;
|
|
89
|
+
this.insertBuffer = insertBuffer;
|
|
90
|
+
this.lines = [];
|
|
91
|
+
}
|
|
92
|
+
pushDiffCommonLine(diff) {
|
|
93
|
+
this.lines.push(diff);
|
|
94
|
+
}
|
|
95
|
+
pushDiffChangeLines(diff) {
|
|
96
|
+
const isDiffEmpty = diff[1].length === 0;
|
|
97
|
+
// An empty diff string is redundant, unless a change line is empty.
|
|
98
|
+
if (!isDiffEmpty || this.deleteBuffer.isLineEmpty()) {
|
|
99
|
+
this.deleteBuffer.pushDiff(diff);
|
|
100
|
+
}
|
|
101
|
+
if (!isDiffEmpty || this.insertBuffer.isLineEmpty()) {
|
|
102
|
+
this.insertBuffer.pushDiff(diff);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
flushChangeLines() {
|
|
106
|
+
this.deleteBuffer.moveLinesTo(this.lines);
|
|
107
|
+
this.insertBuffer.moveLinesTo(this.lines);
|
|
108
|
+
}
|
|
109
|
+
// Input to buffer.
|
|
110
|
+
align(diff) {
|
|
111
|
+
const op = diff[0];
|
|
112
|
+
const string = diff[1];
|
|
113
|
+
if (string.includes('\n')) {
|
|
114
|
+
const substrings = string.split('\n');
|
|
115
|
+
const iLast = substrings.length - 1;
|
|
116
|
+
substrings.forEach((substring, i) => {
|
|
117
|
+
if (i === 0) {
|
|
118
|
+
const subdiff = new Diff(op, substring);
|
|
119
|
+
if (this.deleteBuffer.isLineEmpty() &&
|
|
120
|
+
this.insertBuffer.isLineEmpty()) {
|
|
121
|
+
// If both current change lines are empty,
|
|
122
|
+
// then the first substring is a common line.
|
|
123
|
+
this.flushChangeLines();
|
|
124
|
+
this.pushDiffCommonLine(subdiff);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// If either current change line is non-empty,
|
|
128
|
+
// then the first substring completes the change lines.
|
|
129
|
+
this.pushDiffChangeLines(subdiff);
|
|
130
|
+
this.flushChangeLines();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (i < iLast) {
|
|
134
|
+
// A middle substring is a common line.
|
|
135
|
+
this.pushDiffCommonLine(new Diff(op, substring));
|
|
136
|
+
}
|
|
137
|
+
else if (substring.length !== 0) {
|
|
138
|
+
// The last substring starts a change line, if it is not empty.
|
|
139
|
+
// Important: This non-empty condition also automatically omits
|
|
140
|
+
// the newline appended to the end of expected and received strings.
|
|
141
|
+
this.pushDiffChangeLines(new Diff(op, substring));
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// Append non-multiline string to current change lines.
|
|
147
|
+
// Important: It cannot be at the end following empty change lines,
|
|
148
|
+
// because newline appended to the end of expected and received strings.
|
|
149
|
+
this.pushDiffChangeLines(diff);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Output from buffer.
|
|
153
|
+
getLines() {
|
|
154
|
+
this.flushChangeLines();
|
|
155
|
+
return this.lines;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Given diffs from expected and received strings,
|
|
159
|
+
// return new array of diffs split or joined into lines.
|
|
160
|
+
//
|
|
161
|
+
// To correctly align a change line at the end, the algorithm:
|
|
162
|
+
// * assumes that a newline was appended to the strings
|
|
163
|
+
// * omits the last newline from the output array
|
|
164
|
+
//
|
|
165
|
+
// Assume the function is not called:
|
|
166
|
+
// * if either expected or received is empty string
|
|
167
|
+
// * if neither expected nor received is multiline string
|
|
168
|
+
const getAlignedDiffs = (diffs, changeColor) => {
|
|
169
|
+
const deleteBuffer = new ChangeBuffer(DIFF_DELETE, changeColor);
|
|
170
|
+
const insertBuffer = new ChangeBuffer(DIFF_INSERT, changeColor);
|
|
171
|
+
const commonBuffer = new CommonBuffer(deleteBuffer, insertBuffer);
|
|
172
|
+
diffs.forEach((diff) => {
|
|
173
|
+
switch (diff[0]) {
|
|
174
|
+
case DIFF_DELETE:
|
|
175
|
+
deleteBuffer.align(diff);
|
|
176
|
+
break;
|
|
177
|
+
case DIFF_INSERT:
|
|
178
|
+
insertBuffer.align(diff);
|
|
179
|
+
break;
|
|
180
|
+
default:
|
|
181
|
+
commonBuffer.align(diff);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return commonBuffer.getLines();
|
|
185
|
+
};
|
|
186
|
+
export default getAlignedDiffs;
|
|
187
|
+
//# sourceMappingURL=getAlignedDiffs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAlignedDiffs.js","sourceRoot":"","sources":["getAlignedDiffs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAG/E,kEAAkE;AAClE,2BAA2B;AAC3B,mEAAmE;AACnE,kDAAkD;AAClD,MAAM,wBAAwB,GAAG,CAC7B,EAAU,EACV,KAAkB,EAClB,WAA6B,EACvB,EAAE,CACR,KAAK,CAAC,MAAM,CACR,CAAC,OAAe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sBAAsB;IACtB,QAAQ;QACJ,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CACJ;AAED,kDAAkD;AAClD,wDAAwD;AACxD,EAAE;AACF,8DAA8D;AAC9D,uDAAuD;AACvD,iDAAiD;AACjD,EAAE;AACF,qCAAqC;AACrC,mDAAmD;AACnD,yDAAyD;AACzD,MAAM,eAAe,GAAG,CACpB,KAAkB,EAClB,WAA6B,EAClB,EAAE;IACb,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAElE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACnB,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE;YACb,KAAK,WAAW;gBACZ,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACzB,MAAM;YAEV,KAAK,WAAW;gBACZ,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACzB,MAAM;YAEV;gBACI,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAChC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff } from './cleanupSemantic';
|
|
8
|
+
import { diffLinesRaw, diffLinesUnified, diffLinesUnified2 } from './diffLines';
|
|
9
|
+
import { diffStringsRaw, diffStringsUnified } from './printDiffs';
|
|
10
|
+
import type { DiffOptions } from './types';
|
|
11
|
+
export type { DiffOptions, DiffOptionsColor } from './types';
|
|
12
|
+
export { diffLinesRaw, diffLinesUnified, diffLinesUnified2 };
|
|
13
|
+
export { diffStringsRaw, diffStringsUnified };
|
|
14
|
+
export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff };
|
|
15
|
+
export declare function diff(a: any, b: any, options?: DiffOptions): string | null;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import chalk from '@casual-simulation/chalk';
|
|
8
|
+
import { getType } from '../get-type';
|
|
9
|
+
import { format as prettyFormat, plugins as prettyFormatPlugins, } from '../pretty-format';
|
|
10
|
+
import { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff } from './cleanupSemantic';
|
|
11
|
+
import { NO_DIFF_MESSAGE, SIMILAR_MESSAGE } from './constants';
|
|
12
|
+
import { diffLinesRaw, diffLinesUnified, diffLinesUnified2 } from './diffLines';
|
|
13
|
+
import { normalizeDiffOptions } from './normalizeDiffOptions';
|
|
14
|
+
import { diffStringsRaw, diffStringsUnified } from './printDiffs';
|
|
15
|
+
export { diffLinesRaw, diffLinesUnified, diffLinesUnified2 };
|
|
16
|
+
export { diffStringsRaw, diffStringsUnified };
|
|
17
|
+
export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff };
|
|
18
|
+
const getCommonMessage = (message, options) => {
|
|
19
|
+
const { commonColor } = normalizeDiffOptions(options);
|
|
20
|
+
return commonColor(message);
|
|
21
|
+
};
|
|
22
|
+
const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactTestComponent, } = prettyFormatPlugins;
|
|
23
|
+
const PLUGINS = [
|
|
24
|
+
ReactTestComponent,
|
|
25
|
+
DOMElement,
|
|
26
|
+
DOMCollection,
|
|
27
|
+
Immutable,
|
|
28
|
+
AsymmetricMatcher,
|
|
29
|
+
];
|
|
30
|
+
const FORMAT_OPTIONS = {
|
|
31
|
+
plugins: PLUGINS,
|
|
32
|
+
};
|
|
33
|
+
const FALLBACK_FORMAT_OPTIONS = {
|
|
34
|
+
callToJSON: false,
|
|
35
|
+
maxDepth: 10,
|
|
36
|
+
plugins: PLUGINS,
|
|
37
|
+
};
|
|
38
|
+
// Generate a string that will highlight the difference between two values
|
|
39
|
+
// with green and red. (similar to how github does code diffing)
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
41
|
+
export function diff(a, b, options) {
|
|
42
|
+
if (Object.is(a, b)) {
|
|
43
|
+
return getCommonMessage(NO_DIFF_MESSAGE, options);
|
|
44
|
+
}
|
|
45
|
+
const aType = getType(a);
|
|
46
|
+
let expectedType = aType;
|
|
47
|
+
let omitDifference = false;
|
|
48
|
+
if (aType === 'object' && typeof a.asymmetricMatch === 'function') {
|
|
49
|
+
if (a.$$typeof !== Symbol.for('jest.asymmetricMatcher')) {
|
|
50
|
+
// Do not know expected type of user-defined asymmetric matcher.
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (typeof a.getExpectedType !== 'function') {
|
|
54
|
+
// For example, expect.anything() matches either null or undefined
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
expectedType = a.getExpectedType();
|
|
58
|
+
// Primitive types boolean and number omit difference below.
|
|
59
|
+
// For example, omit difference for expect.stringMatching(regexp)
|
|
60
|
+
omitDifference = expectedType === 'string';
|
|
61
|
+
}
|
|
62
|
+
if (expectedType !== getType(b)) {
|
|
63
|
+
return (' Comparing two different types of values.' +
|
|
64
|
+
` Expected ${chalk.green(expectedType)} but ` +
|
|
65
|
+
`received ${chalk.red(getType(b))}.`);
|
|
66
|
+
}
|
|
67
|
+
if (omitDifference) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
switch (aType) {
|
|
71
|
+
case 'string':
|
|
72
|
+
return diffLinesUnified(a.split('\n'), b.split('\n'), options);
|
|
73
|
+
case 'boolean':
|
|
74
|
+
case 'number':
|
|
75
|
+
return comparePrimitive(a, b, options);
|
|
76
|
+
case 'map':
|
|
77
|
+
return compareObjects(sortMap(a), sortMap(b), options);
|
|
78
|
+
case 'set':
|
|
79
|
+
return compareObjects(sortSet(a), sortSet(b), options);
|
|
80
|
+
default:
|
|
81
|
+
return compareObjects(a, b, options);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function comparePrimitive(a, b, options) {
|
|
85
|
+
const aFormat = prettyFormat(a, FORMAT_OPTIONS);
|
|
86
|
+
const bFormat = prettyFormat(b, FORMAT_OPTIONS);
|
|
87
|
+
return aFormat === bFormat
|
|
88
|
+
? getCommonMessage(NO_DIFF_MESSAGE, options)
|
|
89
|
+
: diffLinesUnified(aFormat.split('\n'), bFormat.split('\n'), options);
|
|
90
|
+
}
|
|
91
|
+
function sortMap(map) {
|
|
92
|
+
return new Map(Array.from(map.entries()).sort());
|
|
93
|
+
}
|
|
94
|
+
function sortSet(set) {
|
|
95
|
+
return new Set(Array.from(set.values()).sort());
|
|
96
|
+
}
|
|
97
|
+
function compareObjects(a, b, options) {
|
|
98
|
+
let difference;
|
|
99
|
+
let hasThrown = false;
|
|
100
|
+
try {
|
|
101
|
+
const formatOptions = getFormatOptions(FORMAT_OPTIONS, options);
|
|
102
|
+
difference = getObjectsDifference(a, b, formatOptions, options);
|
|
103
|
+
}
|
|
104
|
+
catch (_a) {
|
|
105
|
+
hasThrown = true;
|
|
106
|
+
}
|
|
107
|
+
const noDiffMessage = getCommonMessage(NO_DIFF_MESSAGE, options);
|
|
108
|
+
// If the comparison yields no results, compare again but this time
|
|
109
|
+
// without calling `toJSON`. It's also possible that toJSON might throw.
|
|
110
|
+
if (difference === undefined || difference === noDiffMessage) {
|
|
111
|
+
const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
|
|
112
|
+
difference = getObjectsDifference(a, b, formatOptions, options);
|
|
113
|
+
if (difference !== noDiffMessage && !hasThrown) {
|
|
114
|
+
difference =
|
|
115
|
+
getCommonMessage(SIMILAR_MESSAGE, options) +
|
|
116
|
+
'\n\n' +
|
|
117
|
+
difference;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return difference;
|
|
121
|
+
}
|
|
122
|
+
function getFormatOptions(formatOptions, options) {
|
|
123
|
+
const { compareKeys } = normalizeDiffOptions(options);
|
|
124
|
+
return Object.assign(Object.assign({}, formatOptions), { compareKeys });
|
|
125
|
+
}
|
|
126
|
+
function getObjectsDifference(a, b, formatOptions, options) {
|
|
127
|
+
const formatOptionsZeroIndent = Object.assign(Object.assign({}, formatOptions), { indent: 0 });
|
|
128
|
+
const aCompare = prettyFormat(a, formatOptionsZeroIndent);
|
|
129
|
+
const bCompare = prettyFormat(b, formatOptionsZeroIndent);
|
|
130
|
+
if (aCompare === bCompare) {
|
|
131
|
+
return getCommonMessage(NO_DIFF_MESSAGE, options);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const aDisplay = prettyFormat(a, formatOptions);
|
|
135
|
+
const bDisplay = prettyFormat(b, formatOptions);
|
|
136
|
+
return diffLinesUnified2(aDisplay.split('\n'), bDisplay.split('\n'), aCompare.split('\n'), bCompare.split('\n'), options);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,0BAA0B,CAAC;AAC7C,OAAO,EAAE,OAA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I,QAAQ,KAAK,QAAQ,EAAE;QACvB,OAAO,gBAAgB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;KACrD;SAAM;QACH,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QAEhD,OAAO,iBAAiB,CACpB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EACpB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EACpB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EACpB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EACpB,OAAO,CACV,CAAC;KACL;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { Diff } from './cleanupSemantic';
|
|
8
|
+
import type { DiffOptionsNormalized } from './types';
|
|
9
|
+
export declare const joinAlignedDiffsNoExpand: (diffs: Array<Diff>, options: DiffOptionsNormalized) => string;
|
|
10
|
+
export declare const joinAlignedDiffsExpand: (diffs: Array<Diff>, options: DiffOptionsNormalized) => string;
|
|
11
|
+
//# sourceMappingURL=joinAlignedDiffs.d.ts.map
|