mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
21
web/node_modules/jest-diff/LICENSE
generated
vendored
Normal file
21
web/node_modules/jest-diff/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
614
web/node_modules/jest-diff/README.md
generated
vendored
Normal file
614
web/node_modules/jest-diff/README.md
generated
vendored
Normal file
|
@ -0,0 +1,614 @@
|
|||
# jest-diff
|
||||
|
||||
Display differences clearly so people can review changes confidently.
|
||||
|
||||
The default export serializes JavaScript **values**, compares them line-by-line, and returns a string which includes comparison lines.
|
||||
|
||||
Two named exports compare **strings** character-by-character:
|
||||
|
||||
- `diffStringsUnified` returns a string.
|
||||
- `diffStringsRaw` returns an array of `Diff` objects.
|
||||
|
||||
Three named exports compare **arrays of strings** line-by-line:
|
||||
|
||||
- `diffLinesUnified` and `diffLinesUnified2` return a string.
|
||||
- `diffLinesRaw` returns an array of `Diff` objects.
|
||||
|
||||
## Installation
|
||||
|
||||
To add this package as a dependency of a project, run either of the following commands:
|
||||
|
||||
- `npm install jest-diff`
|
||||
- `yarn add jest-diff`
|
||||
|
||||
## Usage of default export
|
||||
|
||||
Given JavaScript **values**, `diffDefault(a, b, options?)` does the following:
|
||||
|
||||
1. **serialize** the values as strings using the `pretty-format` package
|
||||
2. **compare** the strings line-by-line using the `diff-sequences` package
|
||||
3. **format** the changed or common lines using the `chalk` package
|
||||
|
||||
To use this function, write either of the following:
|
||||
|
||||
- `const diffDefault = require('jest-diff').default;` in CommonJS modules
|
||||
- `import diffDefault from 'jest-diff';` in ECMAScript modules
|
||||
|
||||
### Example of default export
|
||||
|
||||
```js
|
||||
const a = ['delete', 'common', 'changed from'];
|
||||
const b = ['common', 'changed to', 'insert'];
|
||||
|
||||
const difference = diffDefault(a, b);
|
||||
```
|
||||
|
||||
The returned **string** consists of:
|
||||
|
||||
- annotation lines: describe the two change indicators with labels, and a blank line
|
||||
- comparison lines: similar to “unified” view on GitHub, but `Expected` lines are green, `Received` lines are red, and common lines are dim (by default, see Options)
|
||||
|
||||
```diff
|
||||
- Expected
|
||||
+ Received
|
||||
|
||||
Array [
|
||||
- "delete",
|
||||
"common",
|
||||
- "changed from",
|
||||
+ "changed to",
|
||||
+ "insert",
|
||||
]
|
||||
```
|
||||
|
||||
### Edge cases of default export
|
||||
|
||||
Here are edge cases for the return value:
|
||||
|
||||
- `' Comparing two different types of values. …'` if the arguments have **different types** according to the `jest-get-type` package (instances of different classes have the same `'object'` type)
|
||||
- `'Compared values have no visual difference.'` if the arguments have either **referential identity** according to `Object.is` method or **same serialization** according to the `pretty-format` package
|
||||
- `null` if either argument is a so-called **asymmetric matcher** in Jasmine or Jest
|
||||
|
||||
## Usage of diffStringsUnified
|
||||
|
||||
Given **strings**, `diffStringsUnified(a, b, options?)` does the following:
|
||||
|
||||
1. **compare** the strings character-by-character using the `diff-sequences` package
|
||||
2. **clean up** small (often coincidental) common substrings, also known as chaff
|
||||
3. **format** the changed or common lines using the `chalk` package
|
||||
|
||||
Although the function is mainly for **multiline** strings, it compares any strings.
|
||||
|
||||
Write either of the following:
|
||||
|
||||
- `const {diffStringsUnified} = require('jest-diff');` in CommonJS modules
|
||||
- `import {diffStringsUnified} from 'jest-diff';` in ECMAScript modules
|
||||
|
||||
### Example of diffStringsUnified
|
||||
|
||||
```js
|
||||
const a = 'common\nchanged from';
|
||||
const b = 'common\nchanged to';
|
||||
|
||||
const difference = diffStringsUnified(a, b);
|
||||
```
|
||||
|
||||
The returned **string** consists of:
|
||||
|
||||
- annotation lines: describe the two change indicators with labels, and a blank line
|
||||
- comparison lines: similar to “unified” view on GitHub, and **changed substrings** have **inverse** foreground and background colors (that is, `from` has white-on-green and `to` has white-on-red, which the following example does not show)
|
||||
|
||||
```diff
|
||||
- Expected
|
||||
+ Received
|
||||
|
||||
common
|
||||
- changed from
|
||||
+ changed to
|
||||
```
|
||||
|
||||
### Performance of diffStringsUnified
|
||||
|
||||
To get the benefit of **changed substrings** within the comparison lines, a character-by-character comparison has a higher computational cost (in time and space) than a line-by-line comparison.
|
||||
|
||||
If the input strings can have **arbitrary length**, we recommend that the calling code set a limit, beyond which splits the strings, and then calls `diffLinesUnified` instead. For example, Jest falls back to line-by-line comparison if either string has length greater than 20K characters.
|
||||
|
||||
## Usage of diffLinesUnified
|
||||
|
||||
Given **arrays of strings**, `diffLinesUnified(aLines, bLines, options?)` does the following:
|
||||
|
||||
1. **compare** the arrays line-by-line using the `diff-sequences` package
|
||||
2. **format** the changed or common lines using the `chalk` package
|
||||
|
||||
You might call this function when strings have been split into lines and you do not need to see changed substrings within lines.
|
||||
|
||||
### Example of diffLinesUnified
|
||||
|
||||
```js
|
||||
const aLines = ['delete', 'common', 'changed from'];
|
||||
const bLines = ['common', 'changed to', 'insert'];
|
||||
|
||||
const difference = diffLinesUnified(aLines, bLines);
|
||||
```
|
||||
|
||||
```diff
|
||||
- Expected
|
||||
+ Received
|
||||
|
||||
- delete
|
||||
common
|
||||
- changed from
|
||||
+ changed to
|
||||
+ insert
|
||||
```
|
||||
|
||||
### Edge cases of diffLinesUnified or diffStringsUnified
|
||||
|
||||
Here are edge cases for arguments and return values:
|
||||
|
||||
- both `a` and `b` are empty strings: no comparison lines
|
||||
- only `a` is empty string: all comparison lines have `bColor` and `bIndicator` (see Options)
|
||||
- only `b` is empty string: all comparison lines have `aColor` and `aIndicator` (see Options)
|
||||
- `a` and `b` are equal non-empty strings: all comparison lines have `commonColor` and `commonIndicator` (see Options)
|
||||
|
||||
## Usage of diffLinesUnified2
|
||||
|
||||
Given two **pairs** of arrays of strings, `diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options?)` does the following:
|
||||
|
||||
1. **compare** the pair of `Compare` arrays line-by-line using the `diff-sequences` package
|
||||
2. **format** the corresponding lines in the pair of `Display` arrays using the `chalk` package
|
||||
|
||||
Jest calls this function to consider lines as common instead of changed if the only difference is indentation.
|
||||
|
||||
You might call this function for case insensitive or Unicode equivalence comparison of lines.
|
||||
|
||||
### Example of diffLinesUnified2
|
||||
|
||||
```js
|
||||
import format from 'pretty-format';
|
||||
|
||||
const a = {
|
||||
text: 'Ignore indentation in serialized object',
|
||||
time: '2019-09-19T12:34:56.000Z',
|
||||
type: 'CREATE_ITEM',
|
||||
};
|
||||
const b = {
|
||||
payload: {
|
||||
text: 'Ignore indentation in serialized object',
|
||||
time: '2019-09-19T12:34:56.000Z',
|
||||
},
|
||||
type: 'CREATE_ITEM',
|
||||
};
|
||||
|
||||
const difference = diffLinesUnified2(
|
||||
// serialize with indentation to display lines
|
||||
format(a).split('\n'),
|
||||
format(b).split('\n'),
|
||||
// serialize without indentation to compare lines
|
||||
format(a, {indent: 0}).split('\n'),
|
||||
format(b, {indent: 0}).split('\n'),
|
||||
);
|
||||
```
|
||||
|
||||
The `text` and `time` properties are common, because their only difference is indentation:
|
||||
|
||||
```diff
|
||||
- Expected
|
||||
+ Received
|
||||
|
||||
Object {
|
||||
+ payload: Object {
|
||||
text: 'Ignore indentation in serialized object',
|
||||
time: '2019-09-19T12:34:56.000Z',
|
||||
+ },
|
||||
type: 'CREATE_ITEM',
|
||||
}
|
||||
```
|
||||
|
||||
The preceding example illustrates why (at least for indentation) it seems more intuitive that the function returns the common line from the `bLinesDisplay` array instead of from the `aLinesDisplay` array.
|
||||
|
||||
## Usage of diffStringsRaw
|
||||
|
||||
Given **strings** and a boolean option, `diffStringsRaw(a, b, cleanup)` does the following:
|
||||
|
||||
1. **compare** the strings character-by-character using the `diff-sequences` package
|
||||
2. optionally **clean up** small (often coincidental) common substrings, also known as chaff
|
||||
|
||||
Because `diffStringsRaw` returns the difference as **data** instead of a string, you can format it as your application requires (for example, enclosed in HTML markup for browser instead of escape sequences for console).
|
||||
|
||||
The returned **array** describes substrings as instances of the `Diff` class, which calling code can access like array tuples:
|
||||
|
||||
The value at index `0` is one of the following:
|
||||
|
||||
| value | named export | description |
|
||||
| ----: | :------------ | :-------------------- |
|
||||
| `0` | `DIFF_EQUAL` | in `a` and in `b` |
|
||||
| `-1` | `DIFF_DELETE` | in `a` but not in `b` |
|
||||
| `1` | `DIFF_INSERT` | in `b` but not in `a` |
|
||||
|
||||
The value at index `1` is a substring of `a` or `b` or both.
|
||||
|
||||
### Example of diffStringsRaw with cleanup
|
||||
|
||||
```js
|
||||
const diffs = diffStringsRaw('changed from', 'changed to', true);
|
||||
```
|
||||
|
||||
| `i` | `diffs[i][0]` | `diffs[i][1]` |
|
||||
| --: | ------------: | :------------ |
|
||||
| `0` | `0` | `'changed '` |
|
||||
| `1` | `-1` | `'from'` |
|
||||
| `2` | `1` | `'to'` |
|
||||
|
||||
### Example of diffStringsRaw without cleanup
|
||||
|
||||
```js
|
||||
const diffs = diffStringsRaw('changed from', 'changed to', false);
|
||||
```
|
||||
|
||||
| `i` | `diffs[i][0]` | `diffs[i][1]` |
|
||||
| --: | ------------: | :------------ |
|
||||
| `0` | `0` | `'changed '` |
|
||||
| `1` | `-1` | `'fr'` |
|
||||
| `2` | `1` | `'t'` |
|
||||
| `3` | `0` | `'o'` |
|
||||
| `4` | `-1` | `'m'` |
|
||||
|
||||
### Advanced import for diffStringsRaw
|
||||
|
||||
Here are all the named imports that you might need for the `diffStringsRaw` function:
|
||||
|
||||
- `const {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} = require('jest-diff');` in CommonJS modules
|
||||
- `import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} from 'jest-diff';` in ECMAScript modules
|
||||
|
||||
To write a **formatting** function, you might need the named constants (and `Diff` in TypeScript annotations).
|
||||
|
||||
If you write an application-specific **cleanup** algorithm, then you might need to call the `Diff` constructor:
|
||||
|
||||
```js
|
||||
const diffCommon = new Diff(DIFF_EQUAL, 'changed ');
|
||||
const diffDelete = new Diff(DIFF_DELETE, 'from');
|
||||
const diffInsert = new Diff(DIFF_INSERT, 'to');
|
||||
```
|
||||
|
||||
## Usage of diffLinesRaw
|
||||
|
||||
Given **arrays of strings**, `diffLinesRaw(aLines, bLines)` does the following:
|
||||
|
||||
- **compare** the arrays line-by-line using the `diff-sequences` package
|
||||
|
||||
Because `diffLinesRaw` returns the difference as **data** instead of a string, you can format it as your application requires.
|
||||
|
||||
### Example of diffLinesRaw
|
||||
|
||||
```js
|
||||
const aLines = ['delete', 'common', 'changed from'];
|
||||
const bLines = ['common', 'changed to', 'insert'];
|
||||
|
||||
const diffs = diffLinesRaw(aLines, bLines);
|
||||
```
|
||||
|
||||
| `i` | `diffs[i][0]` | `diffs[i][1]` |
|
||||
| --: | ------------: | :--------------- |
|
||||
| `0` | `-1` | `'delete'` |
|
||||
| `1` | `0` | `'common'` |
|
||||
| `2` | `-1` | `'changed from'` |
|
||||
| `3` | `1` | `'changed to'` |
|
||||
| `4` | `1` | `'insert'` |
|
||||
|
||||
### Edge case of diffLinesRaw
|
||||
|
||||
If you call `string.split('\n')` for an empty string:
|
||||
|
||||
- the result is `['']` an array which contains an empty string
|
||||
- instead of `[]` an empty array
|
||||
|
||||
Depending of your application, you might call `diffLinesRaw` with either array.
|
||||
|
||||
### Example of split method
|
||||
|
||||
```js
|
||||
import {diffLinesRaw} from 'jest-diff';
|
||||
|
||||
const a = 'non-empty string';
|
||||
const b = '';
|
||||
|
||||
const diffs = diffLinesRaw(a.split('\n'), b.split('\n'));
|
||||
```
|
||||
|
||||
| `i` | `diffs[i][0]` | `diffs[i][1]` |
|
||||
| --: | ------------: | :------------------- |
|
||||
| `0` | `-1` | `'non-empty string'` |
|
||||
| `1` | `1` | `''` |
|
||||
|
||||
Which you might format as follows:
|
||||
|
||||
```diff
|
||||
- Expected - 1
|
||||
+ Received + 1
|
||||
|
||||
- non-empty string
|
||||
+
|
||||
```
|
||||
|
||||
### Example of splitLines0 function
|
||||
|
||||
For edge case behavior like the `diffLinesUnified` function, you might define a `splitLines0` function, which given an empty string, returns `[]` an empty array:
|
||||
|
||||
```js
|
||||
export const splitLines0 = string =>
|
||||
string.length === 0 ? [] : string.split('\n');
|
||||
```
|
||||
|
||||
```js
|
||||
import {diffLinesRaw} from 'jest-diff';
|
||||
|
||||
const a = '';
|
||||
const b = 'line 1\nline 2\nline 3';
|
||||
|
||||
const diffs = diffLinesRaw(a.split('\n'), b.split('\n'));
|
||||
```
|
||||
|
||||
| `i` | `diffs[i][0]` | `diffs[i][1]` |
|
||||
| --: | ------------: | :------------ |
|
||||
| `0` | `1` | `'line 1'` |
|
||||
| `1` | `1` | `'line 2'` |
|
||||
| `2` | `1` | `'line 3'` |
|
||||
|
||||
Which you might format as follows:
|
||||
|
||||
```diff
|
||||
- Expected - 0
|
||||
+ Received + 3
|
||||
|
||||
+ line 1
|
||||
+ line 2
|
||||
+ line 3
|
||||
```
|
||||
|
||||
In contrast to the `diffLinesRaw` function, the `diffLinesUnified` and `diffLinesUnified2` functions **automatically** convert array arguments computed by string `split` method, so callers do **not** need a `splitLine0` function.
|
||||
|
||||
## Options
|
||||
|
||||
The default options are for the report when an assertion fails from the `expect` package used by Jest.
|
||||
|
||||
For other applications, you can provide an options object as a third argument:
|
||||
|
||||
- `diffDefault(a, b, options)`
|
||||
- `diffStringsUnified(a, b, options)`
|
||||
- `diffLinesUnified(aLines, bLines, options)`
|
||||
- `diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options)`
|
||||
|
||||
### Properties of options object
|
||||
|
||||
| name | default |
|
||||
| :-------------------------------- | :----------------- |
|
||||
| `aAnnotation` | `'Expected'` |
|
||||
| `aColor` | `chalk.green` |
|
||||
| `aIndicator` | `'-'` |
|
||||
| `bAnnotation` | `'Received'` |
|
||||
| `bColor` | `chalk.red` |
|
||||
| `bIndicator` | `'+'` |
|
||||
| `changeColor` | `chalk.inverse` |
|
||||
| `changeLineTrailingSpaceColor` | `string => string` |
|
||||
| `commonColor` | `chalk.dim` |
|
||||
| `commonIndicator` | `' '` |
|
||||
| `commonLineTrailingSpaceColor` | `string => string` |
|
||||
| `contextLines` | `5` |
|
||||
| `emptyFirstOrLastLinePlaceholder` | `''` |
|
||||
| `expand` | `true` |
|
||||
| `includeChangeCounts` | `false` |
|
||||
| `omitAnnotationLines` | `false` |
|
||||
| `patchColor` | `chalk.yellow` |
|
||||
|
||||
For more information about the options, see the following examples.
|
||||
|
||||
### Example of options for labels
|
||||
|
||||
If the application is code modification, you might replace the labels:
|
||||
|
||||
```js
|
||||
const options = {
|
||||
aAnnotation: 'Original',
|
||||
bAnnotation: 'Modified',
|
||||
};
|
||||
```
|
||||
|
||||
```diff
|
||||
- Original
|
||||
+ Modified
|
||||
|
||||
common
|
||||
- changed from
|
||||
+ changed to
|
||||
```
|
||||
|
||||
The `jest-diff` package does not assume that the 2 labels have equal length.
|
||||
|
||||
### Example of options for colors of changed lines
|
||||
|
||||
For consistency with most diff tools, you might exchange the colors:
|
||||
|
||||
```ts
|
||||
import chalk = require('chalk');
|
||||
|
||||
const options = {
|
||||
aColor: chalk.red,
|
||||
bColor: chalk.green,
|
||||
};
|
||||
```
|
||||
|
||||
### Example of option for color of changed substrings
|
||||
|
||||
Although the default inverse of foreground and background colors is hard to beat for changed substrings **within lines**, especially because it highlights spaces, if you want bold font weight on yellow background color:
|
||||
|
||||
```ts
|
||||
import chalk = require('chalk');
|
||||
|
||||
const options = {
|
||||
changeColor: chalk.bold.bgYellowBright,
|
||||
};
|
||||
```
|
||||
|
||||
### Example of option to format trailing spaces
|
||||
|
||||
Because the default export does not display substring differences within lines, formatting can help you see when lines differ by the presence or absence of trailing spaces found by `/\s+$/` regular expression.
|
||||
|
||||
- If change lines have a background color, then you can see trailing spaces.
|
||||
- If common lines have default dim color, then you cannot see trailing spaces. You might want yellowish background color to see them.
|
||||
|
||||
```js
|
||||
const options = {
|
||||
aColor: chalk.rgb(128, 0, 128).bgRgb(255, 215, 255), // magenta
|
||||
bColor: chalk.rgb(0, 95, 0).bgRgb(215, 255, 215), // green
|
||||
commonLineTrailingSpaceColor: chalk.bgYellow,
|
||||
};
|
||||
```
|
||||
|
||||
The value of a Color option is a function, which given a string, returns a string.
|
||||
|
||||
If you want to replace trailing spaces with middle dot characters:
|
||||
|
||||
```js
|
||||
const replaceSpacesWithMiddleDot = string => '·'.repeat(string.length);
|
||||
|
||||
const options = {
|
||||
changeLineTrailingSpaceColor: replaceSpacesWithMiddleDot,
|
||||
commonLineTrailingSpaceColor: replaceSpacesWithMiddleDot,
|
||||
};
|
||||
```
|
||||
|
||||
If you need the TypeScript type of a Color option:
|
||||
|
||||
```ts
|
||||
import {DiffOptionsColor} from 'jest-diff';
|
||||
```
|
||||
|
||||
### Example of options for no colors
|
||||
|
||||
To store the difference in a file without escape codes for colors, provide an identity function:
|
||||
|
||||
```js
|
||||
const noColor = string => string;
|
||||
|
||||
const options = {
|
||||
aColor: noColor,
|
||||
bColor: noColor,
|
||||
changeColor: noColor,
|
||||
commonColor: noColor,
|
||||
patchColor: noColor,
|
||||
};
|
||||
```
|
||||
|
||||
### Example of options for indicators
|
||||
|
||||
For consistency with the `diff` command, you might replace the indicators:
|
||||
|
||||
```js
|
||||
const options = {
|
||||
aIndicator: '<',
|
||||
bIndicator: '>',
|
||||
};
|
||||
```
|
||||
|
||||
The `jest-diff` package assumes (but does not enforce) that the 3 indicators have equal length.
|
||||
|
||||
### Example of options to limit common lines
|
||||
|
||||
By default, the output includes all common lines.
|
||||
|
||||
To emphasize the changes, you might limit the number of common “context” lines:
|
||||
|
||||
```js
|
||||
const options = {
|
||||
contextLines: 1,
|
||||
expand: false,
|
||||
};
|
||||
```
|
||||
|
||||
A patch mark like `@@ -12,7 +12,9 @@` accounts for omitted common lines.
|
||||
|
||||
### Example of option for color of patch marks
|
||||
|
||||
If you want patch marks to have the same dim color as common lines:
|
||||
|
||||
```ts
|
||||
import chalk = require('chalk');
|
||||
|
||||
const options = {
|
||||
expand: false,
|
||||
patchColor: chalk.dim,
|
||||
};
|
||||
```
|
||||
|
||||
### Example of option to include change counts
|
||||
|
||||
To display the number of changed lines at the right of annotation lines:
|
||||
|
||||
```js
|
||||
const a = ['common', 'changed from'];
|
||||
const b = ['common', 'changed to', 'insert'];
|
||||
|
||||
const options = {
|
||||
includeChangeCounts: true,
|
||||
};
|
||||
|
||||
const difference = diffDefault(a, b, options);
|
||||
```
|
||||
|
||||
```diff
|
||||
- Expected - 1
|
||||
+ Received + 2
|
||||
|
||||
Array [
|
||||
"common",
|
||||
- "changed from",
|
||||
+ "changed to",
|
||||
+ "insert",
|
||||
]
|
||||
```
|
||||
|
||||
### Example of option to omit annotation lines
|
||||
|
||||
To display only the comparison lines:
|
||||
|
||||
```js
|
||||
const a = 'common\nchanged from';
|
||||
const b = 'common\nchanged to';
|
||||
|
||||
const options = {
|
||||
omitAnnotationLines: true,
|
||||
};
|
||||
|
||||
const difference = diffStringsUnified(a, b, options);
|
||||
```
|
||||
|
||||
```diff
|
||||
common
|
||||
- changed from
|
||||
+ changed to
|
||||
```
|
||||
|
||||
### Example of option for empty first or last lines
|
||||
|
||||
If the **first** or **last** comparison line is **empty**, because the content is empty and the indicator is a space, you might not notice it.
|
||||
|
||||
The replacement option is a string whose default value is `''` empty string.
|
||||
|
||||
Because Jest trims the report when a matcher fails, it deletes an empty last line.
|
||||
|
||||
Therefore, Jest uses as placeholder the downwards arrow with corner leftwards:
|
||||
|
||||
```js
|
||||
const options = {
|
||||
emptyFirstOrLastLinePlaceholder: '↵', // U+21B5
|
||||
};
|
||||
```
|
||||
|
||||
If a content line is empty, then the corresponding comparison line is automatically trimmed to remove the margin space (represented as a middle dot below) for the default indicators:
|
||||
|
||||
| Indicator | untrimmed | trimmed |
|
||||
| ----------------: | :-------- | :------ |
|
||||
| `aIndicator` | `'-·'` | `'-'` |
|
||||
| `bIndicator` | `'+·'` | `'+'` |
|
||||
| `commonIndicator` | `' ·'` | `''` |
|
57
web/node_modules/jest-diff/build/cleanupSemantic.d.ts
generated
vendored
Normal file
57
web/node_modules/jest-diff/build/cleanupSemantic.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Diff Match and Patch
|
||||
* Copyright 2018 The diff-match-patch Authors.
|
||||
* https://github.com/google/diff-match-patch
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* @fileoverview Computes the difference between two texts to create a patch.
|
||||
* Applies the patch onto another text, allowing for errors.
|
||||
* @author fraser@google.com (Neil Fraser)
|
||||
*/
|
||||
/**
|
||||
* CHANGES by pedrottimark to diff_match_patch_uncompressed.ts file:
|
||||
*
|
||||
* 1. Delete anything not needed to use diff_cleanupSemantic method
|
||||
* 2. Convert from prototype properties to var declarations
|
||||
* 3. Convert Diff to class from constructor and prototype
|
||||
* 4. Add type annotations for arguments and return values
|
||||
* 5. Add exports
|
||||
*/
|
||||
/**
|
||||
* The data structure representing a diff is an array of tuples:
|
||||
* [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
|
||||
* which means: delete 'Hello', add 'Goodbye' and keep ' world.'
|
||||
*/
|
||||
declare var DIFF_DELETE: number;
|
||||
declare var DIFF_INSERT: number;
|
||||
declare var DIFF_EQUAL: number;
|
||||
/**
|
||||
* Class representing one diff tuple.
|
||||
* Attempts to look like a two-element array (which is what this used to be).
|
||||
* @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
|
||||
* @param {string} text Text to be deleted, inserted, or retained.
|
||||
* @constructor
|
||||
*/
|
||||
declare class Diff {
|
||||
0: number;
|
||||
1: string;
|
||||
constructor(op: number, text: string);
|
||||
}
|
||||
/**
|
||||
* Reduce the number of edits by eliminating semantically trivial equalities.
|
||||
* @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
|
||||
*/
|
||||
declare var diff_cleanupSemantic: (diffs: Array<Diff>) => void;
|
||||
export { Diff, DIFF_EQUAL, DIFF_DELETE, DIFF_INSERT, diff_cleanupSemantic as cleanupSemantic, };
|
651
web/node_modules/jest-diff/build/cleanupSemantic.js
generated
vendored
Normal file
651
web/node_modules/jest-diff/build/cleanupSemantic.js
generated
vendored
Normal file
|
@ -0,0 +1,651 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.cleanupSemantic = exports.DIFF_INSERT = exports.DIFF_DELETE = exports.DIFF_EQUAL = exports.Diff = void 0;
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff Match and Patch
|
||||
* Copyright 2018 The diff-match-patch Authors.
|
||||
* https://github.com/google/diff-match-patch
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Computes the difference between two texts to create a patch.
|
||||
* Applies the patch onto another text, allowing for errors.
|
||||
* @author fraser@google.com (Neil Fraser)
|
||||
*/
|
||||
|
||||
/**
|
||||
* CHANGES by pedrottimark to diff_match_patch_uncompressed.ts file:
|
||||
*
|
||||
* 1. Delete anything not needed to use diff_cleanupSemantic method
|
||||
* 2. Convert from prototype properties to var declarations
|
||||
* 3. Convert Diff to class from constructor and prototype
|
||||
* 4. Add type annotations for arguments and return values
|
||||
* 5. Add exports
|
||||
*/
|
||||
|
||||
/**
|
||||
* The data structure representing a diff is an array of tuples:
|
||||
* [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
|
||||
* which means: delete 'Hello', add 'Goodbye' and keep ' world.'
|
||||
*/
|
||||
var DIFF_DELETE = -1;
|
||||
exports.DIFF_DELETE = DIFF_DELETE;
|
||||
var DIFF_INSERT = 1;
|
||||
exports.DIFF_INSERT = DIFF_INSERT;
|
||||
var DIFF_EQUAL = 0;
|
||||
/**
|
||||
* Class representing one diff tuple.
|
||||
* Attempts to look like a two-element array (which is what this used to be).
|
||||
* @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
|
||||
* @param {string} text Text to be deleted, inserted, or retained.
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
exports.DIFF_EQUAL = DIFF_EQUAL;
|
||||
|
||||
class Diff {
|
||||
constructor(op, text) {
|
||||
_defineProperty(this, 0, void 0);
|
||||
|
||||
_defineProperty(this, 1, void 0);
|
||||
|
||||
this[0] = op;
|
||||
this[1] = text;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determine the common prefix of two strings.
|
||||
* @param {string} text1 First string.
|
||||
* @param {string} text2 Second string.
|
||||
* @return {number} The number of characters common to the start of each
|
||||
* string.
|
||||
*/
|
||||
|
||||
exports.Diff = Diff;
|
||||
|
||||
var diff_commonPrefix = function (text1, text2) {
|
||||
// Quick check for common null cases.
|
||||
if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
|
||||
return 0;
|
||||
} // Binary search.
|
||||
// Performance analysis: https://neil.fraser.name/news/2007/10/09/
|
||||
|
||||
var pointermin = 0;
|
||||
var pointermax = Math.min(text1.length, text2.length);
|
||||
var pointermid = pointermax;
|
||||
var pointerstart = 0;
|
||||
|
||||
while (pointermin < pointermid) {
|
||||
if (
|
||||
text1.substring(pointerstart, pointermid) ==
|
||||
text2.substring(pointerstart, pointermid)
|
||||
) {
|
||||
pointermin = pointermid;
|
||||
pointerstart = pointermin;
|
||||
} else {
|
||||
pointermax = pointermid;
|
||||
}
|
||||
|
||||
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
||||
}
|
||||
|
||||
return pointermid;
|
||||
};
|
||||
/**
|
||||
* Determine the common suffix of two strings.
|
||||
* @param {string} text1 First string.
|
||||
* @param {string} text2 Second string.
|
||||
* @return {number} The number of characters common to the end of each string.
|
||||
*/
|
||||
|
||||
var diff_commonSuffix = function (text1, text2) {
|
||||
// Quick check for common null cases.
|
||||
if (
|
||||
!text1 ||
|
||||
!text2 ||
|
||||
text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)
|
||||
) {
|
||||
return 0;
|
||||
} // Binary search.
|
||||
// Performance analysis: https://neil.fraser.name/news/2007/10/09/
|
||||
|
||||
var pointermin = 0;
|
||||
var pointermax = Math.min(text1.length, text2.length);
|
||||
var pointermid = pointermax;
|
||||
var pointerend = 0;
|
||||
|
||||
while (pointermin < pointermid) {
|
||||
if (
|
||||
text1.substring(text1.length - pointermid, text1.length - pointerend) ==
|
||||
text2.substring(text2.length - pointermid, text2.length - pointerend)
|
||||
) {
|
||||
pointermin = pointermid;
|
||||
pointerend = pointermin;
|
||||
} else {
|
||||
pointermax = pointermid;
|
||||
}
|
||||
|
||||
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
||||
}
|
||||
|
||||
return pointermid;
|
||||
};
|
||||
/**
|
||||
* Determine if the suffix of one string is the prefix of another.
|
||||
* @param {string} text1 First string.
|
||||
* @param {string} text2 Second string.
|
||||
* @return {number} The number of characters common to the end of the first
|
||||
* string and the start of the second string.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var diff_commonOverlap_ = function (text1, text2) {
|
||||
// Cache the text lengths to prevent multiple calls.
|
||||
var text1_length = text1.length;
|
||||
var text2_length = text2.length; // Eliminate the null case.
|
||||
|
||||
if (text1_length == 0 || text2_length == 0) {
|
||||
return 0;
|
||||
} // Truncate the longer string.
|
||||
|
||||
if (text1_length > text2_length) {
|
||||
text1 = text1.substring(text1_length - text2_length);
|
||||
} else if (text1_length < text2_length) {
|
||||
text2 = text2.substring(0, text1_length);
|
||||
}
|
||||
|
||||
var text_length = Math.min(text1_length, text2_length); // Quick check for the worst case.
|
||||
|
||||
if (text1 == text2) {
|
||||
return text_length;
|
||||
} // Start by looking for a single character match
|
||||
// and increase length until no match is found.
|
||||
// Performance analysis: https://neil.fraser.name/news/2010/11/04/
|
||||
|
||||
var best = 0;
|
||||
var length = 1;
|
||||
|
||||
while (true) {
|
||||
var pattern = text1.substring(text_length - length);
|
||||
var found = text2.indexOf(pattern);
|
||||
|
||||
if (found == -1) {
|
||||
return best;
|
||||
}
|
||||
|
||||
length += found;
|
||||
|
||||
if (
|
||||
found == 0 ||
|
||||
text1.substring(text_length - length) == text2.substring(0, length)
|
||||
) {
|
||||
best = length;
|
||||
length++;
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Reduce the number of edits by eliminating semantically trivial equalities.
|
||||
* @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
|
||||
*/
|
||||
|
||||
var diff_cleanupSemantic = function (diffs) {
|
||||
var changes = false;
|
||||
var equalities = []; // Stack of indices where equalities are found.
|
||||
|
||||
var equalitiesLength = 0; // Keeping our own length var is faster in JS.
|
||||
|
||||
/** @type {?string} */
|
||||
|
||||
var lastEquality = null; // Always equal to diffs[equalities[equalitiesLength - 1]][1]
|
||||
|
||||
var pointer = 0; // Index of current position.
|
||||
// Number of characters that changed prior to the equality.
|
||||
|
||||
var length_insertions1 = 0;
|
||||
var length_deletions1 = 0; // Number of characters that changed after the equality.
|
||||
|
||||
var length_insertions2 = 0;
|
||||
var length_deletions2 = 0;
|
||||
|
||||
while (pointer < diffs.length) {
|
||||
if (diffs[pointer][0] == DIFF_EQUAL) {
|
||||
// Equality found.
|
||||
equalities[equalitiesLength++] = pointer;
|
||||
length_insertions1 = length_insertions2;
|
||||
length_deletions1 = length_deletions2;
|
||||
length_insertions2 = 0;
|
||||
length_deletions2 = 0;
|
||||
lastEquality = diffs[pointer][1];
|
||||
} else {
|
||||
// An insertion or deletion.
|
||||
if (diffs[pointer][0] == DIFF_INSERT) {
|
||||
length_insertions2 += diffs[pointer][1].length;
|
||||
} else {
|
||||
length_deletions2 += diffs[pointer][1].length;
|
||||
} // Eliminate an equality that is smaller or equal to the edits on both
|
||||
// sides of it.
|
||||
|
||||
if (
|
||||
lastEquality &&
|
||||
lastEquality.length <=
|
||||
Math.max(length_insertions1, length_deletions1) &&
|
||||
lastEquality.length <= Math.max(length_insertions2, length_deletions2)
|
||||
) {
|
||||
// Duplicate record.
|
||||
diffs.splice(
|
||||
equalities[equalitiesLength - 1],
|
||||
0,
|
||||
new Diff(DIFF_DELETE, lastEquality)
|
||||
); // Change second copy to insert.
|
||||
|
||||
diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; // Throw away the equality we just deleted.
|
||||
|
||||
equalitiesLength--; // Throw away the previous equality (it needs to be reevaluated).
|
||||
|
||||
equalitiesLength--;
|
||||
pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
|
||||
length_insertions1 = 0; // Reset the counters.
|
||||
|
||||
length_deletions1 = 0;
|
||||
length_insertions2 = 0;
|
||||
length_deletions2 = 0;
|
||||
lastEquality = null;
|
||||
changes = true;
|
||||
}
|
||||
}
|
||||
|
||||
pointer++;
|
||||
} // Normalize the diff.
|
||||
|
||||
if (changes) {
|
||||
diff_cleanupMerge(diffs);
|
||||
}
|
||||
|
||||
diff_cleanupSemanticLossless(diffs); // Find any overlaps between deletions and insertions.
|
||||
// e.g: <del>abcxxx</del><ins>xxxdef</ins>
|
||||
// -> <del>abc</del>xxx<ins>def</ins>
|
||||
// e.g: <del>xxxabc</del><ins>defxxx</ins>
|
||||
// -> <ins>def</ins>xxx<del>abc</del>
|
||||
// Only extract an overlap if it is as big as the edit ahead or behind it.
|
||||
|
||||
pointer = 1;
|
||||
|
||||
while (pointer < diffs.length) {
|
||||
if (
|
||||
diffs[pointer - 1][0] == DIFF_DELETE &&
|
||||
diffs[pointer][0] == DIFF_INSERT
|
||||
) {
|
||||
var deletion = diffs[pointer - 1][1];
|
||||
var insertion = diffs[pointer][1];
|
||||
var overlap_length1 = diff_commonOverlap_(deletion, insertion);
|
||||
var overlap_length2 = diff_commonOverlap_(insertion, deletion);
|
||||
|
||||
if (overlap_length1 >= overlap_length2) {
|
||||
if (
|
||||
overlap_length1 >= deletion.length / 2 ||
|
||||
overlap_length1 >= insertion.length / 2
|
||||
) {
|
||||
// Overlap found. Insert an equality and trim the surrounding edits.
|
||||
diffs.splice(
|
||||
pointer,
|
||||
0,
|
||||
new Diff(DIFF_EQUAL, insertion.substring(0, overlap_length1))
|
||||
);
|
||||
diffs[pointer - 1][1] = deletion.substring(
|
||||
0,
|
||||
deletion.length - overlap_length1
|
||||
);
|
||||
diffs[pointer + 1][1] = insertion.substring(overlap_length1);
|
||||
pointer++;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
overlap_length2 >= deletion.length / 2 ||
|
||||
overlap_length2 >= insertion.length / 2
|
||||
) {
|
||||
// Reverse overlap found.
|
||||
// Insert an equality and swap and trim the surrounding edits.
|
||||
diffs.splice(
|
||||
pointer,
|
||||
0,
|
||||
new Diff(DIFF_EQUAL, deletion.substring(0, overlap_length2))
|
||||
);
|
||||
diffs[pointer - 1][0] = DIFF_INSERT;
|
||||
diffs[pointer - 1][1] = insertion.substring(
|
||||
0,
|
||||
insertion.length - overlap_length2
|
||||
);
|
||||
diffs[pointer + 1][0] = DIFF_DELETE;
|
||||
diffs[pointer + 1][1] = deletion.substring(overlap_length2);
|
||||
pointer++;
|
||||
}
|
||||
}
|
||||
|
||||
pointer++;
|
||||
}
|
||||
|
||||
pointer++;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Look for single edits surrounded on both sides by equalities
|
||||
* which can be shifted sideways to align the edit to a word boundary.
|
||||
* e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
|
||||
* @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
|
||||
*/
|
||||
|
||||
exports.cleanupSemantic = diff_cleanupSemantic;
|
||||
|
||||
var diff_cleanupSemanticLossless = function (diffs) {
|
||||
/**
|
||||
* Given two strings, compute a score representing whether the internal
|
||||
* boundary falls on logical boundaries.
|
||||
* Scores range from 6 (best) to 0 (worst).
|
||||
* Closure, but does not reference any external variables.
|
||||
* @param {string} one First string.
|
||||
* @param {string} two Second string.
|
||||
* @return {number} The score.
|
||||
* @private
|
||||
*/
|
||||
function diff_cleanupSemanticScore_(one, two) {
|
||||
if (!one || !two) {
|
||||
// Edges are the best.
|
||||
return 6;
|
||||
} // Each port of this function behaves slightly differently due to
|
||||
// subtle differences in each language's definition of things like
|
||||
// 'whitespace'. Since this function's purpose is largely cosmetic,
|
||||
// the choice has been made to use each language's native features
|
||||
// rather than force total conformity.
|
||||
|
||||
var char1 = one.charAt(one.length - 1);
|
||||
var char2 = two.charAt(0);
|
||||
var nonAlphaNumeric1 = char1.match(nonAlphaNumericRegex_);
|
||||
var nonAlphaNumeric2 = char2.match(nonAlphaNumericRegex_);
|
||||
var whitespace1 = nonAlphaNumeric1 && char1.match(whitespaceRegex_);
|
||||
var whitespace2 = nonAlphaNumeric2 && char2.match(whitespaceRegex_);
|
||||
var lineBreak1 = whitespace1 && char1.match(linebreakRegex_);
|
||||
var lineBreak2 = whitespace2 && char2.match(linebreakRegex_);
|
||||
var blankLine1 = lineBreak1 && one.match(blanklineEndRegex_);
|
||||
var blankLine2 = lineBreak2 && two.match(blanklineStartRegex_);
|
||||
|
||||
if (blankLine1 || blankLine2) {
|
||||
// Five points for blank lines.
|
||||
return 5;
|
||||
} else if (lineBreak1 || lineBreak2) {
|
||||
// Four points for line breaks.
|
||||
return 4;
|
||||
} else if (nonAlphaNumeric1 && !whitespace1 && whitespace2) {
|
||||
// Three points for end of sentences.
|
||||
return 3;
|
||||
} else if (whitespace1 || whitespace2) {
|
||||
// Two points for whitespace.
|
||||
return 2;
|
||||
} else if (nonAlphaNumeric1 || nonAlphaNumeric2) {
|
||||
// One point for non-alphanumeric.
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
var pointer = 1; // Intentionally ignore the first and last element (don't need checking).
|
||||
|
||||
while (pointer < diffs.length - 1) {
|
||||
if (
|
||||
diffs[pointer - 1][0] == DIFF_EQUAL &&
|
||||
diffs[pointer + 1][0] == DIFF_EQUAL
|
||||
) {
|
||||
// This is a single edit surrounded by equalities.
|
||||
var equality1 = diffs[pointer - 1][1];
|
||||
var edit = diffs[pointer][1];
|
||||
var equality2 = diffs[pointer + 1][1]; // First, shift the edit as far left as possible.
|
||||
|
||||
var commonOffset = diff_commonSuffix(equality1, edit);
|
||||
|
||||
if (commonOffset) {
|
||||
var commonString = edit.substring(edit.length - commonOffset);
|
||||
equality1 = equality1.substring(0, equality1.length - commonOffset);
|
||||
edit = commonString + edit.substring(0, edit.length - commonOffset);
|
||||
equality2 = commonString + equality2;
|
||||
} // Second, step character by character right, looking for the best fit.
|
||||
|
||||
var bestEquality1 = equality1;
|
||||
var bestEdit = edit;
|
||||
var bestEquality2 = equality2;
|
||||
var bestScore =
|
||||
diff_cleanupSemanticScore_(equality1, edit) +
|
||||
diff_cleanupSemanticScore_(edit, equality2);
|
||||
|
||||
while (edit.charAt(0) === equality2.charAt(0)) {
|
||||
equality1 += edit.charAt(0);
|
||||
edit = edit.substring(1) + equality2.charAt(0);
|
||||
equality2 = equality2.substring(1);
|
||||
var score =
|
||||
diff_cleanupSemanticScore_(equality1, edit) +
|
||||
diff_cleanupSemanticScore_(edit, equality2); // The >= encourages trailing rather than leading whitespace on edits.
|
||||
|
||||
if (score >= bestScore) {
|
||||
bestScore = score;
|
||||
bestEquality1 = equality1;
|
||||
bestEdit = edit;
|
||||
bestEquality2 = equality2;
|
||||
}
|
||||
}
|
||||
|
||||
if (diffs[pointer - 1][1] != bestEquality1) {
|
||||
// We have an improvement, save it back to the diff.
|
||||
if (bestEquality1) {
|
||||
diffs[pointer - 1][1] = bestEquality1;
|
||||
} else {
|
||||
diffs.splice(pointer - 1, 1);
|
||||
pointer--;
|
||||
}
|
||||
|
||||
diffs[pointer][1] = bestEdit;
|
||||
|
||||
if (bestEquality2) {
|
||||
diffs[pointer + 1][1] = bestEquality2;
|
||||
} else {
|
||||
diffs.splice(pointer + 1, 1);
|
||||
pointer--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pointer++;
|
||||
}
|
||||
}; // Define some regex patterns for matching boundaries.
|
||||
|
||||
var nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/;
|
||||
var whitespaceRegex_ = /\s/;
|
||||
var linebreakRegex_ = /[\r\n]/;
|
||||
var blanklineEndRegex_ = /\n\r?\n$/;
|
||||
var blanklineStartRegex_ = /^\r?\n\r?\n/;
|
||||
/**
|
||||
* Reorder and merge like edit sections. Merge equalities.
|
||||
* Any edit section can move as long as it doesn't cross an equality.
|
||||
* @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
|
||||
*/
|
||||
|
||||
var diff_cleanupMerge = function (diffs) {
|
||||
// Add a dummy entry at the end.
|
||||
diffs.push(new Diff(DIFF_EQUAL, ''));
|
||||
var pointer = 0;
|
||||
var count_delete = 0;
|
||||
var count_insert = 0;
|
||||
var text_delete = '';
|
||||
var text_insert = '';
|
||||
var commonlength;
|
||||
|
||||
while (pointer < diffs.length) {
|
||||
switch (diffs[pointer][0]) {
|
||||
case DIFF_INSERT:
|
||||
count_insert++;
|
||||
text_insert += diffs[pointer][1];
|
||||
pointer++;
|
||||
break;
|
||||
|
||||
case DIFF_DELETE:
|
||||
count_delete++;
|
||||
text_delete += diffs[pointer][1];
|
||||
pointer++;
|
||||
break;
|
||||
|
||||
case DIFF_EQUAL:
|
||||
// Upon reaching an equality, check for prior redundancies.
|
||||
if (count_delete + count_insert > 1) {
|
||||
if (count_delete !== 0 && count_insert !== 0) {
|
||||
// Factor out any common prefixies.
|
||||
commonlength = diff_commonPrefix(text_insert, text_delete);
|
||||
|
||||
if (commonlength !== 0) {
|
||||
if (
|
||||
pointer - count_delete - count_insert > 0 &&
|
||||
diffs[pointer - count_delete - count_insert - 1][0] ==
|
||||
DIFF_EQUAL
|
||||
) {
|
||||
diffs[
|
||||
pointer - count_delete - count_insert - 1
|
||||
][1] += text_insert.substring(0, commonlength);
|
||||
} else {
|
||||
diffs.splice(
|
||||
0,
|
||||
0,
|
||||
new Diff(DIFF_EQUAL, text_insert.substring(0, commonlength))
|
||||
);
|
||||
pointer++;
|
||||
}
|
||||
|
||||
text_insert = text_insert.substring(commonlength);
|
||||
text_delete = text_delete.substring(commonlength);
|
||||
} // Factor out any common suffixies.
|
||||
|
||||
commonlength = diff_commonSuffix(text_insert, text_delete);
|
||||
|
||||
if (commonlength !== 0) {
|
||||
diffs[pointer][1] =
|
||||
text_insert.substring(text_insert.length - commonlength) +
|
||||
diffs[pointer][1];
|
||||
text_insert = text_insert.substring(
|
||||
0,
|
||||
text_insert.length - commonlength
|
||||
);
|
||||
text_delete = text_delete.substring(
|
||||
0,
|
||||
text_delete.length - commonlength
|
||||
);
|
||||
}
|
||||
} // Delete the offending records and add the merged ones.
|
||||
|
||||
pointer -= count_delete + count_insert;
|
||||
diffs.splice(pointer, count_delete + count_insert);
|
||||
|
||||
if (text_delete.length) {
|
||||
diffs.splice(pointer, 0, new Diff(DIFF_DELETE, text_delete));
|
||||
pointer++;
|
||||
}
|
||||
|
||||
if (text_insert.length) {
|
||||
diffs.splice(pointer, 0, new Diff(DIFF_INSERT, text_insert));
|
||||
pointer++;
|
||||
}
|
||||
|
||||
pointer++;
|
||||
} else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
|
||||
// Merge this equality with the previous one.
|
||||
diffs[pointer - 1][1] += diffs[pointer][1];
|
||||
diffs.splice(pointer, 1);
|
||||
} else {
|
||||
pointer++;
|
||||
}
|
||||
|
||||
count_insert = 0;
|
||||
count_delete = 0;
|
||||
text_delete = '';
|
||||
text_insert = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (diffs[diffs.length - 1][1] === '') {
|
||||
diffs.pop(); // Remove the dummy entry at the end.
|
||||
} // Second pass: look for single edits surrounded on both sides by equalities
|
||||
// which can be shifted sideways to eliminate an equality.
|
||||
// e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
|
||||
|
||||
var changes = false;
|
||||
pointer = 1; // Intentionally ignore the first and last element (don't need checking).
|
||||
|
||||
while (pointer < diffs.length - 1) {
|
||||
if (
|
||||
diffs[pointer - 1][0] == DIFF_EQUAL &&
|
||||
diffs[pointer + 1][0] == DIFF_EQUAL
|
||||
) {
|
||||
// This is a single edit surrounded by equalities.
|
||||
if (
|
||||
diffs[pointer][1].substring(
|
||||
diffs[pointer][1].length - diffs[pointer - 1][1].length
|
||||
) == diffs[pointer - 1][1]
|
||||
) {
|
||||
// Shift the edit over the previous equality.
|
||||
diffs[pointer][1] =
|
||||
diffs[pointer - 1][1] +
|
||||
diffs[pointer][1].substring(
|
||||
0,
|
||||
diffs[pointer][1].length - diffs[pointer - 1][1].length
|
||||
);
|
||||
diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
|
||||
diffs.splice(pointer - 1, 1);
|
||||
changes = true;
|
||||
} else if (
|
||||
diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
|
||||
diffs[pointer + 1][1]
|
||||
) {
|
||||
// Shift the edit over the next equality.
|
||||
diffs[pointer - 1][1] += diffs[pointer + 1][1];
|
||||
diffs[pointer][1] =
|
||||
diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
|
||||
diffs[pointer + 1][1];
|
||||
diffs.splice(pointer + 1, 1);
|
||||
changes = true;
|
||||
}
|
||||
}
|
||||
|
||||
pointer++;
|
||||
} // If shifts were made, the diff needs reordering and another shift sweep.
|
||||
|
||||
if (changes) {
|
||||
diff_cleanupMerge(diffs);
|
||||
}
|
||||
};
|
8
web/node_modules/jest-diff/build/constants.d.ts
generated
vendored
Normal file
8
web/node_modules/jest-diff/build/constants.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare const NO_DIFF_MESSAGE = "Compared values have no visual difference.";
|
||||
export declare const SIMILAR_MESSAGE: string;
|
19
web/node_modules/jest-diff/build/constants.js
generated
vendored
Normal file
19
web/node_modules/jest-diff/build/constants.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.SIMILAR_MESSAGE = exports.NO_DIFF_MESSAGE = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const NO_DIFF_MESSAGE = 'Compared values have no visual difference.';
|
||||
exports.NO_DIFF_MESSAGE = NO_DIFF_MESSAGE;
|
||||
const SIMILAR_MESSAGE =
|
||||
'Compared values serialize to the same structure.\n' +
|
||||
'Printing internal object structure without calling `toJSON` instead.';
|
||||
exports.SIMILAR_MESSAGE = SIMILAR_MESSAGE;
|
11
web/node_modules/jest-diff/build/diffLines.d.ts
generated
vendored
Normal file
11
web/node_modules/jest-diff/build/diffLines.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Diff } from './cleanupSemantic';
|
||||
import type { DiffOptions } from './types';
|
||||
export declare const diffLinesUnified: (aLines: Array<string>, bLines: Array<string>, options?: DiffOptions | undefined) => string;
|
||||
export declare const diffLinesUnified2: (aLinesDisplay: Array<string>, bLinesDisplay: Array<string>, aLinesCompare: Array<string>, bLinesCompare: Array<string>, options?: DiffOptions | undefined) => string;
|
||||
export declare const diffLinesRaw: (aLines: Array<string>, bLines: Array<string>) => Array<Diff>;
|
143
web/node_modules/jest-diff/build/diffLines.js
generated
vendored
Normal file
143
web/node_modules/jest-diff/build/diffLines.js
generated
vendored
Normal file
|
@ -0,0 +1,143 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.diffLinesRaw = exports.diffLinesUnified2 = exports.diffLinesUnified = void 0;
|
||||
|
||||
var _diffSequences = _interopRequireDefault(require('diff-sequences'));
|
||||
|
||||
var _cleanupSemantic = require('./cleanupSemantic');
|
||||
|
||||
var _normalizeDiffOptions = require('./normalizeDiffOptions');
|
||||
|
||||
var _printDiffs = require('./printDiffs');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const isEmptyString = lines => lines.length === 1 && lines[0].length === 0; // Compare two arrays of strings line-by-line. Format as comparison lines.
|
||||
|
||||
const diffLinesUnified = (aLines, bLines, options) =>
|
||||
(0, _printDiffs.printDiffLines)(
|
||||
diffLinesRaw(
|
||||
isEmptyString(aLines) ? [] : aLines,
|
||||
isEmptyString(bLines) ? [] : bLines
|
||||
),
|
||||
(0, _normalizeDiffOptions.normalizeDiffOptions)(options)
|
||||
); // Given two pairs of arrays of strings:
|
||||
// Compare the pair of comparison arrays line-by-line.
|
||||
// Format the corresponding lines in the pair of displayable arrays.
|
||||
|
||||
exports.diffLinesUnified = diffLinesUnified;
|
||||
|
||||
const diffLinesUnified2 = (
|
||||
aLinesDisplay,
|
||||
bLinesDisplay,
|
||||
aLinesCompare,
|
||||
bLinesCompare,
|
||||
options
|
||||
) => {
|
||||
if (isEmptyString(aLinesDisplay) && isEmptyString(aLinesCompare)) {
|
||||
aLinesDisplay = [];
|
||||
aLinesCompare = [];
|
||||
}
|
||||
|
||||
if (isEmptyString(bLinesDisplay) && isEmptyString(bLinesCompare)) {
|
||||
bLinesDisplay = [];
|
||||
bLinesCompare = [];
|
||||
}
|
||||
|
||||
if (
|
||||
aLinesDisplay.length !== aLinesCompare.length ||
|
||||
bLinesDisplay.length !== bLinesCompare.length
|
||||
) {
|
||||
// Fall back to diff of display lines.
|
||||
return diffLinesUnified(aLinesDisplay, bLinesDisplay, options);
|
||||
}
|
||||
|
||||
const diffs = diffLinesRaw(aLinesCompare, bLinesCompare); // Replace comparison lines with displayable lines.
|
||||
|
||||
let aIndex = 0;
|
||||
let bIndex = 0;
|
||||
diffs.forEach(diff => {
|
||||
switch (diff[0]) {
|
||||
case _cleanupSemantic.DIFF_DELETE:
|
||||
diff[1] = aLinesDisplay[aIndex];
|
||||
aIndex += 1;
|
||||
break;
|
||||
|
||||
case _cleanupSemantic.DIFF_INSERT:
|
||||
diff[1] = bLinesDisplay[bIndex];
|
||||
bIndex += 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
diff[1] = bLinesDisplay[bIndex];
|
||||
aIndex += 1;
|
||||
bIndex += 1;
|
||||
}
|
||||
});
|
||||
return (0, _printDiffs.printDiffLines)(
|
||||
diffs,
|
||||
(0, _normalizeDiffOptions.normalizeDiffOptions)(options)
|
||||
);
|
||||
}; // Compare two arrays of strings line-by-line.
|
||||
|
||||
exports.diffLinesUnified2 = diffLinesUnified2;
|
||||
|
||||
const diffLinesRaw = (aLines, bLines) => {
|
||||
const aLength = aLines.length;
|
||||
const bLength = bLines.length;
|
||||
|
||||
const isCommon = (aIndex, bIndex) => aLines[aIndex] === bLines[bIndex];
|
||||
|
||||
const diffs = [];
|
||||
let aIndex = 0;
|
||||
let bIndex = 0;
|
||||
|
||||
const foundSubsequence = (nCommon, aCommon, bCommon) => {
|
||||
for (; aIndex !== aCommon; aIndex += 1) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(_cleanupSemantic.DIFF_DELETE, aLines[aIndex])
|
||||
);
|
||||
}
|
||||
|
||||
for (; bIndex !== bCommon; bIndex += 1) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(_cleanupSemantic.DIFF_INSERT, bLines[bIndex])
|
||||
);
|
||||
}
|
||||
|
||||
for (; nCommon !== 0; nCommon -= 1, aIndex += 1, bIndex += 1) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(_cleanupSemantic.DIFF_EQUAL, bLines[bIndex])
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
(0, _diffSequences.default)(aLength, bLength, isCommon, foundSubsequence); // After the last common subsequence, push remaining change items.
|
||||
|
||||
for (; aIndex !== aLength; aIndex += 1) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(_cleanupSemantic.DIFF_DELETE, aLines[aIndex])
|
||||
);
|
||||
}
|
||||
|
||||
for (; bIndex !== bLength; bIndex += 1) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(_cleanupSemantic.DIFF_INSERT, bLines[bIndex])
|
||||
);
|
||||
}
|
||||
|
||||
return diffs;
|
||||
};
|
||||
|
||||
exports.diffLinesRaw = diffLinesRaw;
|
9
web/node_modules/jest-diff/build/diffStrings.d.ts
generated
vendored
Normal file
9
web/node_modules/jest-diff/build/diffStrings.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Diff } from './cleanupSemantic';
|
||||
declare const diffStrings: (a: string, b: string) => Array<Diff>;
|
||||
export default diffStrings;
|
78
web/node_modules/jest-diff/build/diffStrings.js
generated
vendored
Normal file
78
web/node_modules/jest-diff/build/diffStrings.js
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _diffSequences = _interopRequireDefault(require('diff-sequences'));
|
||||
|
||||
var _cleanupSemantic = require('./cleanupSemantic');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const diffStrings = (a, b) => {
|
||||
const isCommon = (aIndex, bIndex) => a[aIndex] === b[bIndex];
|
||||
|
||||
let aIndex = 0;
|
||||
let bIndex = 0;
|
||||
const diffs = [];
|
||||
|
||||
const foundSubsequence = (nCommon, aCommon, bCommon) => {
|
||||
if (aIndex !== aCommon) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(
|
||||
_cleanupSemantic.DIFF_DELETE,
|
||||
a.slice(aIndex, aCommon)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (bIndex !== bCommon) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(
|
||||
_cleanupSemantic.DIFF_INSERT,
|
||||
b.slice(bIndex, bCommon)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
aIndex = aCommon + nCommon; // number of characters compared in a
|
||||
|
||||
bIndex = bCommon + nCommon; // number of characters compared in b
|
||||
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(
|
||||
_cleanupSemantic.DIFF_EQUAL,
|
||||
b.slice(bCommon, bIndex)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
(0, _diffSequences.default)(a.length, b.length, isCommon, foundSubsequence); // After the last common subsequence, push remaining change items.
|
||||
|
||||
if (aIndex !== a.length) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(_cleanupSemantic.DIFF_DELETE, a.slice(aIndex))
|
||||
);
|
||||
}
|
||||
|
||||
if (bIndex !== b.length) {
|
||||
diffs.push(
|
||||
new _cleanupSemantic.Diff(_cleanupSemantic.DIFF_INSERT, b.slice(bIndex))
|
||||
);
|
||||
}
|
||||
|
||||
return diffs;
|
||||
};
|
||||
|
||||
var _default = diffStrings;
|
||||
exports.default = _default;
|
10
web/node_modules/jest-diff/build/getAlignedDiffs.d.ts
generated
vendored
Normal file
10
web/node_modules/jest-diff/build/getAlignedDiffs.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Diff } from './cleanupSemantic';
|
||||
import type { DiffOptionsColor } from './types';
|
||||
declare const getAlignedDiffs: (diffs: Array<Diff>, changeColor: DiffOptionsColor) => Array<Diff>;
|
||||
export default getAlignedDiffs;
|
244
web/node_modules/jest-diff/build/getAlignedDiffs.js
generated
vendored
Normal file
244
web/node_modules/jest-diff/build/getAlignedDiffs.js
generated
vendored
Normal file
|
@ -0,0 +1,244 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _cleanupSemantic = require('./cleanupSemantic');
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Given change op and array of diffs, return concatenated string:
|
||||
// * include common strings
|
||||
// * include change strings which have argument op with changeColor
|
||||
// * exclude change strings which have opposite op
|
||||
const concatenateRelevantDiffs = (op, diffs, changeColor) =>
|
||||
diffs.reduce(
|
||||
(reduced, diff) =>
|
||||
reduced +
|
||||
(diff[0] === _cleanupSemantic.DIFF_EQUAL
|
||||
? diff[1]
|
||||
: diff[0] === op && diff[1].length !== 0 // empty if change is newline
|
||||
? changeColor(diff[1])
|
||||
: ''),
|
||||
''
|
||||
); // Encapsulate change lines until either a common newline or the end.
|
||||
|
||||
class ChangeBuffer {
|
||||
// incomplete line
|
||||
// complete lines
|
||||
constructor(op, changeColor) {
|
||||
_defineProperty(this, 'op', void 0);
|
||||
|
||||
_defineProperty(this, 'line', void 0);
|
||||
|
||||
_defineProperty(this, 'lines', void 0);
|
||||
|
||||
_defineProperty(this, 'changeColor', void 0);
|
||||
|
||||
this.op = op;
|
||||
this.line = [];
|
||||
this.lines = [];
|
||||
this.changeColor = changeColor;
|
||||
}
|
||||
|
||||
pushSubstring(substring) {
|
||||
this.pushDiff(new _cleanupSemantic.Diff(this.op, substring));
|
||||
}
|
||||
|
||||
pushLine() {
|
||||
// Assume call only if line has at least one diff,
|
||||
// therefore an empty line must have a diff which has an empty string.
|
||||
// If line has multiple diffs, then assume it has a common diff,
|
||||
// therefore change diffs have change color;
|
||||
// otherwise then it has line color only.
|
||||
this.lines.push(
|
||||
this.line.length !== 1
|
||||
? new _cleanupSemantic.Diff(
|
||||
this.op,
|
||||
concatenateRelevantDiffs(this.op, this.line, this.changeColor)
|
||||
)
|
||||
: this.line[0][0] === this.op
|
||||
? this.line[0] // can use instance
|
||||
: new _cleanupSemantic.Diff(this.op, this.line[0][1]) // was common diff
|
||||
);
|
||||
this.line.length = 0;
|
||||
}
|
||||
|
||||
isLineEmpty() {
|
||||
return this.line.length === 0;
|
||||
} // Minor input to buffer.
|
||||
|
||||
pushDiff(diff) {
|
||||
this.line.push(diff);
|
||||
} // Main input to buffer.
|
||||
|
||||
align(diff) {
|
||||
const string = diff[1];
|
||||
|
||||
if (string.includes('\n')) {
|
||||
const substrings = string.split('\n');
|
||||
const iLast = substrings.length - 1;
|
||||
substrings.forEach((substring, i) => {
|
||||
if (i < iLast) {
|
||||
// The first substring completes the current change line.
|
||||
// A middle substring is a change line.
|
||||
this.pushSubstring(substring);
|
||||
this.pushLine();
|
||||
} else if (substring.length !== 0) {
|
||||
// The last substring starts a change line, if it is not empty.
|
||||
// Important: This non-empty condition also automatically omits
|
||||
// the newline appended to the end of expected and received strings.
|
||||
this.pushSubstring(substring);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Append non-multiline string to current change line.
|
||||
this.pushDiff(diff);
|
||||
}
|
||||
} // Output from buffer.
|
||||
|
||||
moveLinesTo(lines) {
|
||||
if (!this.isLineEmpty()) {
|
||||
this.pushLine();
|
||||
}
|
||||
|
||||
lines.push(...this.lines);
|
||||
this.lines.length = 0;
|
||||
}
|
||||
} // Encapsulate common and change lines.
|
||||
|
||||
class CommonBuffer {
|
||||
constructor(deleteBuffer, insertBuffer) {
|
||||
_defineProperty(this, 'deleteBuffer', void 0);
|
||||
|
||||
_defineProperty(this, 'insertBuffer', void 0);
|
||||
|
||||
_defineProperty(this, 'lines', void 0);
|
||||
|
||||
this.deleteBuffer = deleteBuffer;
|
||||
this.insertBuffer = insertBuffer;
|
||||
this.lines = [];
|
||||
}
|
||||
|
||||
pushDiffCommonLine(diff) {
|
||||
this.lines.push(diff);
|
||||
}
|
||||
|
||||
pushDiffChangeLines(diff) {
|
||||
const isDiffEmpty = diff[1].length === 0; // An empty diff string is redundant, unless a change line is empty.
|
||||
|
||||
if (!isDiffEmpty || this.deleteBuffer.isLineEmpty()) {
|
||||
this.deleteBuffer.pushDiff(diff);
|
||||
}
|
||||
|
||||
if (!isDiffEmpty || this.insertBuffer.isLineEmpty()) {
|
||||
this.insertBuffer.pushDiff(diff);
|
||||
}
|
||||
}
|
||||
|
||||
flushChangeLines() {
|
||||
this.deleteBuffer.moveLinesTo(this.lines);
|
||||
this.insertBuffer.moveLinesTo(this.lines);
|
||||
} // Input to buffer.
|
||||
|
||||
align(diff) {
|
||||
const op = diff[0];
|
||||
const string = diff[1];
|
||||
|
||||
if (string.includes('\n')) {
|
||||
const substrings = string.split('\n');
|
||||
const iLast = substrings.length - 1;
|
||||
substrings.forEach((substring, i) => {
|
||||
if (i === 0) {
|
||||
const subdiff = new _cleanupSemantic.Diff(op, substring);
|
||||
|
||||
if (
|
||||
this.deleteBuffer.isLineEmpty() &&
|
||||
this.insertBuffer.isLineEmpty()
|
||||
) {
|
||||
// If both current change lines are empty,
|
||||
// then the first substring is a common line.
|
||||
this.flushChangeLines();
|
||||
this.pushDiffCommonLine(subdiff);
|
||||
} else {
|
||||
// If either current change line is non-empty,
|
||||
// then the first substring completes the change lines.
|
||||
this.pushDiffChangeLines(subdiff);
|
||||
this.flushChangeLines();
|
||||
}
|
||||
} else if (i < iLast) {
|
||||
// A middle substring is a common line.
|
||||
this.pushDiffCommonLine(new _cleanupSemantic.Diff(op, substring));
|
||||
} else if (substring.length !== 0) {
|
||||
// The last substring starts a change line, if it is not empty.
|
||||
// Important: This non-empty condition also automatically omits
|
||||
// the newline appended to the end of expected and received strings.
|
||||
this.pushDiffChangeLines(new _cleanupSemantic.Diff(op, substring));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Append non-multiline string to current change lines.
|
||||
// Important: It cannot be at the end following empty change lines,
|
||||
// because newline appended to the end of expected and received strings.
|
||||
this.pushDiffChangeLines(diff);
|
||||
}
|
||||
} // Output from buffer.
|
||||
|
||||
getLines() {
|
||||
this.flushChangeLines();
|
||||
return this.lines;
|
||||
}
|
||||
} // Given diffs from expected and received strings,
|
||||
// return new array of diffs split or joined into lines.
|
||||
//
|
||||
// To correctly align a change line at the end, the algorithm:
|
||||
// * assumes that a newline was appended to the strings
|
||||
// * omits the last newline from the output array
|
||||
//
|
||||
// Assume the function is not called:
|
||||
// * if either expected or received is empty string
|
||||
// * if neither expected nor received is multiline string
|
||||
|
||||
const getAlignedDiffs = (diffs, changeColor) => {
|
||||
const deleteBuffer = new ChangeBuffer(
|
||||
_cleanupSemantic.DIFF_DELETE,
|
||||
changeColor
|
||||
);
|
||||
const insertBuffer = new ChangeBuffer(
|
||||
_cleanupSemantic.DIFF_INSERT,
|
||||
changeColor
|
||||
);
|
||||
const commonBuffer = new CommonBuffer(deleteBuffer, insertBuffer);
|
||||
diffs.forEach(diff => {
|
||||
switch (diff[0]) {
|
||||
case _cleanupSemantic.DIFF_DELETE:
|
||||
deleteBuffer.align(diff);
|
||||
break;
|
||||
|
||||
case _cleanupSemantic.DIFF_INSERT:
|
||||
insertBuffer.align(diff);
|
||||
break;
|
||||
|
||||
default:
|
||||
commonBuffer.align(diff);
|
||||
}
|
||||
});
|
||||
return commonBuffer.getLines();
|
||||
};
|
||||
|
||||
var _default = getAlignedDiffs;
|
||||
exports.default = _default;
|
16
web/node_modules/jest-diff/build/index.d.ts
generated
vendored
Normal file
16
web/node_modules/jest-diff/build/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff } from './cleanupSemantic';
|
||||
import { diffLinesRaw, diffLinesUnified, diffLinesUnified2 } from './diffLines';
|
||||
import { diffStringsRaw, diffStringsUnified } from './printDiffs';
|
||||
import type { DiffOptions } from './types';
|
||||
export type { DiffOptions, DiffOptionsColor } from './types';
|
||||
export { diffLinesRaw, diffLinesUnified, diffLinesUnified2 };
|
||||
export { diffStringsRaw, diffStringsUnified };
|
||||
export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff };
|
||||
declare function diff(a: any, b: any, options?: DiffOptions): string | null;
|
||||
export default diff;
|
258
web/node_modules/jest-diff/build/index.js
generated
vendored
Normal file
258
web/node_modules/jest-diff/build/index.js
generated
vendored
Normal file
|
@ -0,0 +1,258 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, 'DIFF_DELETE', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _cleanupSemantic.DIFF_DELETE;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'DIFF_EQUAL', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _cleanupSemantic.DIFF_EQUAL;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'DIFF_INSERT', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _cleanupSemantic.DIFF_INSERT;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'Diff', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _cleanupSemantic.Diff;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'diffLinesRaw', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _diffLines.diffLinesRaw;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'diffLinesUnified', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _diffLines.diffLinesUnified;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'diffLinesUnified2', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _diffLines.diffLinesUnified2;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'diffStringsRaw', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _printDiffs.diffStringsRaw;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'diffStringsUnified', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _printDiffs.diffStringsUnified;
|
||||
}
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _chalk = _interopRequireDefault(require('chalk'));
|
||||
|
||||
var _jestGetType = _interopRequireDefault(require('jest-get-type'));
|
||||
|
||||
var _prettyFormat = _interopRequireDefault(require('pretty-format'));
|
||||
|
||||
var _cleanupSemantic = require('./cleanupSemantic');
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
var _diffLines = require('./diffLines');
|
||||
|
||||
var _normalizeDiffOptions = require('./normalizeDiffOptions');
|
||||
|
||||
var _printDiffs = require('./printDiffs');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
|
||||
const getCommonMessage = (message, options) => {
|
||||
const {commonColor} = (0, _normalizeDiffOptions.normalizeDiffOptions)(
|
||||
options
|
||||
);
|
||||
return commonColor(message);
|
||||
};
|
||||
|
||||
const {
|
||||
AsymmetricMatcher,
|
||||
DOMCollection,
|
||||
DOMElement,
|
||||
Immutable,
|
||||
ReactElement,
|
||||
ReactTestComponent
|
||||
} = _prettyFormat.default.plugins;
|
||||
const PLUGINS = [
|
||||
ReactTestComponent,
|
||||
ReactElement,
|
||||
DOMElement,
|
||||
DOMCollection,
|
||||
Immutable,
|
||||
AsymmetricMatcher
|
||||
];
|
||||
const FORMAT_OPTIONS = {
|
||||
plugins: PLUGINS
|
||||
};
|
||||
const FORMAT_OPTIONS_0 = {...FORMAT_OPTIONS, indent: 0};
|
||||
const FALLBACK_FORMAT_OPTIONS = {
|
||||
callToJSON: false,
|
||||
maxDepth: 10,
|
||||
plugins: PLUGINS
|
||||
};
|
||||
const FALLBACK_FORMAT_OPTIONS_0 = {...FALLBACK_FORMAT_OPTIONS, indent: 0}; // Generate a string that will highlight the difference between two values
|
||||
// with green and red. (similar to how github does code diffing)
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
|
||||
function diff(a, b, options) {
|
||||
if (Object.is(a, b)) {
|
||||
return getCommonMessage(_constants.NO_DIFF_MESSAGE, options);
|
||||
}
|
||||
|
||||
const aType = (0, _jestGetType.default)(a);
|
||||
let expectedType = aType;
|
||||
let omitDifference = false;
|
||||
|
||||
if (aType === 'object' && typeof a.asymmetricMatch === 'function') {
|
||||
if (a.$$typeof !== Symbol.for('jest.asymmetricMatcher')) {
|
||||
// Do not know expected type of user-defined asymmetric matcher.
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof a.getExpectedType !== 'function') {
|
||||
// For example, expect.anything() matches either null or undefined
|
||||
return null;
|
||||
}
|
||||
|
||||
expectedType = a.getExpectedType(); // Primitive types boolean and number omit difference below.
|
||||
// For example, omit difference for expect.stringMatching(regexp)
|
||||
|
||||
omitDifference = expectedType === 'string';
|
||||
}
|
||||
|
||||
if (expectedType !== (0, _jestGetType.default)(b)) {
|
||||
return (
|
||||
' Comparing two different types of values.' +
|
||||
` Expected ${_chalk.default.green(expectedType)} but ` +
|
||||
`received ${_chalk.default.red((0, _jestGetType.default)(b))}.`
|
||||
);
|
||||
}
|
||||
|
||||
if (omitDifference) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (aType) {
|
||||
case 'string':
|
||||
return (0, _diffLines.diffLinesUnified)(
|
||||
a.split('\n'),
|
||||
b.split('\n'),
|
||||
options
|
||||
);
|
||||
|
||||
case 'boolean':
|
||||
case 'number':
|
||||
return comparePrimitive(a, b, options);
|
||||
|
||||
case 'map':
|
||||
return compareObjects(sortMap(a), sortMap(b), options);
|
||||
|
||||
case 'set':
|
||||
return compareObjects(sortSet(a), sortSet(b), options);
|
||||
|
||||
default:
|
||||
return compareObjects(a, b, options);
|
||||
}
|
||||
}
|
||||
|
||||
function comparePrimitive(a, b, options) {
|
||||
const aFormat = (0, _prettyFormat.default)(a, FORMAT_OPTIONS);
|
||||
const bFormat = (0, _prettyFormat.default)(b, FORMAT_OPTIONS);
|
||||
return aFormat === bFormat
|
||||
? getCommonMessage(_constants.NO_DIFF_MESSAGE, options)
|
||||
: (0, _diffLines.diffLinesUnified)(
|
||||
aFormat.split('\n'),
|
||||
bFormat.split('\n'),
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
function sortMap(map) {
|
||||
return new Map(Array.from(map.entries()).sort());
|
||||
}
|
||||
|
||||
function sortSet(set) {
|
||||
return new Set(Array.from(set.values()).sort());
|
||||
}
|
||||
|
||||
function compareObjects(a, b, options) {
|
||||
let difference;
|
||||
let hasThrown = false;
|
||||
const noDiffMessage = getCommonMessage(_constants.NO_DIFF_MESSAGE, options);
|
||||
|
||||
try {
|
||||
const aCompare = (0, _prettyFormat.default)(a, FORMAT_OPTIONS_0);
|
||||
const bCompare = (0, _prettyFormat.default)(b, FORMAT_OPTIONS_0);
|
||||
|
||||
if (aCompare === bCompare) {
|
||||
difference = noDiffMessage;
|
||||
} else {
|
||||
const aDisplay = (0, _prettyFormat.default)(a, FORMAT_OPTIONS);
|
||||
const bDisplay = (0, _prettyFormat.default)(b, FORMAT_OPTIONS);
|
||||
difference = (0, _diffLines.diffLinesUnified2)(
|
||||
aDisplay.split('\n'),
|
||||
bDisplay.split('\n'),
|
||||
aCompare.split('\n'),
|
||||
bCompare.split('\n'),
|
||||
options
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
hasThrown = true;
|
||||
} // If the comparison yields no results, compare again but this time
|
||||
// without calling `toJSON`. It's also possible that toJSON might throw.
|
||||
|
||||
if (difference === undefined || difference === noDiffMessage) {
|
||||
const aCompare = (0, _prettyFormat.default)(a, FALLBACK_FORMAT_OPTIONS_0);
|
||||
const bCompare = (0, _prettyFormat.default)(b, FALLBACK_FORMAT_OPTIONS_0);
|
||||
|
||||
if (aCompare === bCompare) {
|
||||
difference = noDiffMessage;
|
||||
} else {
|
||||
const aDisplay = (0, _prettyFormat.default)(a, FALLBACK_FORMAT_OPTIONS);
|
||||
const bDisplay = (0, _prettyFormat.default)(b, FALLBACK_FORMAT_OPTIONS);
|
||||
difference = (0, _diffLines.diffLinesUnified2)(
|
||||
aDisplay.split('\n'),
|
||||
bDisplay.split('\n'),
|
||||
aCompare.split('\n'),
|
||||
bCompare.split('\n'),
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
if (difference !== noDiffMessage && !hasThrown) {
|
||||
difference =
|
||||
getCommonMessage(_constants.SIMILAR_MESSAGE, options) +
|
||||
'\n\n' +
|
||||
difference;
|
||||
}
|
||||
}
|
||||
|
||||
return difference;
|
||||
}
|
||||
|
||||
var _default = diff;
|
||||
exports.default = _default;
|
10
web/node_modules/jest-diff/build/joinAlignedDiffs.d.ts
generated
vendored
Normal file
10
web/node_modules/jest-diff/build/joinAlignedDiffs.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Diff } from './cleanupSemantic';
|
||||
import type { DiffOptionsNormalized } from './types';
|
||||
export declare const joinAlignedDiffsNoExpand: (diffs: Array<Diff>, options: DiffOptionsNormalized) => string;
|
||||
export declare const joinAlignedDiffsExpand: (diffs: Array<Diff>, options: DiffOptionsNormalized) => string;
|
235
web/node_modules/jest-diff/build/joinAlignedDiffs.js
generated
vendored
Normal file
235
web/node_modules/jest-diff/build/joinAlignedDiffs.js
generated
vendored
Normal file
|
@ -0,0 +1,235 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.joinAlignedDiffsExpand = exports.joinAlignedDiffsNoExpand = void 0;
|
||||
|
||||
var _cleanupSemantic = require('./cleanupSemantic');
|
||||
|
||||
var _printDiffs = require('./printDiffs');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// jest --no-expand
|
||||
//
|
||||
// Given array of aligned strings with inverse highlight formatting,
|
||||
// return joined lines with diff formatting (and patch marks, if needed).
|
||||
const joinAlignedDiffsNoExpand = (diffs, options) => {
|
||||
const iLength = diffs.length;
|
||||
const nContextLines = options.contextLines;
|
||||
const nContextLines2 = nContextLines + nContextLines; // First pass: count output lines and see if it has patches.
|
||||
|
||||
let jLength = iLength;
|
||||
let hasExcessAtStartOrEnd = false;
|
||||
let nExcessesBetweenChanges = 0;
|
||||
let i = 0;
|
||||
|
||||
while (i !== iLength) {
|
||||
const iStart = i;
|
||||
|
||||
while (i !== iLength && diffs[i][0] === _cleanupSemantic.DIFF_EQUAL) {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
if (iStart !== i) {
|
||||
if (iStart === 0) {
|
||||
// at start
|
||||
if (i > nContextLines) {
|
||||
jLength -= i - nContextLines; // subtract excess common lines
|
||||
|
||||
hasExcessAtStartOrEnd = true;
|
||||
}
|
||||
} else if (i === iLength) {
|
||||
// at end
|
||||
const n = i - iStart;
|
||||
|
||||
if (n > nContextLines) {
|
||||
jLength -= n - nContextLines; // subtract excess common lines
|
||||
|
||||
hasExcessAtStartOrEnd = true;
|
||||
}
|
||||
} else {
|
||||
// between changes
|
||||
const n = i - iStart;
|
||||
|
||||
if (n > nContextLines2) {
|
||||
jLength -= n - nContextLines2; // subtract excess common lines
|
||||
|
||||
nExcessesBetweenChanges += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (i !== iLength && diffs[i][0] !== _cleanupSemantic.DIFF_EQUAL) {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
const hasPatch = nExcessesBetweenChanges !== 0 || hasExcessAtStartOrEnd;
|
||||
|
||||
if (nExcessesBetweenChanges !== 0) {
|
||||
jLength += nExcessesBetweenChanges + 1; // add patch lines
|
||||
} else if (hasExcessAtStartOrEnd) {
|
||||
jLength += 1; // add patch line
|
||||
}
|
||||
|
||||
const jLast = jLength - 1;
|
||||
const lines = [];
|
||||
let jPatchMark = 0; // index of placeholder line for current patch mark
|
||||
|
||||
if (hasPatch) {
|
||||
lines.push(''); // placeholder line for first patch mark
|
||||
} // Indexes of expected or received lines in current patch:
|
||||
|
||||
let aStart = 0;
|
||||
let bStart = 0;
|
||||
let aEnd = 0;
|
||||
let bEnd = 0;
|
||||
|
||||
const pushCommonLine = line => {
|
||||
const j = lines.length;
|
||||
lines.push(
|
||||
(0, _printDiffs.printCommonLine)(line, j === 0 || j === jLast, options)
|
||||
);
|
||||
aEnd += 1;
|
||||
bEnd += 1;
|
||||
};
|
||||
|
||||
const pushDeleteLine = line => {
|
||||
const j = lines.length;
|
||||
lines.push(
|
||||
(0, _printDiffs.printDeleteLine)(line, j === 0 || j === jLast, options)
|
||||
);
|
||||
aEnd += 1;
|
||||
};
|
||||
|
||||
const pushInsertLine = line => {
|
||||
const j = lines.length;
|
||||
lines.push(
|
||||
(0, _printDiffs.printInsertLine)(line, j === 0 || j === jLast, options)
|
||||
);
|
||||
bEnd += 1;
|
||||
}; // Second pass: push lines with diff formatting (and patch marks, if needed).
|
||||
|
||||
i = 0;
|
||||
|
||||
while (i !== iLength) {
|
||||
let iStart = i;
|
||||
|
||||
while (i !== iLength && diffs[i][0] === _cleanupSemantic.DIFF_EQUAL) {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
if (iStart !== i) {
|
||||
if (iStart === 0) {
|
||||
// at beginning
|
||||
if (i > nContextLines) {
|
||||
iStart = i - nContextLines;
|
||||
aStart = iStart;
|
||||
bStart = iStart;
|
||||
aEnd = aStart;
|
||||
bEnd = bStart;
|
||||
}
|
||||
|
||||
for (let iCommon = iStart; iCommon !== i; iCommon += 1) {
|
||||
pushCommonLine(diffs[iCommon][1]);
|
||||
}
|
||||
} else if (i === iLength) {
|
||||
// at end
|
||||
const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
|
||||
|
||||
for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) {
|
||||
pushCommonLine(diffs[iCommon][1]);
|
||||
}
|
||||
} else {
|
||||
// between changes
|
||||
const nCommon = i - iStart;
|
||||
|
||||
if (nCommon > nContextLines2) {
|
||||
const iEnd = iStart + nContextLines;
|
||||
|
||||
for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) {
|
||||
pushCommonLine(diffs[iCommon][1]);
|
||||
}
|
||||
|
||||
lines[jPatchMark] = (0, _printDiffs.createPatchMark)(
|
||||
aStart,
|
||||
aEnd,
|
||||
bStart,
|
||||
bEnd,
|
||||
options
|
||||
);
|
||||
jPatchMark = lines.length;
|
||||
lines.push(''); // placeholder line for next patch mark
|
||||
|
||||
const nOmit = nCommon - nContextLines2;
|
||||
aStart = aEnd + nOmit;
|
||||
bStart = bEnd + nOmit;
|
||||
aEnd = aStart;
|
||||
bEnd = bStart;
|
||||
|
||||
for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) {
|
||||
pushCommonLine(diffs[iCommon][1]);
|
||||
}
|
||||
} else {
|
||||
for (let iCommon = iStart; iCommon !== i; iCommon += 1) {
|
||||
pushCommonLine(diffs[iCommon][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (i !== iLength && diffs[i][0] === _cleanupSemantic.DIFF_DELETE) {
|
||||
pushDeleteLine(diffs[i][1]);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
while (i !== iLength && diffs[i][0] === _cleanupSemantic.DIFF_INSERT) {
|
||||
pushInsertLine(diffs[i][1]);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPatch) {
|
||||
lines[jPatchMark] = (0, _printDiffs.createPatchMark)(
|
||||
aStart,
|
||||
aEnd,
|
||||
bStart,
|
||||
bEnd,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}; // jest --expand
|
||||
//
|
||||
// Given array of aligned strings with inverse highlight formatting,
|
||||
// return joined lines with diff formatting.
|
||||
|
||||
exports.joinAlignedDiffsNoExpand = joinAlignedDiffsNoExpand;
|
||||
|
||||
const joinAlignedDiffsExpand = (diffs, options) =>
|
||||
diffs
|
||||
.map((diff, i, diffs) => {
|
||||
const line = diff[1];
|
||||
const isFirstOrLast = i === 0 || i === diffs.length - 1;
|
||||
|
||||
switch (diff[0]) {
|
||||
case _cleanupSemantic.DIFF_DELETE:
|
||||
return (0, _printDiffs.printDeleteLine)(line, isFirstOrLast, options);
|
||||
|
||||
case _cleanupSemantic.DIFF_INSERT:
|
||||
return (0, _printDiffs.printInsertLine)(line, isFirstOrLast, options);
|
||||
|
||||
default:
|
||||
return (0, _printDiffs.printCommonLine)(line, isFirstOrLast, options);
|
||||
}
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
exports.joinAlignedDiffsExpand = joinAlignedDiffsExpand;
|
9
web/node_modules/jest-diff/build/normalizeDiffOptions.d.ts
generated
vendored
Normal file
9
web/node_modules/jest-diff/build/normalizeDiffOptions.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { DiffOptions, DiffOptionsNormalized } from './types';
|
||||
export declare const noColor: (string: string) => string;
|
||||
export declare const normalizeDiffOptions: (options?: DiffOptions) => DiffOptionsNormalized;
|
57
web/node_modules/jest-diff/build/normalizeDiffOptions.js
generated
vendored
Normal file
57
web/node_modules/jest-diff/build/normalizeDiffOptions.js
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.normalizeDiffOptions = exports.noColor = void 0;
|
||||
|
||||
var _chalk = _interopRequireDefault(require('chalk'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const noColor = string => string;
|
||||
|
||||
exports.noColor = noColor;
|
||||
const DIFF_CONTEXT_DEFAULT = 5;
|
||||
const OPTIONS_DEFAULT = {
|
||||
aAnnotation: 'Expected',
|
||||
aColor: _chalk.default.green,
|
||||
aIndicator: '-',
|
||||
bAnnotation: 'Received',
|
||||
bColor: _chalk.default.red,
|
||||
bIndicator: '+',
|
||||
changeColor: _chalk.default.inverse,
|
||||
changeLineTrailingSpaceColor: noColor,
|
||||
commonColor: _chalk.default.dim,
|
||||
commonIndicator: ' ',
|
||||
commonLineTrailingSpaceColor: noColor,
|
||||
contextLines: DIFF_CONTEXT_DEFAULT,
|
||||
emptyFirstOrLastLinePlaceholder: '',
|
||||
expand: true,
|
||||
includeChangeCounts: false,
|
||||
omitAnnotationLines: false,
|
||||
patchColor: _chalk.default.yellow
|
||||
};
|
||||
|
||||
const getContextLines = contextLines =>
|
||||
typeof contextLines === 'number' &&
|
||||
Number.isSafeInteger(contextLines) &&
|
||||
contextLines >= 0
|
||||
? contextLines
|
||||
: DIFF_CONTEXT_DEFAULT; // Pure function returns options with all properties.
|
||||
|
||||
const normalizeDiffOptions = (options = {}) => ({
|
||||
...OPTIONS_DEFAULT,
|
||||
...options,
|
||||
contextLines: getContextLines(options.contextLines)
|
||||
});
|
||||
|
||||
exports.normalizeDiffOptions = normalizeDiffOptions;
|
22
web/node_modules/jest-diff/build/printDiffs.d.ts
generated
vendored
Normal file
22
web/node_modules/jest-diff/build/printDiffs.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Diff } from './cleanupSemantic';
|
||||
import type { DiffOptions, DiffOptionsNormalized } from './types';
|
||||
export declare const printDeleteLine: (line: string, isFirstOrLast: boolean, { aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder, }: DiffOptionsNormalized) => string;
|
||||
export declare const printInsertLine: (line: string, isFirstOrLast: boolean, { bColor, bIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder, }: DiffOptionsNormalized) => string;
|
||||
export declare const printCommonLine: (line: string, isFirstOrLast: boolean, { commonColor, commonIndicator, commonLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder, }: DiffOptionsNormalized) => string;
|
||||
export declare const hasCommonDiff: (diffs: Array<Diff>, isMultiline: boolean) => boolean;
|
||||
export declare type ChangeCounts = {
|
||||
a: number;
|
||||
b: number;
|
||||
};
|
||||
export declare const countChanges: (diffs: Array<Diff>) => ChangeCounts;
|
||||
export declare const printAnnotation: ({ aAnnotation, aColor, aIndicator, bAnnotation, bColor, bIndicator, includeChangeCounts, omitAnnotationLines, }: DiffOptionsNormalized, changeCounts: ChangeCounts) => string;
|
||||
export declare const printDiffLines: (diffs: Array<Diff>, options: DiffOptionsNormalized) => string;
|
||||
export declare const createPatchMark: (aStart: number, aEnd: number, bStart: number, bEnd: number, { patchColor }: DiffOptionsNormalized) => string;
|
||||
export declare const diffStringsUnified: (a: string, b: string, options?: DiffOptions | undefined) => string;
|
||||
export declare const diffStringsRaw: (a: string, b: string, cleanup: boolean) => Array<Diff>;
|
257
web/node_modules/jest-diff/build/printDiffs.js
generated
vendored
Normal file
257
web/node_modules/jest-diff/build/printDiffs.js
generated
vendored
Normal file
|
@ -0,0 +1,257 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.diffStringsRaw = exports.diffStringsUnified = exports.createPatchMark = exports.printDiffLines = exports.printAnnotation = exports.countChanges = exports.hasCommonDiff = exports.printCommonLine = exports.printInsertLine = exports.printDeleteLine = void 0;
|
||||
|
||||
var _cleanupSemantic = require('./cleanupSemantic');
|
||||
|
||||
var _diffLines = require('./diffLines');
|
||||
|
||||
var _diffStrings = _interopRequireDefault(require('./diffStrings'));
|
||||
|
||||
var _getAlignedDiffs = _interopRequireDefault(require('./getAlignedDiffs'));
|
||||
|
||||
var _joinAlignedDiffs = require('./joinAlignedDiffs');
|
||||
|
||||
var _normalizeDiffOptions = require('./normalizeDiffOptions');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const formatTrailingSpaces = (line, trailingSpaceFormatter) =>
|
||||
line.replace(/\s+$/, match => trailingSpaceFormatter(match));
|
||||
|
||||
const printDiffLine = (
|
||||
line,
|
||||
isFirstOrLast,
|
||||
color,
|
||||
indicator,
|
||||
trailingSpaceFormatter,
|
||||
emptyFirstOrLastLinePlaceholder
|
||||
) =>
|
||||
line.length !== 0
|
||||
? color(
|
||||
indicator + ' ' + formatTrailingSpaces(line, trailingSpaceFormatter)
|
||||
)
|
||||
: indicator !== ' '
|
||||
? color(indicator)
|
||||
: isFirstOrLast && emptyFirstOrLastLinePlaceholder.length !== 0
|
||||
? color(indicator + ' ' + emptyFirstOrLastLinePlaceholder)
|
||||
: '';
|
||||
|
||||
const printDeleteLine = (
|
||||
line,
|
||||
isFirstOrLast,
|
||||
{
|
||||
aColor,
|
||||
aIndicator,
|
||||
changeLineTrailingSpaceColor,
|
||||
emptyFirstOrLastLinePlaceholder
|
||||
}
|
||||
) =>
|
||||
printDiffLine(
|
||||
line,
|
||||
isFirstOrLast,
|
||||
aColor,
|
||||
aIndicator,
|
||||
changeLineTrailingSpaceColor,
|
||||
emptyFirstOrLastLinePlaceholder
|
||||
);
|
||||
|
||||
exports.printDeleteLine = printDeleteLine;
|
||||
|
||||
const printInsertLine = (
|
||||
line,
|
||||
isFirstOrLast,
|
||||
{
|
||||
bColor,
|
||||
bIndicator,
|
||||
changeLineTrailingSpaceColor,
|
||||
emptyFirstOrLastLinePlaceholder
|
||||
}
|
||||
) =>
|
||||
printDiffLine(
|
||||
line,
|
||||
isFirstOrLast,
|
||||
bColor,
|
||||
bIndicator,
|
||||
changeLineTrailingSpaceColor,
|
||||
emptyFirstOrLastLinePlaceholder
|
||||
);
|
||||
|
||||
exports.printInsertLine = printInsertLine;
|
||||
|
||||
const printCommonLine = (
|
||||
line,
|
||||
isFirstOrLast,
|
||||
{
|
||||
commonColor,
|
||||
commonIndicator,
|
||||
commonLineTrailingSpaceColor,
|
||||
emptyFirstOrLastLinePlaceholder
|
||||
}
|
||||
) =>
|
||||
printDiffLine(
|
||||
line,
|
||||
isFirstOrLast,
|
||||
commonColor,
|
||||
commonIndicator,
|
||||
commonLineTrailingSpaceColor,
|
||||
emptyFirstOrLastLinePlaceholder
|
||||
);
|
||||
|
||||
exports.printCommonLine = printCommonLine;
|
||||
|
||||
const hasCommonDiff = (diffs, isMultiline) => {
|
||||
if (isMultiline) {
|
||||
// Important: Ignore common newline that was appended to multiline strings!
|
||||
const iLast = diffs.length - 1;
|
||||
return diffs.some(
|
||||
(diff, i) =>
|
||||
diff[0] === _cleanupSemantic.DIFF_EQUAL &&
|
||||
(i !== iLast || diff[1] !== '\n')
|
||||
);
|
||||
}
|
||||
|
||||
return diffs.some(diff => diff[0] === _cleanupSemantic.DIFF_EQUAL);
|
||||
};
|
||||
|
||||
exports.hasCommonDiff = hasCommonDiff;
|
||||
|
||||
const countChanges = diffs => {
|
||||
let a = 0;
|
||||
let b = 0;
|
||||
diffs.forEach(diff => {
|
||||
switch (diff[0]) {
|
||||
case _cleanupSemantic.DIFF_DELETE:
|
||||
a += 1;
|
||||
break;
|
||||
|
||||
case _cleanupSemantic.DIFF_INSERT:
|
||||
b += 1;
|
||||
break;
|
||||
}
|
||||
});
|
||||
return {
|
||||
a,
|
||||
b
|
||||
};
|
||||
};
|
||||
|
||||
exports.countChanges = countChanges;
|
||||
|
||||
const printAnnotation = (
|
||||
{
|
||||
aAnnotation,
|
||||
aColor,
|
||||
aIndicator,
|
||||
bAnnotation,
|
||||
bColor,
|
||||
bIndicator,
|
||||
includeChangeCounts,
|
||||
omitAnnotationLines
|
||||
},
|
||||
changeCounts
|
||||
) => {
|
||||
if (omitAnnotationLines) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let aRest = '';
|
||||
let bRest = '';
|
||||
|
||||
if (includeChangeCounts) {
|
||||
const aCount = String(changeCounts.a);
|
||||
const bCount = String(changeCounts.b); // Padding right aligns the ends of the annotations.
|
||||
|
||||
const baAnnotationLengthDiff = bAnnotation.length - aAnnotation.length;
|
||||
const aAnnotationPadding = ' '.repeat(Math.max(0, baAnnotationLengthDiff));
|
||||
const bAnnotationPadding = ' '.repeat(Math.max(0, -baAnnotationLengthDiff)); // Padding left aligns the ends of the counts.
|
||||
|
||||
const baCountLengthDiff = bCount.length - aCount.length;
|
||||
const aCountPadding = ' '.repeat(Math.max(0, baCountLengthDiff));
|
||||
const bCountPadding = ' '.repeat(Math.max(0, -baCountLengthDiff));
|
||||
aRest =
|
||||
aAnnotationPadding + ' ' + aIndicator + ' ' + aCountPadding + aCount;
|
||||
bRest =
|
||||
bAnnotationPadding + ' ' + bIndicator + ' ' + bCountPadding + bCount;
|
||||
}
|
||||
|
||||
return (
|
||||
aColor(aIndicator + ' ' + aAnnotation + aRest) +
|
||||
'\n' +
|
||||
bColor(bIndicator + ' ' + bAnnotation + bRest) +
|
||||
'\n\n'
|
||||
);
|
||||
};
|
||||
|
||||
exports.printAnnotation = printAnnotation;
|
||||
|
||||
const printDiffLines = (diffs, options) =>
|
||||
printAnnotation(options, countChanges(diffs)) +
|
||||
(options.expand
|
||||
? (0, _joinAlignedDiffs.joinAlignedDiffsExpand)(diffs, options)
|
||||
: (0, _joinAlignedDiffs.joinAlignedDiffsNoExpand)(diffs, options)); // In GNU diff format, indexes are one-based instead of zero-based.
|
||||
|
||||
exports.printDiffLines = printDiffLines;
|
||||
|
||||
const createPatchMark = (aStart, aEnd, bStart, bEnd, {patchColor}) =>
|
||||
patchColor(
|
||||
`@@ -${aStart + 1},${aEnd - aStart} +${bStart + 1},${bEnd - bStart} @@`
|
||||
); // Compare two strings character-by-character.
|
||||
// Format as comparison lines in which changed substrings have inverse colors.
|
||||
|
||||
exports.createPatchMark = createPatchMark;
|
||||
|
||||
const diffStringsUnified = (a, b, options) => {
|
||||
if (a !== b && a.length !== 0 && b.length !== 0) {
|
||||
const isMultiline = a.includes('\n') || b.includes('\n'); // getAlignedDiffs assumes that a newline was appended to the strings.
|
||||
|
||||
const diffs = diffStringsRaw(
|
||||
isMultiline ? a + '\n' : a,
|
||||
isMultiline ? b + '\n' : b,
|
||||
true // cleanupSemantic
|
||||
);
|
||||
|
||||
if (hasCommonDiff(diffs, isMultiline)) {
|
||||
const optionsNormalized = (0, _normalizeDiffOptions.normalizeDiffOptions)(
|
||||
options
|
||||
);
|
||||
const lines = (0, _getAlignedDiffs.default)(
|
||||
diffs,
|
||||
optionsNormalized.changeColor
|
||||
);
|
||||
return printDiffLines(lines, optionsNormalized);
|
||||
}
|
||||
} // Fall back to line-by-line diff.
|
||||
|
||||
return (0, _diffLines.diffLinesUnified)(
|
||||
a.split('\n'),
|
||||
b.split('\n'),
|
||||
options
|
||||
);
|
||||
}; // Compare two strings character-by-character.
|
||||
// Optionally clean up small common substrings, also known as chaff.
|
||||
|
||||
exports.diffStringsUnified = diffStringsUnified;
|
||||
|
||||
const diffStringsRaw = (a, b, cleanup) => {
|
||||
const diffs = (0, _diffStrings.default)(a, b);
|
||||
|
||||
if (cleanup) {
|
||||
(0, _cleanupSemantic.cleanupSemantic)(diffs); // impure function
|
||||
}
|
||||
|
||||
return diffs;
|
||||
};
|
||||
|
||||
exports.diffStringsRaw = diffStringsRaw;
|
45
web/node_modules/jest-diff/build/types.d.ts
generated
vendored
Normal file
45
web/node_modules/jest-diff/build/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare type DiffOptionsColor = (arg: string) => string;
|
||||
export declare type DiffOptions = {
|
||||
aAnnotation?: string;
|
||||
aColor?: DiffOptionsColor;
|
||||
aIndicator?: string;
|
||||
bAnnotation?: string;
|
||||
bColor?: DiffOptionsColor;
|
||||
bIndicator?: string;
|
||||
changeColor?: DiffOptionsColor;
|
||||
changeLineTrailingSpaceColor?: DiffOptionsColor;
|
||||
commonColor?: DiffOptionsColor;
|
||||
commonIndicator?: string;
|
||||
commonLineTrailingSpaceColor?: DiffOptionsColor;
|
||||
contextLines?: number;
|
||||
emptyFirstOrLastLinePlaceholder?: string;
|
||||
expand?: boolean;
|
||||
includeChangeCounts?: boolean;
|
||||
omitAnnotationLines?: boolean;
|
||||
patchColor?: DiffOptionsColor;
|
||||
};
|
||||
export declare type DiffOptionsNormalized = {
|
||||
aAnnotation: string;
|
||||
aColor: DiffOptionsColor;
|
||||
aIndicator: string;
|
||||
bAnnotation: string;
|
||||
bColor: DiffOptionsColor;
|
||||
bIndicator: string;
|
||||
changeColor: DiffOptionsColor;
|
||||
changeLineTrailingSpaceColor: DiffOptionsColor;
|
||||
commonColor: DiffOptionsColor;
|
||||
commonIndicator: string;
|
||||
commonLineTrailingSpaceColor: DiffOptionsColor;
|
||||
contextLines: number;
|
||||
emptyFirstOrLastLinePlaceholder: string;
|
||||
expand: boolean;
|
||||
includeChangeCounts: boolean;
|
||||
omitAnnotationLines: boolean;
|
||||
patchColor: DiffOptionsColor;
|
||||
};
|
1
web/node_modules/jest-diff/build/types.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/build/types.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
21
web/node_modules/jest-diff/node_modules/@jest/types/LICENSE
generated
vendored
Normal file
21
web/node_modules/jest-diff/node_modules/@jest/types/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
191
web/node_modules/jest-diff/node_modules/@jest/types/build/Circus.d.ts
generated
vendored
Normal file
191
web/node_modules/jest-diff/node_modules/@jest/types/build/Circus.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import type * as Global from './Global';
|
||||
declare type Process = NodeJS.Process;
|
||||
export declare type DoneFn = Global.DoneFn;
|
||||
export declare type BlockFn = Global.BlockFn;
|
||||
export declare type BlockName = Global.BlockName;
|
||||
export declare type BlockMode = void | 'skip' | 'only' | 'todo';
|
||||
export declare type TestMode = BlockMode;
|
||||
export declare type TestName = Global.TestName;
|
||||
export declare type TestFn = Global.TestFn;
|
||||
export declare type HookFn = Global.HookFn;
|
||||
export declare type AsyncFn = TestFn | HookFn;
|
||||
export declare type SharedHookType = 'afterAll' | 'beforeAll';
|
||||
export declare type HookType = SharedHookType | 'afterEach' | 'beforeEach';
|
||||
export declare type TestContext = Record<string, unknown>;
|
||||
export declare type Exception = any;
|
||||
export declare type FormattedError = string;
|
||||
export declare type Hook = {
|
||||
asyncError: Error;
|
||||
fn: HookFn;
|
||||
type: HookType;
|
||||
parent: DescribeBlock;
|
||||
timeout: number | undefined | null;
|
||||
};
|
||||
export interface EventHandler {
|
||||
(event: AsyncEvent, state: State): void | Promise<void>;
|
||||
(event: SyncEvent, state: State): void;
|
||||
}
|
||||
export declare type Event = SyncEvent | AsyncEvent;
|
||||
interface JestGlobals extends Global.TestFrameworkGlobals {
|
||||
expect: unknown;
|
||||
}
|
||||
export declare type SyncEvent = {
|
||||
asyncError: Error;
|
||||
mode: BlockMode;
|
||||
name: 'start_describe_definition';
|
||||
blockName: BlockName;
|
||||
} | {
|
||||
mode: BlockMode;
|
||||
name: 'finish_describe_definition';
|
||||
blockName: BlockName;
|
||||
} | {
|
||||
asyncError: Error;
|
||||
name: 'add_hook';
|
||||
hookType: HookType;
|
||||
fn: HookFn;
|
||||
timeout: number | undefined;
|
||||
} | {
|
||||
asyncError: Error;
|
||||
name: 'add_test';
|
||||
testName: TestName;
|
||||
fn: TestFn;
|
||||
mode?: TestMode;
|
||||
timeout: number | undefined;
|
||||
} | {
|
||||
name: 'error';
|
||||
error: Exception;
|
||||
};
|
||||
export declare type AsyncEvent = {
|
||||
name: 'setup';
|
||||
testNamePattern?: string;
|
||||
runtimeGlobals: JestGlobals;
|
||||
parentProcess: Process;
|
||||
} | {
|
||||
name: 'include_test_location_in_result';
|
||||
} | {
|
||||
name: 'hook_start';
|
||||
hook: Hook;
|
||||
} | {
|
||||
name: 'hook_success';
|
||||
describeBlock?: DescribeBlock;
|
||||
test?: TestEntry;
|
||||
hook: Hook;
|
||||
} | {
|
||||
name: 'hook_failure';
|
||||
error: string | Exception;
|
||||
describeBlock?: DescribeBlock;
|
||||
test?: TestEntry;
|
||||
hook: Hook;
|
||||
} | {
|
||||
name: 'test_fn_start';
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'test_fn_success';
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'test_fn_failure';
|
||||
error: Exception;
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'test_retry';
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'test_start';
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'test_skip';
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'test_todo';
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'test_done';
|
||||
test: TestEntry;
|
||||
} | {
|
||||
name: 'run_describe_start';
|
||||
describeBlock: DescribeBlock;
|
||||
} | {
|
||||
name: 'run_describe_finish';
|
||||
describeBlock: DescribeBlock;
|
||||
} | {
|
||||
name: 'run_start';
|
||||
} | {
|
||||
name: 'run_finish';
|
||||
} | {
|
||||
name: 'teardown';
|
||||
};
|
||||
export declare type MatcherResults = {
|
||||
actual: unknown;
|
||||
expected: unknown;
|
||||
name: string;
|
||||
pass: boolean;
|
||||
};
|
||||
export declare type TestStatus = 'skip' | 'done' | 'todo';
|
||||
export declare type TestResult = {
|
||||
duration?: number | null;
|
||||
errors: Array<FormattedError>;
|
||||
errorsDetailed: Array<MatcherResults | unknown>;
|
||||
invocations: number;
|
||||
status: TestStatus;
|
||||
location?: {
|
||||
column: number;
|
||||
line: number;
|
||||
} | null;
|
||||
testPath: Array<TestName | BlockName>;
|
||||
};
|
||||
export declare type RunResult = {
|
||||
unhandledErrors: Array<FormattedError>;
|
||||
testResults: TestResults;
|
||||
};
|
||||
export declare type TestResults = Array<TestResult>;
|
||||
export declare type GlobalErrorHandlers = {
|
||||
uncaughtException: Array<(exception: Exception) => void>;
|
||||
unhandledRejection: Array<(exception: Exception, promise: Promise<unknown>) => void>;
|
||||
};
|
||||
export declare type State = {
|
||||
currentDescribeBlock: DescribeBlock;
|
||||
currentlyRunningTest?: TestEntry | null;
|
||||
expand?: boolean;
|
||||
hasFocusedTests: boolean;
|
||||
hasStarted: boolean;
|
||||
originalGlobalErrorHandlers?: GlobalErrorHandlers;
|
||||
parentProcess: Process | null;
|
||||
rootDescribeBlock: DescribeBlock;
|
||||
testNamePattern?: RegExp | null;
|
||||
testTimeout: number;
|
||||
unhandledErrors: Array<Exception>;
|
||||
includeTestLocationInResult: boolean;
|
||||
};
|
||||
export declare type DescribeBlock = {
|
||||
type: 'describeBlock';
|
||||
children: Array<DescribeBlock | TestEntry>;
|
||||
hooks: Array<Hook>;
|
||||
mode: BlockMode;
|
||||
name: BlockName;
|
||||
parent?: DescribeBlock;
|
||||
/** @deprecated Please get from `children` array instead */
|
||||
tests: Array<TestEntry>;
|
||||
};
|
||||
export declare type TestError = Exception | [Exception | undefined, Exception];
|
||||
export declare type TestEntry = {
|
||||
type: 'test';
|
||||
asyncError: Exception;
|
||||
errors: Array<TestError>;
|
||||
fn: TestFn;
|
||||
invocations: number;
|
||||
mode: TestMode;
|
||||
name: TestName;
|
||||
parent: DescribeBlock;
|
||||
startedAt?: number | null;
|
||||
duration?: number | null;
|
||||
status?: TestStatus | null;
|
||||
timeout?: number;
|
||||
};
|
||||
export {};
|
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Circus.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Circus.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
433
web/node_modules/jest-diff/node_modules/@jest/types/build/Config.d.ts
generated
vendored
Normal file
433
web/node_modules/jest-diff/node_modules/@jest/types/build/Config.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,433 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import type { ForegroundColor } from 'chalk';
|
||||
import type { ReportOptions } from 'istanbul-reports';
|
||||
import type { Arguments } from 'yargs';
|
||||
declare type CoverageProvider = 'babel' | 'v8';
|
||||
declare type Timers = 'real' | 'fake' | 'modern' | 'legacy';
|
||||
export declare type Path = string;
|
||||
export declare type Glob = string;
|
||||
export declare type HasteConfig = {
|
||||
/** Whether to hash files using SHA-1. */
|
||||
computeSha1?: boolean;
|
||||
/** The platform to use as the default, e.g. 'ios'. */
|
||||
defaultPlatform?: string | null;
|
||||
/** Path to a custom implementation of Haste. */
|
||||
hasteImplModulePath?: string;
|
||||
/** All platforms to target, e.g ['ios', 'android']. */
|
||||
platforms?: Array<string>;
|
||||
/** Whether to throw on error on module collision. */
|
||||
throwOnModuleCollision?: boolean;
|
||||
};
|
||||
export declare type CoverageReporterName = keyof ReportOptions;
|
||||
export declare type CoverageReporterWithOptions<K = CoverageReporterName> = K extends CoverageReporterName ? ReportOptions[K] extends never ? never : [K, Partial<ReportOptions[K]>] : never;
|
||||
export declare type CoverageReporters = Array<CoverageReporterName | CoverageReporterWithOptions>;
|
||||
export declare type ReporterConfig = [string, Record<string, unknown>];
|
||||
export declare type TransformerConfig = [string, Record<string, unknown>];
|
||||
export interface ConfigGlobals {
|
||||
[K: string]: unknown;
|
||||
}
|
||||
export declare type DefaultOptions = {
|
||||
automock: boolean;
|
||||
bail: number;
|
||||
cache: boolean;
|
||||
cacheDirectory: Path;
|
||||
changedFilesWithAncestor: boolean;
|
||||
clearMocks: boolean;
|
||||
collectCoverage: boolean;
|
||||
coveragePathIgnorePatterns: Array<string>;
|
||||
coverageReporters: Array<CoverageReporterName>;
|
||||
coverageProvider: CoverageProvider;
|
||||
errorOnDeprecated: boolean;
|
||||
expand: boolean;
|
||||
forceCoverageMatch: Array<Glob>;
|
||||
globals: ConfigGlobals;
|
||||
haste: HasteConfig;
|
||||
injectGlobals: boolean;
|
||||
maxConcurrency: number;
|
||||
maxWorkers: number | string;
|
||||
moduleDirectories: Array<string>;
|
||||
moduleFileExtensions: Array<string>;
|
||||
moduleNameMapper: Record<string, string | Array<string>>;
|
||||
modulePathIgnorePatterns: Array<string>;
|
||||
noStackTrace: boolean;
|
||||
notify: boolean;
|
||||
notifyMode: NotifyMode;
|
||||
prettierPath: string;
|
||||
resetMocks: boolean;
|
||||
resetModules: boolean;
|
||||
restoreMocks: boolean;
|
||||
roots: Array<Path>;
|
||||
runTestsByPath: boolean;
|
||||
runner: 'jest-runner';
|
||||
setupFiles: Array<Path>;
|
||||
setupFilesAfterEnv: Array<Path>;
|
||||
skipFilter: boolean;
|
||||
slowTestThreshold: number;
|
||||
snapshotSerializers: Array<Path>;
|
||||
testEnvironment: string;
|
||||
testEnvironmentOptions: Record<string, unknown>;
|
||||
testFailureExitCode: string | number;
|
||||
testLocationInResults: boolean;
|
||||
testMatch: Array<Glob>;
|
||||
testPathIgnorePatterns: Array<string>;
|
||||
testRegex: Array<string>;
|
||||
testRunner: string;
|
||||
testSequencer: string;
|
||||
testURL: string;
|
||||
timers: Timers;
|
||||
transformIgnorePatterns: Array<Glob>;
|
||||
useStderr: boolean;
|
||||
watch: boolean;
|
||||
watchPathIgnorePatterns: Array<string>;
|
||||
watchman: boolean;
|
||||
};
|
||||
export declare type DisplayName = {
|
||||
name: string;
|
||||
color: typeof ForegroundColor;
|
||||
};
|
||||
export declare type InitialOptionsWithRootDir = InitialOptions & Required<Pick<InitialOptions, 'rootDir'>>;
|
||||
export declare type InitialOptions = Partial<{
|
||||
automock: boolean;
|
||||
bail: boolean | number;
|
||||
cache: boolean;
|
||||
cacheDirectory: Path;
|
||||
clearMocks: boolean;
|
||||
changedFilesWithAncestor: boolean;
|
||||
changedSince: string;
|
||||
collectCoverage: boolean;
|
||||
collectCoverageFrom: Array<Glob>;
|
||||
collectCoverageOnlyFrom: {
|
||||
[key: string]: boolean;
|
||||
};
|
||||
coverageDirectory: string;
|
||||
coveragePathIgnorePatterns: Array<string>;
|
||||
coverageProvider: CoverageProvider;
|
||||
coverageReporters: CoverageReporters;
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
[key: string]: number;
|
||||
};
|
||||
};
|
||||
dependencyExtractor: string;
|
||||
detectLeaks: boolean;
|
||||
detectOpenHandles: boolean;
|
||||
displayName: string | DisplayName;
|
||||
expand: boolean;
|
||||
extraGlobals: Array<string>;
|
||||
filter: Path;
|
||||
findRelatedTests: boolean;
|
||||
forceCoverageMatch: Array<Glob>;
|
||||
forceExit: boolean;
|
||||
json: boolean;
|
||||
globals: ConfigGlobals;
|
||||
globalSetup: string | null | undefined;
|
||||
globalTeardown: string | null | undefined;
|
||||
haste: HasteConfig;
|
||||
injectGlobals: boolean;
|
||||
reporters: Array<string | ReporterConfig>;
|
||||
logHeapUsage: boolean;
|
||||
lastCommit: boolean;
|
||||
listTests: boolean;
|
||||
mapCoverage: boolean;
|
||||
maxConcurrency: number;
|
||||
maxWorkers: number | string;
|
||||
moduleDirectories: Array<string>;
|
||||
moduleFileExtensions: Array<string>;
|
||||
moduleLoader: Path;
|
||||
moduleNameMapper: {
|
||||
[key: string]: string | Array<string>;
|
||||
};
|
||||
modulePathIgnorePatterns: Array<string>;
|
||||
modulePaths: Array<string>;
|
||||
name: string;
|
||||
noStackTrace: boolean;
|
||||
notify: boolean;
|
||||
notifyMode: string;
|
||||
onlyChanged: boolean;
|
||||
onlyFailures: boolean;
|
||||
outputFile: Path;
|
||||
passWithNoTests: boolean;
|
||||
preprocessorIgnorePatterns: Array<Glob>;
|
||||
preset: string | null | undefined;
|
||||
prettierPath: string | null | undefined;
|
||||
projects: Array<Glob>;
|
||||
replname: string | null | undefined;
|
||||
resetMocks: boolean;
|
||||
resetModules: boolean;
|
||||
resolver: Path | null | undefined;
|
||||
restoreMocks: boolean;
|
||||
rootDir: Path;
|
||||
roots: Array<Path>;
|
||||
runner: string;
|
||||
runTestsByPath: boolean;
|
||||
scriptPreprocessor: string;
|
||||
setupFiles: Array<Path>;
|
||||
setupTestFrameworkScriptFile: Path;
|
||||
setupFilesAfterEnv: Array<Path>;
|
||||
silent: boolean;
|
||||
skipFilter: boolean;
|
||||
skipNodeResolution: boolean;
|
||||
slowTestThreshold: number;
|
||||
snapshotResolver: Path;
|
||||
snapshotSerializers: Array<Path>;
|
||||
errorOnDeprecated: boolean;
|
||||
testEnvironment: string;
|
||||
testEnvironmentOptions: Record<string, unknown>;
|
||||
testFailureExitCode: string | number;
|
||||
testLocationInResults: boolean;
|
||||
testMatch: Array<Glob>;
|
||||
testNamePattern: string;
|
||||
testPathDirs: Array<Path>;
|
||||
testPathIgnorePatterns: Array<string>;
|
||||
testRegex: string | Array<string>;
|
||||
testResultsProcessor: string;
|
||||
testRunner: string;
|
||||
testSequencer: string;
|
||||
testURL: string;
|
||||
testTimeout: number;
|
||||
timers: Timers;
|
||||
transform: {
|
||||
[regex: string]: Path | TransformerConfig;
|
||||
};
|
||||
transformIgnorePatterns: Array<Glob>;
|
||||
watchPathIgnorePatterns: Array<string>;
|
||||
unmockedModulePathPatterns: Array<string>;
|
||||
updateSnapshot: boolean;
|
||||
useStderr: boolean;
|
||||
verbose?: boolean;
|
||||
watch: boolean;
|
||||
watchAll: boolean;
|
||||
watchman: boolean;
|
||||
watchPlugins: Array<string | [string, Record<string, unknown>]>;
|
||||
}>;
|
||||
export declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
||||
declare type NotifyMode = 'always' | 'failure' | 'success' | 'change' | 'success-change' | 'failure-change';
|
||||
export declare type CoverageThresholdValue = {
|
||||
branches?: number;
|
||||
functions?: number;
|
||||
lines?: number;
|
||||
statements?: number;
|
||||
};
|
||||
declare type CoverageThreshold = {
|
||||
[path: string]: CoverageThresholdValue;
|
||||
global: CoverageThresholdValue;
|
||||
};
|
||||
export declare type GlobalConfig = {
|
||||
bail: number;
|
||||
changedSince?: string;
|
||||
changedFilesWithAncestor: boolean;
|
||||
collectCoverage: boolean;
|
||||
collectCoverageFrom: Array<Glob>;
|
||||
collectCoverageOnlyFrom?: {
|
||||
[key: string]: boolean;
|
||||
};
|
||||
coverageDirectory: string;
|
||||
coveragePathIgnorePatterns?: Array<string>;
|
||||
coverageProvider: CoverageProvider;
|
||||
coverageReporters: CoverageReporters;
|
||||
coverageThreshold?: CoverageThreshold;
|
||||
detectLeaks: boolean;
|
||||
detectOpenHandles: boolean;
|
||||
enabledTestsMap?: {
|
||||
[key: string]: {
|
||||
[key: string]: boolean;
|
||||
};
|
||||
};
|
||||
expand: boolean;
|
||||
filter?: Path;
|
||||
findRelatedTests: boolean;
|
||||
forceExit: boolean;
|
||||
json: boolean;
|
||||
globalSetup?: string;
|
||||
globalTeardown?: string;
|
||||
lastCommit: boolean;
|
||||
logHeapUsage: boolean;
|
||||
listTests: boolean;
|
||||
maxConcurrency: number;
|
||||
maxWorkers: number;
|
||||
noStackTrace: boolean;
|
||||
nonFlagArgs: Array<string>;
|
||||
noSCM?: boolean;
|
||||
notify: boolean;
|
||||
notifyMode: NotifyMode;
|
||||
outputFile?: Path;
|
||||
onlyChanged: boolean;
|
||||
onlyFailures: boolean;
|
||||
passWithNoTests: boolean;
|
||||
projects: Array<Glob>;
|
||||
replname?: string;
|
||||
reporters?: Array<string | ReporterConfig>;
|
||||
runTestsByPath: boolean;
|
||||
rootDir: Path;
|
||||
silent?: boolean;
|
||||
skipFilter: boolean;
|
||||
errorOnDeprecated: boolean;
|
||||
testFailureExitCode: number;
|
||||
testNamePattern?: string;
|
||||
testPathPattern: string;
|
||||
testResultsProcessor?: string;
|
||||
testSequencer: string;
|
||||
testTimeout?: number;
|
||||
updateSnapshot: SnapshotUpdateState;
|
||||
useStderr: boolean;
|
||||
verbose?: boolean;
|
||||
watch: boolean;
|
||||
watchAll: boolean;
|
||||
watchman: boolean;
|
||||
watchPlugins?: Array<{
|
||||
path: string;
|
||||
config: Record<string, unknown>;
|
||||
}> | null;
|
||||
};
|
||||
export declare type ProjectConfig = {
|
||||
automock: boolean;
|
||||
cache: boolean;
|
||||
cacheDirectory: Path;
|
||||
clearMocks: boolean;
|
||||
coveragePathIgnorePatterns: Array<string>;
|
||||
cwd: Path;
|
||||
dependencyExtractor?: string;
|
||||
detectLeaks: boolean;
|
||||
detectOpenHandles: boolean;
|
||||
displayName?: DisplayName;
|
||||
errorOnDeprecated: boolean;
|
||||
extraGlobals: Array<keyof NodeJS.Global>;
|
||||
filter?: Path;
|
||||
forceCoverageMatch: Array<Glob>;
|
||||
globalSetup?: string;
|
||||
globalTeardown?: string;
|
||||
globals: ConfigGlobals;
|
||||
haste: HasteConfig;
|
||||
injectGlobals: boolean;
|
||||
moduleDirectories: Array<string>;
|
||||
moduleFileExtensions: Array<string>;
|
||||
moduleLoader?: Path;
|
||||
moduleNameMapper: Array<[string, string]>;
|
||||
modulePathIgnorePatterns: Array<string>;
|
||||
modulePaths?: Array<string>;
|
||||
name: string;
|
||||
prettierPath: string;
|
||||
resetMocks: boolean;
|
||||
resetModules: boolean;
|
||||
resolver?: Path;
|
||||
restoreMocks: boolean;
|
||||
rootDir: Path;
|
||||
roots: Array<Path>;
|
||||
runner: string;
|
||||
setupFiles: Array<Path>;
|
||||
setupFilesAfterEnv: Array<Path>;
|
||||
skipFilter: boolean;
|
||||
skipNodeResolution?: boolean;
|
||||
slowTestThreshold: number;
|
||||
snapshotResolver?: Path;
|
||||
snapshotSerializers: Array<Path>;
|
||||
testEnvironment: string;
|
||||
testEnvironmentOptions: Record<string, unknown>;
|
||||
testMatch: Array<Glob>;
|
||||
testLocationInResults: boolean;
|
||||
testPathIgnorePatterns: Array<string>;
|
||||
testRegex: Array<string | RegExp>;
|
||||
testRunner: string;
|
||||
testURL: string;
|
||||
timers: Timers;
|
||||
transform: Array<[string, Path, Record<string, unknown>]>;
|
||||
transformIgnorePatterns: Array<Glob>;
|
||||
watchPathIgnorePatterns: Array<string>;
|
||||
unmockedModulePathPatterns?: Array<string>;
|
||||
};
|
||||
export declare type Argv = Arguments<Partial<{
|
||||
all: boolean;
|
||||
automock: boolean;
|
||||
bail: boolean | number;
|
||||
cache: boolean;
|
||||
cacheDirectory: string;
|
||||
changedFilesWithAncestor: boolean;
|
||||
changedSince: string;
|
||||
ci: boolean;
|
||||
clearCache: boolean;
|
||||
clearMocks: boolean;
|
||||
collectCoverage: boolean;
|
||||
collectCoverageFrom: string;
|
||||
collectCoverageOnlyFrom: Array<string>;
|
||||
color: boolean;
|
||||
colors: boolean;
|
||||
config: string;
|
||||
coverage: boolean;
|
||||
coverageDirectory: string;
|
||||
coveragePathIgnorePatterns: Array<string>;
|
||||
coverageReporters: Array<string>;
|
||||
coverageThreshold: string;
|
||||
debug: boolean;
|
||||
env: string;
|
||||
expand: boolean;
|
||||
findRelatedTests: boolean;
|
||||
forceExit: boolean;
|
||||
globals: string;
|
||||
globalSetup: string | null | undefined;
|
||||
globalTeardown: string | null | undefined;
|
||||
haste: string;
|
||||
init: boolean;
|
||||
injectGlobals: boolean;
|
||||
json: boolean;
|
||||
lastCommit: boolean;
|
||||
logHeapUsage: boolean;
|
||||
maxWorkers: number | string;
|
||||
moduleDirectories: Array<string>;
|
||||
moduleFileExtensions: Array<string>;
|
||||
moduleNameMapper: string;
|
||||
modulePathIgnorePatterns: Array<string>;
|
||||
modulePaths: Array<string>;
|
||||
noStackTrace: boolean;
|
||||
notify: boolean;
|
||||
notifyMode: string;
|
||||
onlyChanged: boolean;
|
||||
onlyFailures: boolean;
|
||||
outputFile: string;
|
||||
preset: string | null | undefined;
|
||||
projects: Array<string>;
|
||||
prettierPath: string | null | undefined;
|
||||
resetMocks: boolean;
|
||||
resetModules: boolean;
|
||||
resolver: string | null | undefined;
|
||||
restoreMocks: boolean;
|
||||
rootDir: string;
|
||||
roots: Array<string>;
|
||||
runInBand: boolean;
|
||||
selectProjects: Array<string>;
|
||||
setupFiles: Array<string>;
|
||||
setupFilesAfterEnv: Array<string>;
|
||||
showConfig: boolean;
|
||||
silent: boolean;
|
||||
snapshotSerializers: Array<string>;
|
||||
testEnvironment: string;
|
||||
testFailureExitCode: string | null | undefined;
|
||||
testMatch: Array<string>;
|
||||
testNamePattern: string;
|
||||
testPathIgnorePatterns: Array<string>;
|
||||
testPathPattern: Array<string>;
|
||||
testRegex: string | Array<string>;
|
||||
testResultsProcessor: string;
|
||||
testRunner: string;
|
||||
testSequencer: string;
|
||||
testURL: string;
|
||||
testTimeout: number | null | undefined;
|
||||
timers: string;
|
||||
transform: string;
|
||||
transformIgnorePatterns: Array<string>;
|
||||
unmockedModulePathPatterns: Array<string> | null | undefined;
|
||||
updateSnapshot: boolean;
|
||||
useStderr: boolean;
|
||||
verbose: boolean;
|
||||
version: boolean;
|
||||
watch: boolean;
|
||||
watchAll: boolean;
|
||||
watchman: boolean;
|
||||
watchPathIgnorePatterns: Array<string>;
|
||||
}>>;
|
||||
export {};
|
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Config.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Config.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
88
web/node_modules/jest-diff/node_modules/@jest/types/build/Global.d.ts
generated
vendored
Normal file
88
web/node_modules/jest-diff/node_modules/@jest/types/build/Global.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import type { CoverageMapData } from 'istanbul-lib-coverage';
|
||||
export declare type DoneFn = (reason?: string | Error) => void;
|
||||
export declare type TestName = string;
|
||||
export declare type TestFn = (done?: DoneFn) => Promise<void | undefined | unknown> | void | undefined;
|
||||
export declare type ConcurrentTestFn = (done?: DoneFn) => Promise<void | undefined | unknown>;
|
||||
export declare type BlockFn = () => void;
|
||||
export declare type BlockName = string;
|
||||
export declare type HookFn = TestFn;
|
||||
export declare type Col = unknown;
|
||||
export declare type Row = Array<Col>;
|
||||
export declare type Table = Array<Row>;
|
||||
export declare type ArrayTable = Table | Row;
|
||||
export declare type TemplateTable = TemplateStringsArray;
|
||||
export declare type TemplateData = Array<unknown>;
|
||||
export declare type EachTable = ArrayTable | TemplateTable;
|
||||
export declare type TestCallback = BlockFn | TestFn | ConcurrentTestFn;
|
||||
export declare type EachTestFn<EachCallback extends TestCallback> = (...args: Array<any>) => ReturnType<EachCallback>;
|
||||
declare type Jasmine = {
|
||||
_DEFAULT_TIMEOUT_INTERVAL?: number;
|
||||
addMatchers: (matchers: Record<string, unknown>) => void;
|
||||
};
|
||||
declare type Each<EachCallback extends TestCallback> = ((table: EachTable, ...taggedTemplateData: Array<unknown>) => (title: string, test: EachTestFn<EachCallback>, timeout?: number) => void) | (() => () => void);
|
||||
export interface HookBase {
|
||||
(fn: HookFn, timeout?: number): void;
|
||||
}
|
||||
export interface ItBase {
|
||||
(testName: TestName, fn: TestFn, timeout?: number): void;
|
||||
each: Each<TestFn>;
|
||||
}
|
||||
export interface It extends ItBase {
|
||||
only: ItBase;
|
||||
skip: ItBase;
|
||||
todo: (testName: TestName) => void;
|
||||
}
|
||||
export interface ItConcurrentBase {
|
||||
(testName: string, testFn: ConcurrentTestFn, timeout?: number): void;
|
||||
each: Each<ConcurrentTestFn>;
|
||||
}
|
||||
export interface ItConcurrentExtended extends ItConcurrentBase {
|
||||
only: ItConcurrentBase;
|
||||
skip: ItConcurrentBase;
|
||||
}
|
||||
export interface ItConcurrent extends It {
|
||||
concurrent: ItConcurrentExtended;
|
||||
}
|
||||
export interface DescribeBase {
|
||||
(blockName: BlockName, blockFn: BlockFn): void;
|
||||
each: Each<BlockFn>;
|
||||
}
|
||||
export interface Describe extends DescribeBase {
|
||||
only: DescribeBase;
|
||||
skip: DescribeBase;
|
||||
}
|
||||
export interface TestFrameworkGlobals {
|
||||
it: ItConcurrent;
|
||||
test: ItConcurrent;
|
||||
fit: ItBase & {
|
||||
concurrent?: ItConcurrentBase;
|
||||
};
|
||||
xit: ItBase;
|
||||
xtest: ItBase;
|
||||
describe: Describe;
|
||||
xdescribe: DescribeBase;
|
||||
fdescribe: DescribeBase;
|
||||
beforeAll: HookBase;
|
||||
beforeEach: HookBase;
|
||||
afterEach: HookBase;
|
||||
afterAll: HookBase;
|
||||
}
|
||||
export interface GlobalAdditions extends TestFrameworkGlobals {
|
||||
__coverage__: CoverageMapData;
|
||||
jasmine: Jasmine;
|
||||
fail: () => void;
|
||||
pending: () => void;
|
||||
spyOn: () => void;
|
||||
spyOnProperty: () => void;
|
||||
}
|
||||
export interface Global extends GlobalAdditions, Omit<NodeJS.Global, keyof GlobalAdditions> {
|
||||
[extras: string]: unknown;
|
||||
}
|
||||
export {};
|
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Global.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Global.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
31
web/node_modules/jest-diff/node_modules/@jest/types/build/TestResult.d.ts
generated
vendored
Normal file
31
web/node_modules/jest-diff/node_modules/@jest/types/build/TestResult.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare type Milliseconds = number;
|
||||
declare type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
|
||||
declare type Callsite = {
|
||||
column: number;
|
||||
line: number;
|
||||
};
|
||||
export declare type AssertionResult = {
|
||||
ancestorTitles: Array<string>;
|
||||
duration?: Milliseconds | null;
|
||||
failureDetails: Array<unknown>;
|
||||
failureMessages: Array<string>;
|
||||
fullName: string;
|
||||
invocations?: number;
|
||||
location?: Callsite | null;
|
||||
numPassingAsserts: number;
|
||||
status: Status;
|
||||
title: string;
|
||||
};
|
||||
export declare type SerializableError = {
|
||||
code?: unknown;
|
||||
message: string;
|
||||
stack: string | null | undefined;
|
||||
type?: string;
|
||||
};
|
||||
export {};
|
1
web/node_modules/jest-diff/node_modules/@jest/types/build/TestResult.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/node_modules/@jest/types/build/TestResult.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
12
web/node_modules/jest-diff/node_modules/@jest/types/build/Transform.d.ts
generated
vendored
Normal file
12
web/node_modules/jest-diff/node_modules/@jest/types/build/Transform.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare type TransformResult = {
|
||||
code: string;
|
||||
originalCode: string;
|
||||
mapCoverage?: boolean;
|
||||
sourceMapPath: string | null;
|
||||
};
|
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Transform.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/node_modules/@jest/types/build/Transform.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
12
web/node_modules/jest-diff/node_modules/@jest/types/build/index.d.ts
generated
vendored
Normal file
12
web/node_modules/jest-diff/node_modules/@jest/types/build/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type * as Circus from './Circus';
|
||||
import type * as Config from './Config';
|
||||
import type * as Global from './Global';
|
||||
import type * as TestResult from './TestResult';
|
||||
import type * as TransformTypes from './Transform';
|
||||
export type { Circus, Config, Global, TestResult, TransformTypes };
|
1
web/node_modules/jest-diff/node_modules/@jest/types/build/index.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/node_modules/@jest/types/build/index.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
26
web/node_modules/jest-diff/node_modules/@jest/types/package.json
generated
vendored
Normal file
26
web/node_modules/jest-diff/node_modules/@jest/types/package.json
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "@jest/types",
|
||||
"version": "26.6.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/jest.git",
|
||||
"directory": "packages/jest-types"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.14.2"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
"dependencies": {
|
||||
"@types/istanbul-lib-coverage": "^2.0.0",
|
||||
"@types/istanbul-reports": "^3.0.0",
|
||||
"@types/node": "*",
|
||||
"@types/yargs": "^15.0.0",
|
||||
"chalk": "^4.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4c46930615602cbf983fb7e8e82884c282a624d5"
|
||||
}
|
21
web/node_modules/jest-diff/node_modules/@types/yargs/LICENSE
generated
vendored
Executable file
21
web/node_modules/jest-diff/node_modules/@types/yargs/LICENSE
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
16
web/node_modules/jest-diff/node_modules/@types/yargs/README.md
generated
vendored
Executable file
16
web/node_modules/jest-diff/node_modules/@types/yargs/README.md
generated
vendored
Executable file
|
@ -0,0 +1,16 @@
|
|||
# Installation
|
||||
> `npm install --save @types/yargs`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for yargs (https://github.com/chevex/yargs).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs/v15.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Fri, 02 Jul 2021 16:32:05 GMT
|
||||
* Dependencies: [@types/yargs-parser](https://npmjs.com/package/@types/yargs-parser)
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Martin Poelstra](https://github.com/poelstra), [Mizunashi Mana](https://github.com/mizunashi-mana), [Jeffery Grajkowski](https://github.com/pushplay), [Jimi (Dimitris) Charalampidis](https://github.com/JimiC), [Steffen Viken Valvåg](https://github.com/steffenvv), [Emily Marigold Klassen](https://github.com/forivall), [ExE Boss](https://github.com/ExE-Boss), and [Aankhen](https://github.com/Aankhen).
|
836
web/node_modules/jest-diff/node_modules/@types/yargs/index.d.ts
generated
vendored
Executable file
836
web/node_modules/jest-diff/node_modules/@types/yargs/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,836 @@
|
|||
// Type definitions for yargs 15.0
|
||||
// Project: https://github.com/chevex/yargs, https://yargs.js.org
|
||||
// Definitions by: Martin Poelstra <https://github.com/poelstra>
|
||||
// Mizunashi Mana <https://github.com/mizunashi-mana>
|
||||
// Jeffery Grajkowski <https://github.com/pushplay>
|
||||
// Jimi (Dimitris) Charalampidis <https://github.com/JimiC>
|
||||
// Steffen Viken Valvåg <https://github.com/steffenvv>
|
||||
// Emily Marigold Klassen <https://github.com/forivall>
|
||||
// ExE Boss <https://github.com/ExE-Boss>
|
||||
// Aankhen <https://github.com/Aankhen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
// The following TSLint rules have been disabled:
|
||||
// unified-signatures: Because there is useful information in the argument names of the overloaded signatures
|
||||
|
||||
// Convention:
|
||||
// Use 'union types' when:
|
||||
// - parameter types have similar signature type (i.e. 'string | ReadonlyArray<string>')
|
||||
// - parameter names have the same semantic meaning (i.e. ['command', 'commands'] , ['key', 'keys'])
|
||||
// An example for not using 'union types' is the declaration of 'env' where `prefix` and `enable` parameters
|
||||
// have different semantics. On the other hand, in the declaration of 'usage', a `command: string` parameter
|
||||
// has the same semantic meaning with declaring an overload method by using `commands: ReadonlyArray<string>`,
|
||||
// thus it's preferred to use `command: string | ReadonlyArray<string>`
|
||||
// Use parameterless declaration instead of declaring all parameters optional,
|
||||
// when all parameters are optional and more than one
|
||||
|
||||
import { DetailedArguments, Configuration } from 'yargs-parser';
|
||||
|
||||
declare namespace yargs {
|
||||
type BuilderCallback<T, R> = ((args: Argv<T>) => PromiseLike<Argv<R>>) | ((args: Argv<T>) => Argv<R>) | ((args: Argv<T>) => void);
|
||||
|
||||
type ParserConfigurationOptions = Configuration & {
|
||||
/** Sort commands alphabetically. Default is `false` */
|
||||
'sort-commands': boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* The type parameter `T` is the expected shape of the parsed options.
|
||||
* `Arguments<T>` is those options plus `_` and `$0`, and an indexer falling
|
||||
* back to `unknown` for unknown options.
|
||||
*
|
||||
* For the return type / `argv` property, we create a mapped type over
|
||||
* `Arguments<T>` to simplify the inferred type signature in client code.
|
||||
*/
|
||||
interface Argv<T = {}> {
|
||||
(): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
(args: ReadonlyArray<string>, cwd?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Set key names as equivalent such that updates to a key will propagate to aliases and vice-versa.
|
||||
*
|
||||
* Optionally `.alias()` can take an object that maps keys to aliases.
|
||||
* Each key of this object should be the canonical version of the option, and each value should be a string or an array of strings.
|
||||
*/
|
||||
// Aliases for previously declared options can inherit the types of those options.
|
||||
alias<K1 extends keyof T, K2 extends string>(shortName: K1, longName: K2 | ReadonlyArray<K2>): Argv<T & { [key in K2]: T[K1] }>;
|
||||
alias<K1 extends keyof T, K2 extends string>(shortName: K2, longName: K1 | ReadonlyArray<K1>): Argv<T & { [key in K2]: T[K1] }>;
|
||||
alias(shortName: string | ReadonlyArray<string>, longName: string | ReadonlyArray<string>): Argv<T>;
|
||||
alias(aliases: { [shortName: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||
|
||||
/**
|
||||
* Get the arguments as a plain old object.
|
||||
*
|
||||
* Arguments without a corresponding flag show up in the `argv._` array.
|
||||
*
|
||||
* The script name or node command is available at `argv.$0` similarly to how `$0` works in bash or perl.
|
||||
*
|
||||
* If `yargs` is executed in an environment that embeds node and there's no script name (e.g. Electron or nw.js),
|
||||
* it will ignore the first parameter since it expects it to be the script name. In order to override
|
||||
* this behavior, use `.parse(process.argv.slice(1))` instead of .argv and the first parameter won't be ignored.
|
||||
*/
|
||||
argv: { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
|
||||
/**
|
||||
* Tell the parser to interpret `key` as an array.
|
||||
* If `.array('foo')` is set, `--foo foo bar` will be parsed as `['foo', 'bar']` rather than as `'foo'`.
|
||||
* Also, if you use the option multiple times all the values will be flattened in one array so `--foo foo --foo bar` will be parsed as `['foo', 'bar']`
|
||||
*
|
||||
* When the option is used with a positional, use `--` to tell `yargs` to stop adding values to the array.
|
||||
*/
|
||||
array<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToArray<T[key]> }>;
|
||||
array<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: Array<string | number> | undefined }>;
|
||||
|
||||
/**
|
||||
* Interpret `key` as a boolean. If a non-flag option follows `key` in `process.argv`, that string won't get set as the value of `key`.
|
||||
*
|
||||
* `key` will default to `false`, unless a `default(key, undefined)` is explicitly set.
|
||||
*
|
||||
* If `key` is an array, interpret all the elements as booleans.
|
||||
*/
|
||||
boolean<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: boolean | undefined }>;
|
||||
boolean<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: boolean | undefined }>;
|
||||
|
||||
/**
|
||||
* Check that certain conditions are met in the provided arguments.
|
||||
* @param func Called with two arguments, the parsed `argv` hash and an array of options and their aliases.
|
||||
* If `func` throws or returns a non-truthy value, show the thrown error, usage information, and exit.
|
||||
* @param global Indicates whether `check()` should be enabled both at the top-level and for each sub-command.
|
||||
*/
|
||||
check(func: (argv: Arguments<T>, aliases: { [alias: string]: string }) => any, global?: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* Limit valid values for key to a predefined set of choices, given as an array or as an individual value.
|
||||
* If this method is called multiple times, all enumerated values will be merged together.
|
||||
* Choices are generally strings or numbers, and value matching is case-sensitive.
|
||||
*
|
||||
* Optionally `.choices()` can take an object that maps multiple keys to their choices.
|
||||
*
|
||||
* Choices can also be specified as choices in the object given to `option()`.
|
||||
*/
|
||||
choices<K extends keyof T, C extends ReadonlyArray<any>>(key: K, values: C): Argv<Omit<T, K> & { [key in K]: C[number] | undefined }>;
|
||||
choices<K extends string, C extends ReadonlyArray<any>>(key: K, values: C): Argv<T & { [key in K]: C[number] | undefined }>;
|
||||
choices<C extends { [key: string]: ReadonlyArray<any> }>(choices: C): Argv<Omit<T, keyof C> & { [key in keyof C]: C[key][number] | undefined }>;
|
||||
|
||||
/**
|
||||
* Provide a synchronous function to coerce or transform the value(s) given on the command line for `key`.
|
||||
*
|
||||
* The coercion function should accept one argument, representing the parsed value from the command line, and should return a new value or throw an error.
|
||||
* The returned value will be used as the value for `key` (or one of its aliases) in `argv`.
|
||||
*
|
||||
* If the function throws, the error will be treated as a validation failure, delegating to either a custom `.fail()` handler or printing the error message in the console.
|
||||
*
|
||||
* Coercion will be applied to a value after all other modifications, such as `.normalize()`.
|
||||
*
|
||||
* Optionally `.coerce()` can take an object that maps several keys to their respective coercion function.
|
||||
*
|
||||
* You can also map the same function to several keys at one time. Just pass an array of keys as the first argument to `.coerce()`.
|
||||
*
|
||||
* If you are using dot-notion or arrays, .e.g., `user.email` and `user.password`, coercion will be applied to the final object that has been parsed
|
||||
*/
|
||||
coerce<K extends keyof T, V>(key: K | ReadonlyArray<K>, func: (arg: any) => V): Argv<Omit<T, K> & { [key in K]: V | undefined }>;
|
||||
coerce<K extends string, V>(key: K | ReadonlyArray<K>, func: (arg: any) => V): Argv<T & { [key in K]: V | undefined }>;
|
||||
coerce<O extends { [key: string]: (arg: any) => any }>(opts: O): Argv<Omit<T, keyof O> & { [key in keyof O]: ReturnType<O[key]> | undefined }>;
|
||||
|
||||
/**
|
||||
* Define the commands exposed by your application.
|
||||
* @param command Should be a string representing the command or an array of strings representing the command and its aliases.
|
||||
* @param description Use to provide a description for each command your application accepts (the values stored in `argv._`).
|
||||
* Set `description` to false to create a hidden command. Hidden commands don't show up in the help output and aren't available for completion.
|
||||
* @param [builder] Object to give hints about the options that your command accepts.
|
||||
* Can also be a function. This function is executed with a yargs instance, and can be used to provide advanced command specific help.
|
||||
*
|
||||
* Note that when `void` is returned, the handler `argv` object type will not include command-specific arguments.
|
||||
* @param [handler] Function, which will be executed with the parsed `argv` object.
|
||||
*/
|
||||
command<U = T>(
|
||||
command: string | ReadonlyArray<string>,
|
||||
description: string,
|
||||
builder?: BuilderCallback<T, U>,
|
||||
handler?: (args: Arguments<U>) => void,
|
||||
middlewares?: MiddlewareFunction[],
|
||||
deprecated?: boolean | string,
|
||||
): Argv<U>;
|
||||
command<O extends { [key: string]: Options }>(
|
||||
command: string | ReadonlyArray<string>,
|
||||
description: string,
|
||||
builder?: O,
|
||||
handler?: (args: Arguments<InferredOptionTypes<O>>) => void,
|
||||
middlewares?: MiddlewareFunction[],
|
||||
deprecated?: boolean | string,
|
||||
): Argv<T>;
|
||||
command<U>(command: string | ReadonlyArray<string>, description: string, module: CommandModule<T, U>): Argv<U>;
|
||||
command<U = T>(
|
||||
command: string | ReadonlyArray<string>,
|
||||
showInHelp: false,
|
||||
builder?: BuilderCallback<T, U>,
|
||||
handler?: (args: Arguments<U>) => void,
|
||||
middlewares?: MiddlewareFunction[],
|
||||
deprecated?: boolean | string,
|
||||
): Argv<T>;
|
||||
command<O extends { [key: string]: Options }>(
|
||||
command: string | ReadonlyArray<string>,
|
||||
showInHelp: false,
|
||||
builder?: O,
|
||||
handler?: (args: Arguments<InferredOptionTypes<O>>) => void,
|
||||
): Argv<T>;
|
||||
command<U>(command: string | ReadonlyArray<string>, showInHelp: false, module: CommandModule<T, U>): Argv<U>;
|
||||
command<U>(module: CommandModule<T, U>): Argv<U>;
|
||||
|
||||
// Advanced API
|
||||
/** Apply command modules from a directory relative to the module calling this method. */
|
||||
commandDir(dir: string, opts?: RequireDirectoryOptions): Argv<T>;
|
||||
|
||||
/**
|
||||
* Enable bash/zsh-completion shortcuts for commands and options.
|
||||
*
|
||||
* If invoked without parameters, `.completion()` will make completion the command to output the completion script.
|
||||
*
|
||||
* @param [cmd] When present in `argv._`, will result in the `.bashrc` or `.zshrc` completion script being outputted.
|
||||
* To enable bash/zsh completions, concat the generated script to your `.bashrc` or `.bash_profile` (or `.zshrc` for zsh).
|
||||
* @param [description] Provide a description in your usage instructions for the command that generates the completion scripts.
|
||||
* @param [func] Rather than relying on yargs' default completion functionality, which shiver me timbers is pretty awesome, you can provide your own completion method.
|
||||
*/
|
||||
completion(): Argv<T>;
|
||||
completion(cmd: string, func?: AsyncCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, func?: SyncCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, func?: PromiseCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, description?: string | false, func?: AsyncCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, description?: string | false, func?: SyncCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, description?: string | false, func?: PromiseCompletionFunction): Argv<T>;
|
||||
|
||||
/**
|
||||
* Tells the parser that if the option specified by `key` is passed in, it should be interpreted as a path to a JSON config file.
|
||||
* The file is loaded and parsed, and its properties are set as arguments.
|
||||
* Because the file is loaded using Node's require(), the filename MUST end in `.json` to be interpreted correctly.
|
||||
*
|
||||
* If invoked without parameters, `.config()` will make --config the option to pass the JSON config file.
|
||||
*
|
||||
* @param [description] Provided to customize the config (`key`) option in the usage string.
|
||||
* @param [explicitConfigurationObject] An explicit configuration `object`
|
||||
*/
|
||||
config(): Argv<T>;
|
||||
config(key: string | ReadonlyArray<string>, description?: string, parseFn?: (configPath: string) => object): Argv<T>;
|
||||
config(key: string | ReadonlyArray<string>, parseFn: (configPath: string) => object): Argv<T>;
|
||||
config(explicitConfigurationObject: object): Argv<T>;
|
||||
|
||||
/**
|
||||
* Given the key `x` is set, the key `y` must not be set. `y` can either be a single string or an array of argument names that `x` conflicts with.
|
||||
*
|
||||
* Optionally `.conflicts()` can accept an object specifying multiple conflicting keys.
|
||||
*/
|
||||
conflicts(key: string, value: string | ReadonlyArray<string>): Argv<T>;
|
||||
conflicts(conflicts: { [key: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||
|
||||
/**
|
||||
* Interpret `key` as a boolean flag, but set its parsed value to the number of flag occurrences rather than `true` or `false`. Default value is thus `0`.
|
||||
*/
|
||||
count<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: number }>;
|
||||
count<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: number }>;
|
||||
|
||||
/**
|
||||
* Set `argv[key]` to `value` if no option was specified in `process.argv`.
|
||||
*
|
||||
* Optionally `.default()` can take an object that maps keys to default values.
|
||||
*
|
||||
* The default value can be a `function` which returns a value. The name of the function will be used in the usage string.
|
||||
*
|
||||
* Optionally, `description` can also be provided and will take precedence over displaying the value in the usage instructions.
|
||||
*/
|
||||
default<K extends keyof T, V>(key: K, value: V, description?: string): Argv<Omit<T, K> & { [key in K]: V }>;
|
||||
default<K extends string, V>(key: K, value: V, description?: string): Argv<T & { [key in K]: V }>;
|
||||
default<D extends { [key: string]: any }>(defaults: D, description?: string): Argv<Omit<T, keyof D> & D>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.demandCommand()' or '.demandOption()' instead
|
||||
*/
|
||||
demand<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
demand<K extends string>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<T & { [key in K]: unknown }>;
|
||||
demand(key: string | ReadonlyArray<string>, required?: boolean): Argv<T>;
|
||||
demand(positionals: number, msg: string): Argv<T>;
|
||||
demand(positionals: number, required?: boolean): Argv<T>;
|
||||
demand(positionals: number, max: number, msg?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* @param key If is a string, show the usage information and exit if key wasn't specified in `process.argv`.
|
||||
* If is an array, demand each element.
|
||||
* @param msg If string is given, it will be printed when the argument is missing, instead of the standard error message.
|
||||
* @param demand Controls whether the option is demanded; this is useful when using .options() to specify command line parameters.
|
||||
*/
|
||||
demandOption<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
demandOption<K extends string>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<T & { [key in K]: unknown }>;
|
||||
demandOption(key: string | ReadonlyArray<string>, demand?: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* Demand in context of commands.
|
||||
* You can demand a minimum and a maximum number a user can have within your program, as well as provide corresponding error messages if either of the demands is not met.
|
||||
*/
|
||||
demandCommand(): Argv<T>;
|
||||
demandCommand(min: number, minMsg?: string): Argv<T>;
|
||||
demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Shows a [deprecated] notice in front of the option
|
||||
*/
|
||||
deprecateOption(option: string, msg?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Describe a `key` for the generated usage information.
|
||||
*
|
||||
* Optionally `.describe()` can take an object that maps keys to descriptions.
|
||||
*/
|
||||
describe(key: string | ReadonlyArray<string>, description: string): Argv<T>;
|
||||
describe(descriptions: { [key: string]: string }): Argv<T>;
|
||||
|
||||
/** Should yargs attempt to detect the os' locale? Defaults to `true`. */
|
||||
detectLocale(detect: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* Tell yargs to parse environment variables matching the given prefix and apply them to argv as though they were command line arguments.
|
||||
*
|
||||
* Use the "__" separator in the environment variable to indicate nested options. (e.g. prefix_nested__foo => nested.foo)
|
||||
*
|
||||
* If this method is called with no argument or with an empty string or with true, then all env vars will be applied to argv.
|
||||
*
|
||||
* Program arguments are defined in this order of precedence:
|
||||
* 1. Command line args
|
||||
* 2. Env vars
|
||||
* 3. Config file/objects
|
||||
* 4. Configured defaults
|
||||
*
|
||||
* Env var parsing is disabled by default, but you can also explicitly disable it by calling `.env(false)`, e.g. if you need to undo previous configuration.
|
||||
*/
|
||||
env(): Argv<T>;
|
||||
env(prefix: string): Argv<T>;
|
||||
env(enable: boolean): Argv<T>;
|
||||
|
||||
/** A message to print at the end of the usage instructions */
|
||||
epilog(msg: string): Argv<T>;
|
||||
/** A message to print at the end of the usage instructions */
|
||||
epilogue(msg: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Give some example invocations of your program.
|
||||
* Inside `cmd`, the string `$0` will get interpolated to the current script name or node command for the present script similar to how `$0` works in bash or perl.
|
||||
* Examples will be printed out as part of the help message.
|
||||
*/
|
||||
example(command: string, description: string): Argv<T>;
|
||||
example(command: ReadonlyArray<[string, string?]>): Argv<T>;
|
||||
|
||||
/** Manually indicate that the program should exit, and provide context about why we wanted to exit. Follows the behavior set by `.exitProcess().` */
|
||||
exit(code: number, err: Error): void;
|
||||
|
||||
/**
|
||||
* By default, yargs exits the process when the user passes a help flag, the user uses the `.version` functionality, validation fails, or the command handler fails.
|
||||
* Calling `.exitProcess(false)` disables this behavior, enabling further actions after yargs have been validated.
|
||||
*/
|
||||
exitProcess(enabled: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* Method to execute when a failure occurs, rather than printing the failure message.
|
||||
* @param func Is called with the failure message that would have been printed, the Error instance originally thrown and yargs state when the failure occurred.
|
||||
*/
|
||||
fail(func: (msg: string, err: Error, yargs: Argv<T>) => any): Argv<T>;
|
||||
|
||||
/**
|
||||
* Allows to programmatically get completion choices for any line.
|
||||
* @param args An array of the words in the command line to complete.
|
||||
* @param done The callback to be called with the resulting completions.
|
||||
*/
|
||||
getCompletion(args: ReadonlyArray<string>, done: (completions: ReadonlyArray<string>) => void): Argv<T>;
|
||||
|
||||
/**
|
||||
* Indicate that an option (or group of options) should not be reset when a command is executed
|
||||
*
|
||||
* Options default to being global.
|
||||
*/
|
||||
global(key: string | ReadonlyArray<string>): Argv<T>;
|
||||
|
||||
/** Given a key, or an array of keys, places options under an alternative heading when displaying usage instructions */
|
||||
group(key: string | ReadonlyArray<string>, groupName: string): Argv<T>;
|
||||
|
||||
/** Hides a key from the generated usage information. Unless a `--show-hidden` option is also passed with `--help` (see `showHidden()`). */
|
||||
hide(key: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Configure an (e.g. `--help`) and implicit command that displays the usage string and exits the process.
|
||||
* By default yargs enables help on the `--help` option.
|
||||
*
|
||||
* Note that any multi-char aliases (e.g. `help`) used for the help option will also be used for the implicit command.
|
||||
* If there are no multi-char aliases (e.g. `h`), then all single-char aliases will be used for the command.
|
||||
*
|
||||
* If invoked without parameters, `.help()` will use `--help` as the option and help as the implicit command to trigger help output.
|
||||
*
|
||||
* @param [description] Customizes the description of the help option in the usage string.
|
||||
* @param [enableExplicit] If `false` is provided, it will disable --help.
|
||||
*/
|
||||
help(): Argv<T>;
|
||||
help(enableExplicit: boolean): Argv<T>;
|
||||
help(option: string, enableExplicit: boolean): Argv<T>;
|
||||
help(option: string, description?: string, enableExplicit?: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* Given the key `x` is set, it is required that the key `y` is set.
|
||||
* y` can either be the name of an argument to imply, a number indicating the position of an argument or an array of multiple implications to associate with `x`.
|
||||
*
|
||||
* Optionally `.implies()` can accept an object specifying multiple implications.
|
||||
*/
|
||||
implies(key: string, value: string | ReadonlyArray<string>): Argv<T>;
|
||||
implies(implies: { [key: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||
|
||||
/**
|
||||
* Return the locale that yargs is currently using.
|
||||
*
|
||||
* By default, yargs will auto-detect the operating system's locale so that yargs-generated help content will display in the user's language.
|
||||
*/
|
||||
locale(): string;
|
||||
/**
|
||||
* Override the auto-detected locale from the user's operating system with a static locale.
|
||||
* Note that the OS locale can be modified by setting/exporting the `LC_ALL` environment variable.
|
||||
*/
|
||||
locale(loc: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Define global middleware functions to be called first, in list order, for all cli command.
|
||||
* @param callbacks Can be a function or a list of functions. Each callback gets passed a reference to argv.
|
||||
* @param [applyBeforeValidation] Set to `true` to apply middleware before validation. This will execute the middleware prior to validation checks, but after parsing.
|
||||
*/
|
||||
middleware(callbacks: MiddlewareFunction<T> | ReadonlyArray<MiddlewareFunction<T>>, applyBeforeValidation?: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* The number of arguments that should be consumed after a key. This can be a useful hint to prevent parsing ambiguity.
|
||||
*
|
||||
* Optionally `.nargs()` can take an object of `key`/`narg` pairs.
|
||||
*/
|
||||
nargs(key: string, count: number): Argv<T>;
|
||||
nargs(nargs: { [key: string]: number }): Argv<T>;
|
||||
|
||||
/** The key provided represents a path and should have `path.normalize()` applied. */
|
||||
normalize<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToString<T[key]> }>;
|
||||
normalize<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: string | undefined }>;
|
||||
|
||||
/**
|
||||
* Tell the parser to always interpret key as a number.
|
||||
*
|
||||
* If `key` is an array, all elements will be parsed as numbers.
|
||||
*
|
||||
* If the option is given on the command line without a value, `argv` will be populated with `undefined`.
|
||||
*
|
||||
* If the value given on the command line cannot be parsed as a number, `argv` will be populated with `NaN`.
|
||||
*
|
||||
* Note that decimals, hexadecimals, and scientific notation are all accepted.
|
||||
*/
|
||||
number<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToNumber<T[key]> }>;
|
||||
number<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: number | undefined }>;
|
||||
|
||||
/**
|
||||
* Method to execute when a command finishes successfully.
|
||||
* @param func Is called with the successful result of the command that finished.
|
||||
*/
|
||||
onFinishCommand(func: (result: any) => void): Argv<T>;
|
||||
|
||||
/**
|
||||
* This method can be used to make yargs aware of options that could exist.
|
||||
* You can also pass an opt object which can hold further customization, like `.alias()`, `.demandOption()` etc. for that option.
|
||||
*/
|
||||
option<K extends keyof T, O extends Options>(key: K, options: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||
option<K extends string, O extends Options>(key: K, options: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||
option<O extends { [key: string]: Options }>(options: O): Argv<Omit<T, keyof O> & InferredOptionTypes<O>>;
|
||||
|
||||
/**
|
||||
* This method can be used to make yargs aware of options that could exist.
|
||||
* You can also pass an opt object which can hold further customization, like `.alias()`, `.demandOption()` etc. for that option.
|
||||
*/
|
||||
options<K extends keyof T, O extends Options>(key: K, options: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||
options<K extends string, O extends Options>(key: K, options: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||
options<O extends { [key: string]: Options }>(options: O): Argv<Omit<T, keyof O> & InferredOptionTypes<O>>;
|
||||
|
||||
/**
|
||||
* Parse `args` instead of `process.argv`. Returns the `argv` object. `args` may either be a pre-processed argv array, or a raw argument string.
|
||||
*
|
||||
* Note: Providing a callback to parse() disables the `exitProcess` setting until after the callback is invoked.
|
||||
* @param [context] Provides a useful mechanism for passing state information to commands
|
||||
*/
|
||||
parse(): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
parse(arg: string | ReadonlyArray<string>, context?: object, parseCallback?: ParseCallback<T>): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
|
||||
/**
|
||||
* If the arguments have not been parsed, this property is `false`.
|
||||
*
|
||||
* If the arguments have been parsed, this contain detailed parsed arguments.
|
||||
*/
|
||||
parsed: DetailedArguments | false;
|
||||
|
||||
/** Allows to configure advanced yargs features. */
|
||||
parserConfiguration(configuration: Partial<ParserConfigurationOptions>): Argv<T>;
|
||||
|
||||
/**
|
||||
* Similar to `config()`, indicates that yargs should interpret the object from the specified key in package.json as a configuration object.
|
||||
* @param [cwd] If provided, the package.json will be read from this location
|
||||
*/
|
||||
pkgConf(key: string | ReadonlyArray<string>, cwd?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Allows you to configure a command's positional arguments with an API similar to `.option()`.
|
||||
* `.positional()` should be called in a command's builder function, and is not available on the top-level yargs instance. If so, it will throw an error.
|
||||
*/
|
||||
positional<K extends keyof T, O extends PositionalOptions>(key: K, opt: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||
positional<K extends string, O extends PositionalOptions>(key: K, opt: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||
|
||||
/** Should yargs provide suggestions regarding similar commands if no matching command is found? */
|
||||
recommendCommands(): Argv<T>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.demandCommand()' or '.demandOption()' instead
|
||||
*/
|
||||
require<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
require(key: string, msg: string): Argv<T>;
|
||||
require(key: string, required: boolean): Argv<T>;
|
||||
require(keys: ReadonlyArray<number>, msg: string): Argv<T>;
|
||||
require(keys: ReadonlyArray<number>, required: boolean): Argv<T>;
|
||||
require(positionals: number, required: boolean): Argv<T>;
|
||||
require(positionals: number, msg: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.demandCommand()' or '.demandOption()' instead
|
||||
*/
|
||||
required<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
required(key: string, msg: string): Argv<T>;
|
||||
required(key: string, required: boolean): Argv<T>;
|
||||
required(keys: ReadonlyArray<number>, msg: string): Argv<T>;
|
||||
required(keys: ReadonlyArray<number>, required: boolean): Argv<T>;
|
||||
required(positionals: number, required: boolean): Argv<T>;
|
||||
required(positionals: number, msg: string): Argv<T>;
|
||||
|
||||
requiresArg(key: string | ReadonlyArray<string>): Argv<T>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.global()' instead
|
||||
*/
|
||||
reset(): Argv<T>;
|
||||
|
||||
/** Set the name of your script ($0). Default is the base filename executed by node (`process.argv[1]`) */
|
||||
scriptName($0: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Generate a bash completion script.
|
||||
* Users of your application can install this script in their `.bashrc`, and yargs will provide completion shortcuts for commands and options.
|
||||
*/
|
||||
showCompletionScript(): Argv<T>;
|
||||
|
||||
/**
|
||||
* Configure the `--show-hidden` option that displays the hidden keys (see `hide()`).
|
||||
* @param option If `boolean`, it enables/disables this option altogether. i.e. hidden keys will be permanently hidden if first argument is `false`.
|
||||
* If `string` it changes the key name ("--show-hidden").
|
||||
* @param description Changes the default description ("Show hidden options")
|
||||
*/
|
||||
showHidden(option?: string | boolean): Argv<T>;
|
||||
showHidden(option: string, description?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Print the usage data using the console function consoleLevel for printing.
|
||||
* @param [consoleLevel='error']
|
||||
*/
|
||||
showHelp(consoleLevel?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Provide the usage data as a string.
|
||||
* @param printCallback a function with a single argument.
|
||||
*/
|
||||
showHelp(printCallback: (s: string) => void): Argv<T>;
|
||||
|
||||
/**
|
||||
* By default, yargs outputs a usage string if any error is detected.
|
||||
* Use the `.showHelpOnFail()` method to customize this behavior.
|
||||
* @param enable If `false`, the usage string is not output.
|
||||
* @param [message] Message that is output after the error message.
|
||||
*/
|
||||
showHelpOnFail(enable: boolean, message?: string): Argv<T>;
|
||||
|
||||
/** Specifies either a single option key (string), or an array of options. If any of the options is present, yargs validation is skipped. */
|
||||
skipValidation(key: string | ReadonlyArray<string>): Argv<T>;
|
||||
|
||||
/**
|
||||
* Any command-line argument given that is not demanded, or does not have a corresponding description, will be reported as an error.
|
||||
*
|
||||
* Unrecognized commands will also be reported as errors.
|
||||
*/
|
||||
strict(): Argv<T>;
|
||||
strict(enabled: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* Similar to .strict(), except that it only applies to unrecognized commands.
|
||||
* A user can still provide arbitrary options, but unknown positional commands
|
||||
* will raise an error.
|
||||
*/
|
||||
strictCommands(): Argv<T>;
|
||||
strictCommands(enabled: boolean): Argv<T>;
|
||||
|
||||
/**
|
||||
* Tell the parser logic not to interpret `key` as a number or boolean. This can be useful if you need to preserve leading zeros in an input.
|
||||
*
|
||||
* If `key` is an array, interpret all the elements as strings.
|
||||
*
|
||||
* `.string('_')` will result in non-hyphenated arguments being interpreted as strings, regardless of whether they resemble numbers.
|
||||
*/
|
||||
string<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToString<T[key]> }>;
|
||||
string<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: string | undefined }>;
|
||||
|
||||
// Intended to be used with '.wrap()'
|
||||
terminalWidth(): number;
|
||||
|
||||
updateLocale(obj: { [key: string]: string }): Argv<T>;
|
||||
|
||||
/**
|
||||
* Override the default strings used by yargs with the key/value pairs provided in obj
|
||||
*
|
||||
* If you explicitly specify a locale(), you should do so before calling `updateStrings()`.
|
||||
*/
|
||||
updateStrings(obj: { [key: string]: string }): Argv<T>;
|
||||
|
||||
/**
|
||||
* Set a usage message to show which commands to use.
|
||||
* Inside `message`, the string `$0` will get interpolated to the current script name or node command for the present script similar to how `$0` works in bash or perl.
|
||||
*
|
||||
* If the optional `description`/`builder`/`handler` are provided, `.usage()` acts an an alias for `.command()`.
|
||||
* This allows you to use `.usage()` to configure the default command that will be run as an entry-point to your application
|
||||
* and allows you to provide configuration for the positional arguments accepted by your program:
|
||||
*/
|
||||
usage(message: string): Argv<T>;
|
||||
usage<U>(command: string | ReadonlyArray<string>, description: string, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||
usage<U>(command: string | ReadonlyArray<string>, showInHelp: boolean, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||
usage<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, description: string, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||
usage<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, showInHelp: boolean, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||
|
||||
/**
|
||||
* Add an option (e.g. `--version`) that displays the version number (given by the version parameter) and exits the process.
|
||||
* By default yargs enables version for the `--version` option.
|
||||
*
|
||||
* If no arguments are passed to version (`.version()`), yargs will parse the package.json of your module and use its version value.
|
||||
*
|
||||
* If the boolean argument `false` is provided, it will disable `--version`.
|
||||
*/
|
||||
version(): Argv<T>;
|
||||
version(version: string): Argv<T>;
|
||||
version(enable: boolean): Argv<T>;
|
||||
version(optionKey: string, version: string): Argv<T>;
|
||||
version(optionKey: string, description: string, version: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* Format usage output to wrap at columns many columns.
|
||||
*
|
||||
* By default wrap will be set to `Math.min(80, windowWidth)`. Use `.wrap(null)` to specify no column limit (no right-align).
|
||||
* Use `.wrap(yargs.terminalWidth())` to maximize the width of yargs' usage instructions.
|
||||
*/
|
||||
wrap(columns: number | null): Argv<T>;
|
||||
}
|
||||
|
||||
type Arguments<T = {}> = T & {
|
||||
/** Non-option arguments */
|
||||
_: Array<string | number>;
|
||||
/** The script name or node command */
|
||||
$0: string;
|
||||
/** All remaining options */
|
||||
[argName: string]: unknown;
|
||||
};
|
||||
|
||||
interface RequireDirectoryOptions {
|
||||
/** Look for command modules in all subdirectories and apply them as a flattened (non-hierarchical) list. */
|
||||
recurse?: boolean | undefined;
|
||||
/** The types of files to look for when requiring command modules. */
|
||||
extensions?: ReadonlyArray<string> | undefined;
|
||||
/**
|
||||
* A synchronous function called for each command module encountered.
|
||||
* Accepts `commandObject`, `pathToFile`, and `filename` as arguments.
|
||||
* Returns `commandObject` to include the command; any falsy value to exclude/skip it.
|
||||
*/
|
||||
visit?: ((commandObject: any, pathToFile?: string, filename?: string) => any) | undefined;
|
||||
/** Whitelist certain modules */
|
||||
include?: RegExp | ((pathToFile: string) => boolean) | undefined;
|
||||
/** Blacklist certain modules. */
|
||||
exclude?: RegExp | ((pathToFile: string) => boolean) | undefined;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/** string or array of strings, alias(es) for the canonical option key, see `alias()` */
|
||||
alias?: string | ReadonlyArray<string> | undefined;
|
||||
/** boolean, interpret option as an array, see `array()` */
|
||||
array?: boolean | undefined;
|
||||
/** boolean, interpret option as a boolean flag, see `boolean()` */
|
||||
boolean?: boolean | undefined;
|
||||
/** value or array of values, limit valid option arguments to a predefined set, see `choices()` */
|
||||
choices?: Choices | undefined;
|
||||
/** function, coerce or transform parsed command line values into another value, see `coerce()` */
|
||||
coerce?: ((arg: any) => any) | undefined;
|
||||
/** boolean, interpret option as a path to a JSON config file, see `config()` */
|
||||
config?: boolean | undefined;
|
||||
/** function, provide a custom config parsing function, see `config()` */
|
||||
configParser?: ((configPath: string) => object) | undefined;
|
||||
/** string or object, require certain keys not to be set, see `conflicts()` */
|
||||
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> } | undefined;
|
||||
/** boolean, interpret option as a count of boolean flags, see `count()` */
|
||||
count?: boolean | undefined;
|
||||
/** value, set a default value for the option, see `default()` */
|
||||
default?: any;
|
||||
/** string, use this description for the default value in help content, see `default()` */
|
||||
defaultDescription?: string | undefined;
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use 'demandOption' instead
|
||||
*/
|
||||
demand?: boolean | string | undefined;
|
||||
/** boolean or string, mark the argument as deprecated, see `deprecateOption()` */
|
||||
deprecate?: boolean | string | undefined;
|
||||
/** boolean or string, mark the argument as deprecated, see `deprecateOption()` */
|
||||
deprecated?: boolean | string | undefined;
|
||||
/** boolean or string, demand the option be given, with optional error message, see `demandOption()` */
|
||||
demandOption?: boolean | string | undefined;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
desc?: string | undefined;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
describe?: string | undefined;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
description?: string | undefined;
|
||||
/** boolean, indicate that this key should not be reset when a command is invoked, see `global()` */
|
||||
global?: boolean | undefined;
|
||||
/** string, when displaying usage instructions place the option under an alternative group heading, see `group()` */
|
||||
group?: string | undefined;
|
||||
/** don't display option in help output. */
|
||||
hidden?: boolean | undefined;
|
||||
/** string or object, require certain keys to be set, see `implies()` */
|
||||
implies?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> } | undefined;
|
||||
/** number, specify how many arguments should be consumed for the option, see `nargs()` */
|
||||
nargs?: number | undefined;
|
||||
/** boolean, apply path.normalize() to the option, see `normalize()` */
|
||||
normalize?: boolean | undefined;
|
||||
/** boolean, interpret option as a number, `number()` */
|
||||
number?: boolean | undefined;
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use 'demandOption' instead
|
||||
*/
|
||||
require?: boolean | string | undefined;
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use 'demandOption' instead
|
||||
*/
|
||||
required?: boolean | string | undefined;
|
||||
/** boolean, require the option be specified with a value, see `requiresArg()` */
|
||||
requiresArg?: boolean | undefined;
|
||||
/** boolean, skips validation if the option is present, see `skipValidation()` */
|
||||
skipValidation?: boolean | undefined;
|
||||
/** boolean, interpret option as a string, see `string()` */
|
||||
string?: boolean | undefined;
|
||||
type?: "array" | "count" | PositionalOptionsType | undefined;
|
||||
}
|
||||
|
||||
interface PositionalOptions {
|
||||
/** string or array of strings, see `alias()` */
|
||||
alias?: string | ReadonlyArray<string> | undefined;
|
||||
/** boolean, interpret option as an array, see `array()` */
|
||||
array?: boolean | undefined;
|
||||
/** value or array of values, limit valid option arguments to a predefined set, see `choices()` */
|
||||
choices?: Choices | undefined;
|
||||
/** function, coerce or transform parsed command line values into another value, see `coerce()` */
|
||||
coerce?: ((arg: any) => any) | undefined;
|
||||
/** string or object, require certain keys not to be set, see `conflicts()` */
|
||||
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> } | undefined;
|
||||
/** value, set a default value for the option, see `default()` */
|
||||
default?: any;
|
||||
/** boolean or string, demand the option be given, with optional error message, see `demandOption()` */
|
||||
demandOption?: boolean | string | undefined;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
desc?: string | undefined;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
describe?: string | undefined;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
description?: string | undefined;
|
||||
/** string or object, require certain keys to be set, see `implies()` */
|
||||
implies?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> } | undefined;
|
||||
/** boolean, apply path.normalize() to the option, see normalize() */
|
||||
normalize?: boolean | undefined;
|
||||
type?: PositionalOptionsType | undefined;
|
||||
}
|
||||
|
||||
/** Remove keys K in T */
|
||||
type Omit<T, K> = { [key in Exclude<keyof T, K>]: T[key] };
|
||||
|
||||
/** Remove undefined as a possible value for keys K in T */
|
||||
type Defined<T, K extends keyof T> = Omit<T, K> & { [key in K]: Exclude<T[key], undefined> };
|
||||
|
||||
/** Convert T to T[] and T | undefined to T[] | undefined */
|
||||
type ToArray<T> = Array<Exclude<T, undefined>> | Extract<T, undefined>;
|
||||
|
||||
/** Gives string[] if T is an array type, otherwise string. Preserves | undefined. */
|
||||
type ToString<T> = (Exclude<T, undefined> extends any[] ? string[] : string) | Extract<T, undefined>;
|
||||
|
||||
/** Gives number[] if T is an array type, otherwise number. Preserves | undefined. */
|
||||
type ToNumber<T> = (Exclude<T, undefined> extends any[] ? number[] : number) | Extract<T, undefined>;
|
||||
|
||||
type InferredOptionType<O extends Options | PositionalOptions> =
|
||||
O extends { default: any, coerce: (arg: any) => infer T } ? T :
|
||||
O extends { default: infer D } ? D :
|
||||
O extends { type: "count" } ? number :
|
||||
O extends { count: true } ? number :
|
||||
O extends { required: string | true } ? RequiredOptionType<O> :
|
||||
O extends { require: string | true } ? RequiredOptionType<O> :
|
||||
O extends { demand: string | true } ? RequiredOptionType<O> :
|
||||
O extends { demandOption: string | true } ? RequiredOptionType<O> :
|
||||
RequiredOptionType<O> | undefined;
|
||||
|
||||
type RequiredOptionType<O extends Options | PositionalOptions> =
|
||||
O extends { type: "array", string: true } ? string[] :
|
||||
O extends { type: "array", number: true } ? number[] :
|
||||
O extends { type: "array", normalize: true } ? string[] :
|
||||
O extends { type: "string", array: true } ? string[] :
|
||||
O extends { type: "number", array: true } ? number[] :
|
||||
O extends { string: true, array: true } ? string[] :
|
||||
O extends { number: true, array: true } ? number[] :
|
||||
O extends { normalize: true, array: true } ? string[] :
|
||||
O extends { type: "array" } ? Array<string | number> :
|
||||
O extends { type: "boolean" } ? boolean :
|
||||
O extends { type: "number" } ? number :
|
||||
O extends { type: "string" } ? string :
|
||||
O extends { array: true } ? Array<string | number> :
|
||||
O extends { boolean: true } ? boolean :
|
||||
O extends { number: true } ? number :
|
||||
O extends { string: true } ? string :
|
||||
O extends { normalize: true } ? string :
|
||||
O extends { choices: ReadonlyArray<infer C> } ? C :
|
||||
O extends { coerce: (arg: any) => infer T } ? T :
|
||||
unknown;
|
||||
|
||||
type InferredOptionTypes<O extends { [key: string]: Options }> = { [key in keyof O]: InferredOptionType<O[key]> };
|
||||
|
||||
interface CommandModule<T = {}, U = {}> {
|
||||
/** array of strings (or a single string) representing aliases of `exports.command`, positional args defined in an alias are ignored */
|
||||
aliases?: ReadonlyArray<string> | string | undefined;
|
||||
/** object declaring the options the command accepts, or a function accepting and returning a yargs instance */
|
||||
builder?: CommandBuilder<T, U> | undefined;
|
||||
/** string (or array of strings) that executes this command when given on the command line, first string may contain positional args */
|
||||
command?: ReadonlyArray<string> | string | undefined;
|
||||
/** boolean (or string) to show deprecation notice */
|
||||
deprecated?: boolean | string | undefined;
|
||||
/** string used as the description for the command in help text, use `false` for a hidden command */
|
||||
describe?: string | false | undefined;
|
||||
/** a function which will be passed the parsed argv. */
|
||||
handler: (args: Arguments<U>) => void;
|
||||
}
|
||||
|
||||
type ParseCallback<T = {}> = (err: Error | undefined, argv: Arguments<T>, output: string) => void;
|
||||
type CommandBuilder<T = {}, U = {}> = { [key: string]: Options } | ((args: Argv<T>) => Argv<U>) | ((args: Argv<T>) => PromiseLike<Argv<U>>);
|
||||
type SyncCompletionFunction = (current: string, argv: any) => string[];
|
||||
type AsyncCompletionFunction = (current: string, argv: any, done: (completion: ReadonlyArray<string>) => void) => void;
|
||||
type PromiseCompletionFunction = (current: string, argv: any) => Promise<string[]>;
|
||||
type MiddlewareFunction<T = {}> = (args: Arguments<T>) => void;
|
||||
type Choices = ReadonlyArray<string | number | true | undefined>;
|
||||
type PositionalOptionsType = "boolean" | "number" | "string";
|
||||
}
|
||||
|
||||
declare var yargs: yargs.Argv;
|
||||
export = yargs;
|
62
web/node_modules/jest-diff/node_modules/@types/yargs/package.json
generated
vendored
Executable file
62
web/node_modules/jest-diff/node_modules/@types/yargs/package.json
generated
vendored
Executable file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"name": "@types/yargs",
|
||||
"version": "15.0.14",
|
||||
"description": "TypeScript definitions for yargs",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Martin Poelstra",
|
||||
"url": "https://github.com/poelstra",
|
||||
"githubUsername": "poelstra"
|
||||
},
|
||||
{
|
||||
"name": "Mizunashi Mana",
|
||||
"url": "https://github.com/mizunashi-mana",
|
||||
"githubUsername": "mizunashi-mana"
|
||||
},
|
||||
{
|
||||
"name": "Jeffery Grajkowski",
|
||||
"url": "https://github.com/pushplay",
|
||||
"githubUsername": "pushplay"
|
||||
},
|
||||
{
|
||||
"name": "Jimi (Dimitris) Charalampidis",
|
||||
"url": "https://github.com/JimiC",
|
||||
"githubUsername": "JimiC"
|
||||
},
|
||||
{
|
||||
"name": "Steffen Viken Valvåg",
|
||||
"url": "https://github.com/steffenvv",
|
||||
"githubUsername": "steffenvv"
|
||||
},
|
||||
{
|
||||
"name": "Emily Marigold Klassen",
|
||||
"url": "https://github.com/forivall",
|
||||
"githubUsername": "forivall"
|
||||
},
|
||||
{
|
||||
"name": "ExE Boss",
|
||||
"url": "https://github.com/ExE-Boss",
|
||||
"githubUsername": "ExE-Boss"
|
||||
},
|
||||
{
|
||||
"name": "Aankhen",
|
||||
"url": "https://github.com/Aankhen",
|
||||
"githubUsername": "Aankhen"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/yargs"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@types/yargs-parser": "*"
|
||||
},
|
||||
"typesPublisherContentHash": "08f18db584d12815700691202627482987b3f369093c020e1539deee222b2a09",
|
||||
"typeScriptVersion": "3.6"
|
||||
}
|
9
web/node_modules/jest-diff/node_modules/@types/yargs/yargs.d.ts
generated
vendored
Executable file
9
web/node_modules/jest-diff/node_modules/@types/yargs/yargs.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,9 @@
|
|||
import { Argv } from '.';
|
||||
|
||||
export = Yargs;
|
||||
|
||||
declare function Yargs(
|
||||
processArgs?: ReadonlyArray<string>,
|
||||
cwd?: string,
|
||||
parentRequire?: NodeRequire,
|
||||
): Argv;
|
21
web/node_modules/jest-diff/node_modules/pretty-format/LICENSE
generated
vendored
Normal file
21
web/node_modules/jest-diff/node_modules/pretty-format/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
454
web/node_modules/jest-diff/node_modules/pretty-format/README.md
generated
vendored
Executable file
454
web/node_modules/jest-diff/node_modules/pretty-format/README.md
generated
vendored
Executable file
|
@ -0,0 +1,454 @@
|
|||
# pretty-format
|
||||
|
||||
Stringify any JavaScript value.
|
||||
|
||||
- Serialize built-in JavaScript types.
|
||||
- Serialize application-specific data types with built-in or user-defined plugins.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ yarn add pretty-format
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const prettyFormat = require('pretty-format'); // CommonJS
|
||||
```
|
||||
|
||||
```js
|
||||
import prettyFormat from 'pretty-format'; // ES2015 modules
|
||||
```
|
||||
|
||||
```js
|
||||
const val = {object: {}};
|
||||
val.circularReference = val;
|
||||
val[Symbol('foo')] = 'foo';
|
||||
val.map = new Map([['prop', 'value']]);
|
||||
val.array = [-0, Infinity, NaN];
|
||||
|
||||
console.log(prettyFormat(val));
|
||||
/*
|
||||
Object {
|
||||
"array": Array [
|
||||
-0,
|
||||
Infinity,
|
||||
NaN,
|
||||
],
|
||||
"circularReference": [Circular],
|
||||
"map": Map {
|
||||
"prop" => "value",
|
||||
},
|
||||
"object": Object {},
|
||||
Symbol(foo): "foo",
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
## Usage with options
|
||||
|
||||
```js
|
||||
function onClick() {}
|
||||
|
||||
console.log(prettyFormat(onClick));
|
||||
/*
|
||||
[Function onClick]
|
||||
*/
|
||||
|
||||
const options = {
|
||||
printFunctionName: false,
|
||||
};
|
||||
console.log(prettyFormat(onClick, options));
|
||||
/*
|
||||
[Function]
|
||||
*/
|
||||
```
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
| key | type | default | description |
|
||||
| :------------------ | :-------- | :--------- | :------------------------------------------------------ |
|
||||
| `callToJSON` | `boolean` | `true` | call `toJSON` method (if it exists) on objects |
|
||||
| `escapeRegex` | `boolean` | `false` | escape special characters in regular expressions |
|
||||
| `escapeString` | `boolean` | `true` | escape special characters in strings |
|
||||
| `highlight` | `boolean` | `false` | highlight syntax with colors in terminal (some plugins) |
|
||||
| `indent` | `number` | `2` | spaces in each level of indentation |
|
||||
| `maxDepth` | `number` | `Infinity` | levels to print in arrays, objects, elements, and so on |
|
||||
| `min` | `boolean` | `false` | minimize added space: no indentation nor line breaks |
|
||||
| `plugins` | `array` | `[]` | plugins to serialize application-specific data types |
|
||||
| `printFunctionName` | `boolean` | `true` | include or omit the name of a function |
|
||||
| `theme` | `object` | | colors to highlight syntax in terminal |
|
||||
|
||||
Property values of `theme` are from [ansi-styles colors](https://github.com/chalk/ansi-styles#colors)
|
||||
|
||||
```js
|
||||
const DEFAULT_THEME = {
|
||||
comment: 'gray',
|
||||
content: 'reset',
|
||||
prop: 'yellow',
|
||||
tag: 'cyan',
|
||||
value: 'green',
|
||||
};
|
||||
```
|
||||
|
||||
## Usage with plugins
|
||||
|
||||
The `pretty-format` package provides some built-in plugins, including:
|
||||
|
||||
- `ReactElement` for elements from `react`
|
||||
- `ReactTestComponent` for test objects from `react-test-renderer`
|
||||
|
||||
```js
|
||||
// CommonJS
|
||||
const React = require('react');
|
||||
const renderer = require('react-test-renderer');
|
||||
const prettyFormat = require('pretty-format');
|
||||
const ReactElement = prettyFormat.plugins.ReactElement;
|
||||
const ReactTestComponent = prettyFormat.plugins.ReactTestComponent;
|
||||
```
|
||||
|
||||
```js
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
// ES2015 modules and destructuring assignment
|
||||
import prettyFormat from 'pretty-format';
|
||||
const {ReactElement, ReactTestComponent} = prettyFormat.plugins;
|
||||
```
|
||||
|
||||
```js
|
||||
const onClick = () => {};
|
||||
const element = React.createElement('button', {onClick}, 'Hello World');
|
||||
|
||||
const formatted1 = prettyFormat(element, {
|
||||
plugins: [ReactElement],
|
||||
printFunctionName: false,
|
||||
});
|
||||
const formatted2 = prettyFormat(renderer.create(element).toJSON(), {
|
||||
plugins: [ReactTestComponent],
|
||||
printFunctionName: false,
|
||||
});
|
||||
/*
|
||||
<button
|
||||
onClick=[Function]
|
||||
>
|
||||
Hello World
|
||||
</button>
|
||||
*/
|
||||
```
|
||||
|
||||
## Usage in Jest
|
||||
|
||||
For snapshot tests, Jest uses `pretty-format` with options that include some of its built-in plugins. For this purpose, plugins are also known as **snapshot serializers**.
|
||||
|
||||
To serialize application-specific data types, you can add modules to `devDependencies` of a project, and then:
|
||||
|
||||
In an **individual** test file, you can add a module as follows. It precedes any modules from Jest configuration.
|
||||
|
||||
```js
|
||||
import serializer from 'my-serializer-module';
|
||||
expect.addSnapshotSerializer(serializer);
|
||||
|
||||
// tests which have `expect(value).toMatchSnapshot()` assertions
|
||||
```
|
||||
|
||||
For **all** test files, you can specify modules in Jest configuration. They precede built-in plugins for React, HTML, and Immutable.js data types. For example, in a `package.json` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"jest": {
|
||||
"snapshotSerializers": ["my-serializer-module"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Writing plugins
|
||||
|
||||
A plugin is a JavaScript object.
|
||||
|
||||
If `options` has a `plugins` array: for the first plugin whose `test(val)` method returns a truthy value, then `prettyFormat(val, options)` returns the result from either:
|
||||
|
||||
- `serialize(val, …)` method of the **improved** interface (available in **version 21** or later)
|
||||
- `print(val, …)` method of the **original** interface (if plugin does not have `serialize` method)
|
||||
|
||||
### test
|
||||
|
||||
Write `test` so it can receive `val` argument of any type. To serialize **objects** which have certain properties, then a guarded expression like `val != null && …` or more concise `val && …` prevents the following errors:
|
||||
|
||||
- `TypeError: Cannot read property 'whatever' of null`
|
||||
- `TypeError: Cannot read property 'whatever' of undefined`
|
||||
|
||||
For example, `test` method of built-in `ReactElement` plugin:
|
||||
|
||||
```js
|
||||
const elementSymbol = Symbol.for('react.element');
|
||||
const test = val => val && val.$$typeof === elementSymbol;
|
||||
```
|
||||
|
||||
Pay attention to efficiency in `test` because `pretty-format` calls it often.
|
||||
|
||||
### serialize
|
||||
|
||||
The **improved** interface is available in **version 21** or later.
|
||||
|
||||
Write `serialize` to return a string, given the arguments:
|
||||
|
||||
- `val` which “passed the test”
|
||||
- unchanging `config` object: derived from `options`
|
||||
- current `indentation` string: concatenate to `indent` from `config`
|
||||
- current `depth` number: compare to `maxDepth` from `config`
|
||||
- current `refs` array: find circular references in objects
|
||||
- `printer` callback function: serialize children
|
||||
|
||||
### config
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
| key | type | description |
|
||||
| :------------------ | :-------- | :------------------------------------------------------ |
|
||||
| `callToJSON` | `boolean` | call `toJSON` method (if it exists) on objects |
|
||||
| `colors` | `Object` | escape codes for colors to highlight syntax |
|
||||
| `escapeRegex` | `boolean` | escape special characters in regular expressions |
|
||||
| `escapeString` | `boolean` | escape special characters in strings |
|
||||
| `indent` | `string` | spaces in each level of indentation |
|
||||
| `maxDepth` | `number` | levels to print in arrays, objects, elements, and so on |
|
||||
| `min` | `boolean` | minimize added space: no indentation nor line breaks |
|
||||
| `plugins` | `array` | plugins to serialize application-specific data types |
|
||||
| `printFunctionName` | `boolean` | include or omit the name of a function |
|
||||
| `spacingInner` | `strong` | spacing to separate items in a list |
|
||||
| `spacingOuter` | `strong` | spacing to enclose a list of items |
|
||||
|
||||
Each property of `colors` in `config` corresponds to a property of `theme` in `options`:
|
||||
|
||||
- the key is the same (for example, `tag`)
|
||||
- the value in `colors` is a object with `open` and `close` properties whose values are escape codes from [ansi-styles](https://github.com/chalk/ansi-styles) for the color value in `theme` (for example, `'cyan'`)
|
||||
|
||||
Some properties in `config` are derived from `min` in `options`:
|
||||
|
||||
- `spacingInner` and `spacingOuter` are **newline** if `min` is `false`
|
||||
- `spacingInner` is **space** and `spacingOuter` is **empty string** if `min` is `true`
|
||||
|
||||
### Example of serialize and test
|
||||
|
||||
This plugin is a pattern you can apply to serialize composite data types. Side note: `pretty-format` does not need a plugin to serialize arrays.
|
||||
|
||||
```js
|
||||
// We reused more code when we factored out a function for child items
|
||||
// that is independent of depth, name, and enclosing punctuation (see below).
|
||||
const SEPARATOR = ',';
|
||||
function serializeItems(items, config, indentation, depth, refs, printer) {
|
||||
if (items.length === 0) {
|
||||
return '';
|
||||
}
|
||||
const indentationItems = indentation + config.indent;
|
||||
return (
|
||||
config.spacingOuter +
|
||||
items
|
||||
.map(
|
||||
item =>
|
||||
indentationItems +
|
||||
printer(item, config, indentationItems, depth, refs), // callback
|
||||
)
|
||||
.join(SEPARATOR + config.spacingInner) +
|
||||
(config.min ? '' : SEPARATOR) + // following the last item
|
||||
config.spacingOuter +
|
||||
indentation
|
||||
);
|
||||
}
|
||||
|
||||
const plugin = {
|
||||
test(val) {
|
||||
return Array.isArray(val);
|
||||
},
|
||||
serialize(array, config, indentation, depth, refs, printer) {
|
||||
const name = array.constructor.name;
|
||||
return ++depth > config.maxDepth
|
||||
? '[' + name + ']'
|
||||
: (config.min ? '' : name + ' ') +
|
||||
'[' +
|
||||
serializeItems(array, config, indentation, depth, refs, printer) +
|
||||
']';
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
const val = {
|
||||
filter: 'completed',
|
||||
items: [
|
||||
{
|
||||
text: 'Write test',
|
||||
completed: true,
|
||||
},
|
||||
{
|
||||
text: 'Write serialize',
|
||||
completed: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
Object {
|
||||
"filter": "completed",
|
||||
"items": Array [
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write test",
|
||||
},
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write serialize",
|
||||
},
|
||||
],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
indent: 4,
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
Object {
|
||||
"filter": "completed",
|
||||
"items": Array [
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write test",
|
||||
},
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write serialize",
|
||||
},
|
||||
],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
maxDepth: 1,
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
Object {
|
||||
"filter": "completed",
|
||||
"items": [Array],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
min: true,
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
{"filter": "completed", "items": [{"completed": true, "text": "Write test"}, {"completed": true, "text": "Write serialize"}]}
|
||||
*/
|
||||
```
|
||||
|
||||
### print
|
||||
|
||||
The **original** interface is adequate for plugins:
|
||||
|
||||
- that **do not** depend on options other than `highlight` or `min`
|
||||
- that **do not** depend on `depth` or `refs` in recursive traversal, and
|
||||
- if values either
|
||||
- do **not** require indentation, or
|
||||
- do **not** occur as children of JavaScript data structures (for example, array)
|
||||
|
||||
Write `print` to return a string, given the arguments:
|
||||
|
||||
- `val` which “passed the test”
|
||||
- current `printer(valChild)` callback function: serialize children
|
||||
- current `indenter(lines)` callback function: indent lines at the next level
|
||||
- unchanging `config` object: derived from `options`
|
||||
- unchanging `colors` object: derived from `options`
|
||||
|
||||
The 3 properties of `config` are `min` in `options` and:
|
||||
|
||||
- `spacing` and `edgeSpacing` are **newline** if `min` is `false`
|
||||
- `spacing` is **space** and `edgeSpacing` is **empty string** if `min` is `true`
|
||||
|
||||
Each property of `colors` corresponds to a property of `theme` in `options`:
|
||||
|
||||
- the key is the same (for example, `tag`)
|
||||
- the value in `colors` is a object with `open` and `close` properties whose values are escape codes from [ansi-styles](https://github.com/chalk/ansi-styles) for the color value in `theme` (for example, `'cyan'`)
|
||||
|
||||
### Example of print and test
|
||||
|
||||
This plugin prints functions with the **number of named arguments** excluding rest argument.
|
||||
|
||||
```js
|
||||
const plugin = {
|
||||
print(val) {
|
||||
return `[Function ${val.name || 'anonymous'} ${val.length}]`;
|
||||
},
|
||||
test(val) {
|
||||
return typeof val === 'function';
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
const val = {
|
||||
onClick(event) {},
|
||||
render() {},
|
||||
};
|
||||
|
||||
prettyFormat(val, {
|
||||
plugins: [plugin],
|
||||
});
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function onClick 1],
|
||||
"render": [Function render 0],
|
||||
}
|
||||
*/
|
||||
|
||||
prettyFormat(val);
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function onClick],
|
||||
"render": [Function render],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
This plugin **ignores** the `printFunctionName` option. That limitation of the original `print` interface is a reason to use the improved `serialize` interface, described above.
|
||||
|
||||
```js
|
||||
prettyFormat(val, {
|
||||
plugins: [pluginOld],
|
||||
printFunctionName: false,
|
||||
});
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function onClick 1],
|
||||
"render": [Function render 0],
|
||||
}
|
||||
*/
|
||||
|
||||
prettyFormat(val, {
|
||||
printFunctionName: false,
|
||||
});
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function],
|
||||
"render": [Function],
|
||||
}
|
||||
*/
|
||||
```
|
32
web/node_modules/jest-diff/node_modules/pretty-format/build/collections.d.ts
generated
vendored
Normal file
32
web/node_modules/jest-diff/node_modules/pretty-format/build/collections.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
import type { Config, Printer, Refs } from './types';
|
||||
/**
|
||||
* Return entries (for example, of a map)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
export declare function printIteratorEntries(iterator: Iterator<[unknown, unknown]>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer, separator?: string): string;
|
||||
/**
|
||||
* Return values (for example, of a set)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (braces or brackets)
|
||||
*/
|
||||
export declare function printIteratorValues(iterator: Iterator<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
||||
/**
|
||||
* Return items (for example, of an array)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, brackets)
|
||||
**/
|
||||
export declare function printListItems(list: ArrayLike<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
||||
/**
|
||||
* Return properties of an object
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
export declare function printObjectProperties(val: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
185
web/node_modules/jest-diff/node_modules/pretty-format/build/collections.js
generated
vendored
Normal file
185
web/node_modules/jest-diff/node_modules/pretty-format/build/collections.js
generated
vendored
Normal file
|
@ -0,0 +1,185 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.printIteratorEntries = printIteratorEntries;
|
||||
exports.printIteratorValues = printIteratorValues;
|
||||
exports.printListItems = printListItems;
|
||||
exports.printObjectProperties = printObjectProperties;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
const getKeysOfEnumerableProperties = object => {
|
||||
const keys = Object.keys(object).sort();
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
Object.getOwnPropertySymbols(object).forEach(symbol => {
|
||||
if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
|
||||
keys.push(symbol);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return keys;
|
||||
};
|
||||
/**
|
||||
* Return entries (for example, of a map)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
|
||||
function printIteratorEntries(
|
||||
iterator,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
|
||||
// What a distracting diff if you change a data structure to/from
|
||||
// ECMAScript Object or Immutable.Map/OrderedMap which use the default.
|
||||
separator = ': '
|
||||
) {
|
||||
let result = '';
|
||||
let current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
while (!current.done) {
|
||||
const name = printer(
|
||||
current.value[0],
|
||||
config,
|
||||
indentationNext,
|
||||
depth,
|
||||
refs
|
||||
);
|
||||
const value = printer(
|
||||
current.value[1],
|
||||
config,
|
||||
indentationNext,
|
||||
depth,
|
||||
refs
|
||||
);
|
||||
result += indentationNext + name + separator + value;
|
||||
current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Return values (for example, of a set)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (braces or brackets)
|
||||
*/
|
||||
|
||||
function printIteratorValues(
|
||||
iterator,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) {
|
||||
let result = '';
|
||||
let current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
while (!current.done) {
|
||||
result +=
|
||||
indentationNext +
|
||||
printer(current.value, config, indentationNext, depth, refs);
|
||||
current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Return items (for example, of an array)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, brackets)
|
||||
**/
|
||||
|
||||
function printListItems(list, config, indentation, depth, refs, printer) {
|
||||
let result = '';
|
||||
|
||||
if (list.length) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
result +=
|
||||
indentationNext +
|
||||
printer(list[i], config, indentationNext, depth, refs);
|
||||
|
||||
if (i < list.length - 1) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Return properties of an object
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
|
||||
function printObjectProperties(val, config, indentation, depth, refs, printer) {
|
||||
let result = '';
|
||||
const keys = getKeysOfEnumerableProperties(val);
|
||||
|
||||
if (keys.length) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const name = printer(key, config, indentationNext, depth, refs);
|
||||
const value = printer(val[key], config, indentationNext, depth, refs);
|
||||
result += indentationNext + name + ': ' + value;
|
||||
|
||||
if (i < keys.length - 1) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
37
web/node_modules/jest-diff/node_modules/pretty-format/build/index.d.ts
generated
vendored
Normal file
37
web/node_modules/jest-diff/node_modules/pretty-format/build/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type * as PrettyFormat from './types';
|
||||
/**
|
||||
* Returns a presentation string of your `val` object
|
||||
* @param val any potential JavaScript object
|
||||
* @param options Custom settings
|
||||
*/
|
||||
declare function prettyFormat(val: unknown, options?: PrettyFormat.OptionsReceived): string;
|
||||
declare namespace prettyFormat {
|
||||
var plugins: {
|
||||
AsymmetricMatcher: PrettyFormat.NewPlugin;
|
||||
ConvertAnsi: PrettyFormat.NewPlugin;
|
||||
DOMCollection: PrettyFormat.NewPlugin;
|
||||
DOMElement: PrettyFormat.NewPlugin;
|
||||
Immutable: PrettyFormat.NewPlugin;
|
||||
ReactElement: PrettyFormat.NewPlugin;
|
||||
ReactTestComponent: PrettyFormat.NewPlugin;
|
||||
};
|
||||
}
|
||||
declare namespace prettyFormat {
|
||||
type Colors = PrettyFormat.Colors;
|
||||
type Config = PrettyFormat.Config;
|
||||
type Options = PrettyFormat.Options;
|
||||
type OptionsReceived = PrettyFormat.OptionsReceived;
|
||||
type OldPlugin = PrettyFormat.OldPlugin;
|
||||
type NewPlugin = PrettyFormat.NewPlugin;
|
||||
type Plugin = PrettyFormat.Plugin;
|
||||
type Plugins = PrettyFormat.Plugins;
|
||||
type Refs = PrettyFormat.Refs;
|
||||
type Theme = PrettyFormat.Theme;
|
||||
}
|
||||
export = prettyFormat;
|
560
web/node_modules/jest-diff/node_modules/pretty-format/build/index.js
generated
vendored
Normal file
560
web/node_modules/jest-diff/node_modules/pretty-format/build/index.js
generated
vendored
Normal file
|
@ -0,0 +1,560 @@
|
|||
'use strict';
|
||||
|
||||
var _ansiStyles = _interopRequireDefault(require('ansi-styles'));
|
||||
|
||||
var _collections = require('./collections');
|
||||
|
||||
var _AsymmetricMatcher = _interopRequireDefault(
|
||||
require('./plugins/AsymmetricMatcher')
|
||||
);
|
||||
|
||||
var _ConvertAnsi = _interopRequireDefault(require('./plugins/ConvertAnsi'));
|
||||
|
||||
var _DOMCollection = _interopRequireDefault(require('./plugins/DOMCollection'));
|
||||
|
||||
var _DOMElement = _interopRequireDefault(require('./plugins/DOMElement'));
|
||||
|
||||
var _Immutable = _interopRequireDefault(require('./plugins/Immutable'));
|
||||
|
||||
var _ReactElement = _interopRequireDefault(require('./plugins/ReactElement'));
|
||||
|
||||
var _ReactTestComponent = _interopRequireDefault(
|
||||
require('./plugins/ReactTestComponent')
|
||||
);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* eslint-disable local/ban-types-eventually */
|
||||
const toString = Object.prototype.toString;
|
||||
const toISOString = Date.prototype.toISOString;
|
||||
const errorToString = Error.prototype.toString;
|
||||
const regExpToString = RegExp.prototype.toString;
|
||||
/**
|
||||
* Explicitly comparing typeof constructor to function avoids undefined as name
|
||||
* when mock identity-obj-proxy returns the key as the value for any key.
|
||||
*/
|
||||
|
||||
const getConstructorName = val =>
|
||||
(typeof val.constructor === 'function' && val.constructor.name) || 'Object';
|
||||
/* global window */
|
||||
|
||||
/** Is val is equal to global window object? Works even if it does not exist :) */
|
||||
|
||||
const isWindow = val => typeof window !== 'undefined' && val === window;
|
||||
|
||||
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
||||
const NEWLINE_REGEXP = /\n/gi;
|
||||
|
||||
class PrettyFormatPluginError extends Error {
|
||||
constructor(message, stack) {
|
||||
super(message);
|
||||
this.stack = stack;
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
||||
function isToStringedArrayType(toStringed) {
|
||||
return (
|
||||
toStringed === '[object Array]' ||
|
||||
toStringed === '[object ArrayBuffer]' ||
|
||||
toStringed === '[object DataView]' ||
|
||||
toStringed === '[object Float32Array]' ||
|
||||
toStringed === '[object Float64Array]' ||
|
||||
toStringed === '[object Int8Array]' ||
|
||||
toStringed === '[object Int16Array]' ||
|
||||
toStringed === '[object Int32Array]' ||
|
||||
toStringed === '[object Uint8Array]' ||
|
||||
toStringed === '[object Uint8ClampedArray]' ||
|
||||
toStringed === '[object Uint16Array]' ||
|
||||
toStringed === '[object Uint32Array]'
|
||||
);
|
||||
}
|
||||
|
||||
function printNumber(val) {
|
||||
return Object.is(val, -0) ? '-0' : String(val);
|
||||
}
|
||||
|
||||
function printBigInt(val) {
|
||||
return String(`${val}n`);
|
||||
}
|
||||
|
||||
function printFunction(val, printFunctionName) {
|
||||
if (!printFunctionName) {
|
||||
return '[Function]';
|
||||
}
|
||||
|
||||
return '[Function ' + (val.name || 'anonymous') + ']';
|
||||
}
|
||||
|
||||
function printSymbol(val) {
|
||||
return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
|
||||
}
|
||||
|
||||
function printError(val) {
|
||||
return '[' + errorToString.call(val) + ']';
|
||||
}
|
||||
/**
|
||||
* The first port of call for printing an object, handles most of the
|
||||
* data-types in JS.
|
||||
*/
|
||||
|
||||
function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
||||
if (val === true || val === false) {
|
||||
return '' + val;
|
||||
}
|
||||
|
||||
if (val === undefined) {
|
||||
return 'undefined';
|
||||
}
|
||||
|
||||
if (val === null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
const typeOf = typeof val;
|
||||
|
||||
if (typeOf === 'number') {
|
||||
return printNumber(val);
|
||||
}
|
||||
|
||||
if (typeOf === 'bigint') {
|
||||
return printBigInt(val);
|
||||
}
|
||||
|
||||
if (typeOf === 'string') {
|
||||
if (escapeString) {
|
||||
return '"' + val.replace(/"|\\/g, '\\$&') + '"';
|
||||
}
|
||||
|
||||
return '"' + val + '"';
|
||||
}
|
||||
|
||||
if (typeOf === 'function') {
|
||||
return printFunction(val, printFunctionName);
|
||||
}
|
||||
|
||||
if (typeOf === 'symbol') {
|
||||
return printSymbol(val);
|
||||
}
|
||||
|
||||
const toStringed = toString.call(val);
|
||||
|
||||
if (toStringed === '[object WeakMap]') {
|
||||
return 'WeakMap {}';
|
||||
}
|
||||
|
||||
if (toStringed === '[object WeakSet]') {
|
||||
return 'WeakSet {}';
|
||||
}
|
||||
|
||||
if (
|
||||
toStringed === '[object Function]' ||
|
||||
toStringed === '[object GeneratorFunction]'
|
||||
) {
|
||||
return printFunction(val, printFunctionName);
|
||||
}
|
||||
|
||||
if (toStringed === '[object Symbol]') {
|
||||
return printSymbol(val);
|
||||
}
|
||||
|
||||
if (toStringed === '[object Date]') {
|
||||
return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
|
||||
}
|
||||
|
||||
if (toStringed === '[object Error]') {
|
||||
return printError(val);
|
||||
}
|
||||
|
||||
if (toStringed === '[object RegExp]') {
|
||||
if (escapeRegex) {
|
||||
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js
|
||||
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
}
|
||||
|
||||
return regExpToString.call(val);
|
||||
}
|
||||
|
||||
if (val instanceof Error) {
|
||||
return printError(val);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Handles more complex objects ( such as objects with circular references.
|
||||
* maps and sets etc )
|
||||
*/
|
||||
|
||||
function printComplexValue(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
hasCalledToJSON
|
||||
) {
|
||||
if (refs.indexOf(val) !== -1) {
|
||||
return '[Circular]';
|
||||
}
|
||||
|
||||
refs = refs.slice();
|
||||
refs.push(val);
|
||||
const hitMaxDepth = ++depth > config.maxDepth;
|
||||
const min = config.min;
|
||||
|
||||
if (
|
||||
config.callToJSON &&
|
||||
!hitMaxDepth &&
|
||||
val.toJSON &&
|
||||
typeof val.toJSON === 'function' &&
|
||||
!hasCalledToJSON
|
||||
) {
|
||||
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
||||
}
|
||||
|
||||
const toStringed = toString.call(val);
|
||||
|
||||
if (toStringed === '[object Arguments]') {
|
||||
return hitMaxDepth
|
||||
? '[Arguments]'
|
||||
: (min ? '' : 'Arguments ') +
|
||||
'[' +
|
||||
(0, _collections.printListItems)(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']';
|
||||
}
|
||||
|
||||
if (isToStringedArrayType(toStringed)) {
|
||||
return hitMaxDepth
|
||||
? '[' + val.constructor.name + ']'
|
||||
: (min ? '' : val.constructor.name + ' ') +
|
||||
'[' +
|
||||
(0, _collections.printListItems)(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']';
|
||||
}
|
||||
|
||||
if (toStringed === '[object Map]') {
|
||||
return hitMaxDepth
|
||||
? '[Map]'
|
||||
: 'Map {' +
|
||||
(0, _collections.printIteratorEntries)(
|
||||
val.entries(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
' => '
|
||||
) +
|
||||
'}';
|
||||
}
|
||||
|
||||
if (toStringed === '[object Set]') {
|
||||
return hitMaxDepth
|
||||
? '[Set]'
|
||||
: 'Set {' +
|
||||
(0, _collections.printIteratorValues)(
|
||||
val.values(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}';
|
||||
} // Avoid failure to serialize global window object in jsdom test environment.
|
||||
// For example, not even relevant if window is prop of React element.
|
||||
|
||||
return hitMaxDepth || isWindow(val)
|
||||
? '[' + getConstructorName(val) + ']'
|
||||
: (min ? '' : getConstructorName(val) + ' ') +
|
||||
'{' +
|
||||
(0, _collections.printObjectProperties)(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}';
|
||||
}
|
||||
|
||||
function isNewPlugin(plugin) {
|
||||
return plugin.serialize != null;
|
||||
}
|
||||
|
||||
function printPlugin(plugin, val, config, indentation, depth, refs) {
|
||||
let printed;
|
||||
|
||||
try {
|
||||
printed = isNewPlugin(plugin)
|
||||
? plugin.serialize(val, config, indentation, depth, refs, printer)
|
||||
: plugin.print(
|
||||
val,
|
||||
valChild => printer(valChild, config, indentation, depth, refs),
|
||||
str => {
|
||||
const indentationNext = indentation + config.indent;
|
||||
return (
|
||||
indentationNext +
|
||||
str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
|
||||
);
|
||||
},
|
||||
{
|
||||
edgeSpacing: config.spacingOuter,
|
||||
min: config.min,
|
||||
spacing: config.spacingInner
|
||||
},
|
||||
config.colors
|
||||
);
|
||||
} catch (error) {
|
||||
throw new PrettyFormatPluginError(error.message, error.stack);
|
||||
}
|
||||
|
||||
if (typeof printed !== 'string') {
|
||||
throw new Error(
|
||||
`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
|
||||
);
|
||||
}
|
||||
|
||||
return printed;
|
||||
}
|
||||
|
||||
function findPlugin(plugins, val) {
|
||||
for (let p = 0; p < plugins.length; p++) {
|
||||
try {
|
||||
if (plugins[p].test(val)) {
|
||||
return plugins[p];
|
||||
}
|
||||
} catch (error) {
|
||||
throw new PrettyFormatPluginError(error.message, error.stack);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
||||
const plugin = findPlugin(config.plugins, val);
|
||||
|
||||
if (plugin !== null) {
|
||||
return printPlugin(plugin, val, config, indentation, depth, refs);
|
||||
}
|
||||
|
||||
const basicResult = printBasicValue(
|
||||
val,
|
||||
config.printFunctionName,
|
||||
config.escapeRegex,
|
||||
config.escapeString
|
||||
);
|
||||
|
||||
if (basicResult !== null) {
|
||||
return basicResult;
|
||||
}
|
||||
|
||||
return printComplexValue(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
hasCalledToJSON
|
||||
);
|
||||
}
|
||||
|
||||
const DEFAULT_THEME = {
|
||||
comment: 'gray',
|
||||
content: 'reset',
|
||||
prop: 'yellow',
|
||||
tag: 'cyan',
|
||||
value: 'green'
|
||||
};
|
||||
const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
|
||||
const DEFAULT_OPTIONS = {
|
||||
callToJSON: true,
|
||||
escapeRegex: false,
|
||||
escapeString: true,
|
||||
highlight: false,
|
||||
indent: 2,
|
||||
maxDepth: Infinity,
|
||||
min: false,
|
||||
plugins: [],
|
||||
printFunctionName: true,
|
||||
theme: DEFAULT_THEME
|
||||
};
|
||||
|
||||
function validateOptions(options) {
|
||||
Object.keys(options).forEach(key => {
|
||||
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
|
||||
throw new Error(`pretty-format: Unknown option "${key}".`);
|
||||
}
|
||||
});
|
||||
|
||||
if (options.min && options.indent !== undefined && options.indent !== 0) {
|
||||
throw new Error(
|
||||
'pretty-format: Options "min" and "indent" cannot be used together.'
|
||||
);
|
||||
}
|
||||
|
||||
if (options.theme !== undefined) {
|
||||
if (options.theme === null) {
|
||||
throw new Error(`pretty-format: Option "theme" must not be null.`);
|
||||
}
|
||||
|
||||
if (typeof options.theme !== 'object') {
|
||||
throw new Error(
|
||||
`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getColorsHighlight = options =>
|
||||
DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
||||
const value =
|
||||
options.theme && options.theme[key] !== undefined
|
||||
? options.theme[key]
|
||||
: DEFAULT_THEME[key];
|
||||
const color = value && _ansiStyles.default[value];
|
||||
|
||||
if (
|
||||
color &&
|
||||
typeof color.close === 'string' &&
|
||||
typeof color.open === 'string'
|
||||
) {
|
||||
colors[key] = color;
|
||||
} else {
|
||||
throw new Error(
|
||||
`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
|
||||
);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}, Object.create(null));
|
||||
|
||||
const getColorsEmpty = () =>
|
||||
DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
||||
colors[key] = {
|
||||
close: '',
|
||||
open: ''
|
||||
};
|
||||
return colors;
|
||||
}, Object.create(null));
|
||||
|
||||
const getPrintFunctionName = options =>
|
||||
options && options.printFunctionName !== undefined
|
||||
? options.printFunctionName
|
||||
: DEFAULT_OPTIONS.printFunctionName;
|
||||
|
||||
const getEscapeRegex = options =>
|
||||
options && options.escapeRegex !== undefined
|
||||
? options.escapeRegex
|
||||
: DEFAULT_OPTIONS.escapeRegex;
|
||||
|
||||
const getEscapeString = options =>
|
||||
options && options.escapeString !== undefined
|
||||
? options.escapeString
|
||||
: DEFAULT_OPTIONS.escapeString;
|
||||
|
||||
const getConfig = options => ({
|
||||
callToJSON:
|
||||
options && options.callToJSON !== undefined
|
||||
? options.callToJSON
|
||||
: DEFAULT_OPTIONS.callToJSON,
|
||||
colors:
|
||||
options && options.highlight
|
||||
? getColorsHighlight(options)
|
||||
: getColorsEmpty(),
|
||||
escapeRegex: getEscapeRegex(options),
|
||||
escapeString: getEscapeString(options),
|
||||
indent:
|
||||
options && options.min
|
||||
? ''
|
||||
: createIndent(
|
||||
options && options.indent !== undefined
|
||||
? options.indent
|
||||
: DEFAULT_OPTIONS.indent
|
||||
),
|
||||
maxDepth:
|
||||
options && options.maxDepth !== undefined
|
||||
? options.maxDepth
|
||||
: DEFAULT_OPTIONS.maxDepth,
|
||||
min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
|
||||
plugins:
|
||||
options && options.plugins !== undefined
|
||||
? options.plugins
|
||||
: DEFAULT_OPTIONS.plugins,
|
||||
printFunctionName: getPrintFunctionName(options),
|
||||
spacingInner: options && options.min ? ' ' : '\n',
|
||||
spacingOuter: options && options.min ? '' : '\n'
|
||||
});
|
||||
|
||||
function createIndent(indent) {
|
||||
return new Array(indent + 1).join(' ');
|
||||
}
|
||||
/**
|
||||
* Returns a presentation string of your `val` object
|
||||
* @param val any potential JavaScript object
|
||||
* @param options Custom settings
|
||||
*/
|
||||
|
||||
function prettyFormat(val, options) {
|
||||
if (options) {
|
||||
validateOptions(options);
|
||||
|
||||
if (options.plugins) {
|
||||
const plugin = findPlugin(options.plugins, val);
|
||||
|
||||
if (plugin !== null) {
|
||||
return printPlugin(plugin, val, getConfig(options), '', 0, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const basicResult = printBasicValue(
|
||||
val,
|
||||
getPrintFunctionName(options),
|
||||
getEscapeRegex(options),
|
||||
getEscapeString(options)
|
||||
);
|
||||
|
||||
if (basicResult !== null) {
|
||||
return basicResult;
|
||||
}
|
||||
|
||||
return printComplexValue(val, getConfig(options), '', 0, []);
|
||||
}
|
||||
|
||||
prettyFormat.plugins = {
|
||||
AsymmetricMatcher: _AsymmetricMatcher.default,
|
||||
ConvertAnsi: _ConvertAnsi.default,
|
||||
DOMCollection: _DOMCollection.default,
|
||||
DOMElement: _DOMElement.default,
|
||||
Immutable: _Immutable.default,
|
||||
ReactElement: _ReactElement.default,
|
||||
ReactTestComponent: _ReactTestComponent.default
|
||||
};
|
||||
module.exports = prettyFormat;
|
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/AsymmetricMatcher.d.ts
generated
vendored
Normal file
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/AsymmetricMatcher.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
103
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js
generated
vendored
Normal file
103
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var _collections = require('../collections');
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
const asymmetricMatcher =
|
||||
typeof Symbol === 'function' && Symbol.for
|
||||
? Symbol.for('jest.asymmetricMatcher')
|
||||
: 0x1357a5;
|
||||
const SPACE = ' ';
|
||||
|
||||
const serialize = (val, config, indentation, depth, refs, printer) => {
|
||||
const stringedValue = val.toString();
|
||||
|
||||
if (
|
||||
stringedValue === 'ArrayContaining' ||
|
||||
stringedValue === 'ArrayNotContaining'
|
||||
) {
|
||||
if (++depth > config.maxDepth) {
|
||||
return '[' + stringedValue + ']';
|
||||
}
|
||||
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
'[' +
|
||||
(0, _collections.printListItems)(
|
||||
val.sample,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
stringedValue === 'ObjectContaining' ||
|
||||
stringedValue === 'ObjectNotContaining'
|
||||
) {
|
||||
if (++depth > config.maxDepth) {
|
||||
return '[' + stringedValue + ']';
|
||||
}
|
||||
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
'{' +
|
||||
(0, _collections.printObjectProperties)(
|
||||
val.sample,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
stringedValue === 'StringMatching' ||
|
||||
stringedValue === 'StringNotMatching'
|
||||
) {
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
printer(val.sample, config, indentation, depth, refs)
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
stringedValue === 'StringContaining' ||
|
||||
stringedValue === 'StringNotContaining'
|
||||
) {
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
printer(val.sample, config, indentation, depth, refs)
|
||||
);
|
||||
}
|
||||
|
||||
return val.toAsymmetricMatcher();
|
||||
};
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val => val && val.$$typeof === asymmetricMatcher;
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ConvertAnsi.d.ts
generated
vendored
Normal file
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ConvertAnsi.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
96
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ConvertAnsi.js
generated
vendored
Normal file
96
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ConvertAnsi.js
generated
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.serialize = exports.test = void 0;
|
||||
|
||||
var _ansiRegex = _interopRequireDefault(require('ansi-regex'));
|
||||
|
||||
var _ansiStyles = _interopRequireDefault(require('ansi-styles'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const toHumanReadableAnsi = text =>
|
||||
text.replace((0, _ansiRegex.default)(), match => {
|
||||
switch (match) {
|
||||
case _ansiStyles.default.red.close:
|
||||
case _ansiStyles.default.green.close:
|
||||
case _ansiStyles.default.cyan.close:
|
||||
case _ansiStyles.default.gray.close:
|
||||
case _ansiStyles.default.white.close:
|
||||
case _ansiStyles.default.yellow.close:
|
||||
case _ansiStyles.default.bgRed.close:
|
||||
case _ansiStyles.default.bgGreen.close:
|
||||
case _ansiStyles.default.bgYellow.close:
|
||||
case _ansiStyles.default.inverse.close:
|
||||
case _ansiStyles.default.dim.close:
|
||||
case _ansiStyles.default.bold.close:
|
||||
case _ansiStyles.default.reset.open:
|
||||
case _ansiStyles.default.reset.close:
|
||||
return '</>';
|
||||
|
||||
case _ansiStyles.default.red.open:
|
||||
return '<red>';
|
||||
|
||||
case _ansiStyles.default.green.open:
|
||||
return '<green>';
|
||||
|
||||
case _ansiStyles.default.cyan.open:
|
||||
return '<cyan>';
|
||||
|
||||
case _ansiStyles.default.gray.open:
|
||||
return '<gray>';
|
||||
|
||||
case _ansiStyles.default.white.open:
|
||||
return '<white>';
|
||||
|
||||
case _ansiStyles.default.yellow.open:
|
||||
return '<yellow>';
|
||||
|
||||
case _ansiStyles.default.bgRed.open:
|
||||
return '<bgRed>';
|
||||
|
||||
case _ansiStyles.default.bgGreen.open:
|
||||
return '<bgGreen>';
|
||||
|
||||
case _ansiStyles.default.bgYellow.open:
|
||||
return '<bgYellow>';
|
||||
|
||||
case _ansiStyles.default.inverse.open:
|
||||
return '<inverse>';
|
||||
|
||||
case _ansiStyles.default.dim.open:
|
||||
return '<dim>';
|
||||
|
||||
case _ansiStyles.default.bold.open:
|
||||
return '<bold>';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
const test = val =>
|
||||
typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
|
||||
|
||||
exports.test = test;
|
||||
|
||||
const serialize = (val, config, indentation, depth, refs, printer) =>
|
||||
printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
|
||||
|
||||
exports.serialize = serialize;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMCollection.d.ts
generated
vendored
Normal file
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMCollection.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
80
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMCollection.js
generated
vendored
Normal file
80
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMCollection.js
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.serialize = exports.test = void 0;
|
||||
|
||||
var _collections = require('../collections');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* eslint-disable local/ban-types-eventually */
|
||||
const SPACE = ' ';
|
||||
const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
|
||||
const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
|
||||
|
||||
const testName = name =>
|
||||
OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
|
||||
|
||||
const test = val =>
|
||||
val &&
|
||||
val.constructor &&
|
||||
!!val.constructor.name &&
|
||||
testName(val.constructor.name);
|
||||
|
||||
exports.test = test;
|
||||
|
||||
const isNamedNodeMap = collection =>
|
||||
collection.constructor.name === 'NamedNodeMap';
|
||||
|
||||
const serialize = (collection, config, indentation, depth, refs, printer) => {
|
||||
const name = collection.constructor.name;
|
||||
|
||||
if (++depth > config.maxDepth) {
|
||||
return '[' + name + ']';
|
||||
}
|
||||
|
||||
return (
|
||||
(config.min ? '' : name + SPACE) +
|
||||
(OBJECT_NAMES.indexOf(name) !== -1
|
||||
? '{' +
|
||||
(0, _collections.printObjectProperties)(
|
||||
isNamedNodeMap(collection)
|
||||
? Array.from(collection).reduce((props, attribute) => {
|
||||
props[attribute.name] = attribute.value;
|
||||
return props;
|
||||
}, {})
|
||||
: {...collection},
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}'
|
||||
: '[' +
|
||||
(0, _collections.printListItems)(
|
||||
Array.from(collection),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']')
|
||||
);
|
||||
};
|
||||
|
||||
exports.serialize = serialize;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMElement.d.ts
generated
vendored
Normal file
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMElement.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
125
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMElement.js
generated
vendored
Normal file
125
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/DOMElement.js
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.serialize = exports.test = void 0;
|
||||
|
||||
var _markup = require('./lib/markup');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const ELEMENT_NODE = 1;
|
||||
const TEXT_NODE = 3;
|
||||
const COMMENT_NODE = 8;
|
||||
const FRAGMENT_NODE = 11;
|
||||
const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
|
||||
|
||||
const testNode = val => {
|
||||
var _val$hasAttribute;
|
||||
|
||||
const constructorName = val.constructor.name;
|
||||
const {nodeType, tagName} = val;
|
||||
const isCustomElement =
|
||||
(typeof tagName === 'string' && tagName.includes('-')) ||
|
||||
((_val$hasAttribute = val.hasAttribute) === null ||
|
||||
_val$hasAttribute === void 0
|
||||
? void 0
|
||||
: _val$hasAttribute.call(val, 'is'));
|
||||
return (
|
||||
(nodeType === ELEMENT_NODE &&
|
||||
(ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||
|
||||
(nodeType === TEXT_NODE && constructorName === 'Text') ||
|
||||
(nodeType === COMMENT_NODE && constructorName === 'Comment') ||
|
||||
(nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment')
|
||||
);
|
||||
};
|
||||
|
||||
const test = val => {
|
||||
var _val$constructor;
|
||||
|
||||
return (
|
||||
(val === null || val === void 0
|
||||
? void 0
|
||||
: (_val$constructor = val.constructor) === null ||
|
||||
_val$constructor === void 0
|
||||
? void 0
|
||||
: _val$constructor.name) && testNode(val)
|
||||
);
|
||||
};
|
||||
|
||||
exports.test = test;
|
||||
|
||||
function nodeIsText(node) {
|
||||
return node.nodeType === TEXT_NODE;
|
||||
}
|
||||
|
||||
function nodeIsComment(node) {
|
||||
return node.nodeType === COMMENT_NODE;
|
||||
}
|
||||
|
||||
function nodeIsFragment(node) {
|
||||
return node.nodeType === FRAGMENT_NODE;
|
||||
}
|
||||
|
||||
const serialize = (node, config, indentation, depth, refs, printer) => {
|
||||
if (nodeIsText(node)) {
|
||||
return (0, _markup.printText)(node.data, config);
|
||||
}
|
||||
|
||||
if (nodeIsComment(node)) {
|
||||
return (0, _markup.printComment)(node.data, config);
|
||||
}
|
||||
|
||||
const type = nodeIsFragment(node)
|
||||
? `DocumentFragment`
|
||||
: node.tagName.toLowerCase();
|
||||
|
||||
if (++depth > config.maxDepth) {
|
||||
return (0, _markup.printElementAsLeaf)(type, config);
|
||||
}
|
||||
|
||||
return (0, _markup.printElement)(
|
||||
type,
|
||||
(0, _markup.printProps)(
|
||||
nodeIsFragment(node)
|
||||
? []
|
||||
: Array.from(node.attributes)
|
||||
.map(attr => attr.name)
|
||||
.sort(),
|
||||
nodeIsFragment(node)
|
||||
? {}
|
||||
: Array.from(node.attributes).reduce((props, attribute) => {
|
||||
props[attribute.name] = attribute.value;
|
||||
return props;
|
||||
}, {}),
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
(0, _markup.printChildren)(
|
||||
Array.prototype.slice.call(node.childNodes || node.children),
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
config,
|
||||
indentation
|
||||
);
|
||||
};
|
||||
|
||||
exports.serialize = serialize;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/Immutable.d.ts
generated
vendored
Normal file
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/Immutable.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
247
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/Immutable.js
generated
vendored
Normal file
247
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/Immutable.js
generated
vendored
Normal file
|
@ -0,0 +1,247 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var _collections = require('../collections');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// SENTINEL constants are from https://github.com/facebook/immutable-js
|
||||
const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
|
||||
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
||||
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
||||
const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
||||
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
||||
const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
|
||||
|
||||
const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
|
||||
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
||||
const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
||||
|
||||
const getImmutableName = name => 'Immutable.' + name;
|
||||
|
||||
const printAsLeaf = name => '[' + name + ']';
|
||||
|
||||
const SPACE = ' ';
|
||||
const LAZY = '…'; // Seq is lazy if it calls a method like filter
|
||||
|
||||
const printImmutableEntries = (
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
type
|
||||
) =>
|
||||
++depth > config.maxDepth
|
||||
? printAsLeaf(getImmutableName(type))
|
||||
: getImmutableName(type) +
|
||||
SPACE +
|
||||
'{' +
|
||||
(0, _collections.printIteratorEntries)(
|
||||
val.entries(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}'; // Record has an entries method because it is a collection in immutable v3.
|
||||
// Return an iterator for Immutable Record from version v3 or v4.
|
||||
|
||||
function getRecordEntries(val) {
|
||||
let i = 0;
|
||||
return {
|
||||
next() {
|
||||
if (i < val._keys.length) {
|
||||
const key = val._keys[i++];
|
||||
return {
|
||||
done: false,
|
||||
value: [key, val.get(key)]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
done: true,
|
||||
value: undefined
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const printImmutableRecord = (
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) => {
|
||||
// _name property is defined only for an Immutable Record instance
|
||||
// which was constructed with a second optional descriptive name arg
|
||||
const name = getImmutableName(val._name || 'Record');
|
||||
return ++depth > config.maxDepth
|
||||
? printAsLeaf(name)
|
||||
: name +
|
||||
SPACE +
|
||||
'{' +
|
||||
(0, _collections.printIteratorEntries)(
|
||||
getRecordEntries(val),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}';
|
||||
};
|
||||
|
||||
const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
|
||||
const name = getImmutableName('Seq');
|
||||
|
||||
if (++depth > config.maxDepth) {
|
||||
return printAsLeaf(name);
|
||||
}
|
||||
|
||||
if (val[IS_KEYED_SENTINEL]) {
|
||||
return (
|
||||
name +
|
||||
SPACE +
|
||||
'{' + // from Immutable collection of entries or from ECMAScript object
|
||||
(val._iter || val._object
|
||||
? (0, _collections.printIteratorEntries)(
|
||||
val.entries(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: LAZY) +
|
||||
'}'
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
name +
|
||||
SPACE +
|
||||
'[' +
|
||||
(val._iter || // from Immutable collection of values
|
||||
val._array || // from ECMAScript array
|
||||
val._collection || // from ECMAScript collection in immutable v4
|
||||
val._iterable // from ECMAScript collection in immutable v3
|
||||
? (0, _collections.printIteratorValues)(
|
||||
val.values(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: LAZY) +
|
||||
']'
|
||||
);
|
||||
};
|
||||
|
||||
const printImmutableValues = (
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
type
|
||||
) =>
|
||||
++depth > config.maxDepth
|
||||
? printAsLeaf(getImmutableName(type))
|
||||
: getImmutableName(type) +
|
||||
SPACE +
|
||||
'[' +
|
||||
(0, _collections.printIteratorValues)(
|
||||
val.values(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']';
|
||||
|
||||
const serialize = (val, config, indentation, depth, refs, printer) => {
|
||||
if (val[IS_MAP_SENTINEL]) {
|
||||
return printImmutableEntries(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_LIST_SENTINEL]) {
|
||||
return printImmutableValues(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
'List'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_SET_SENTINEL]) {
|
||||
return printImmutableValues(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_STACK_SENTINEL]) {
|
||||
return printImmutableValues(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
'Stack'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_SEQ_SENTINEL]) {
|
||||
return printImmutableSeq(val, config, indentation, depth, refs, printer);
|
||||
} // For compatibility with immutable v3 and v4, let record be the default.
|
||||
|
||||
return printImmutableRecord(val, config, indentation, depth, refs, printer);
|
||||
}; // Explicitly comparing sentinel properties to true avoids false positive
|
||||
// when mock identity-obj-proxy returns the key as the value for any key.
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val =>
|
||||
val &&
|
||||
(val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactElement.d.ts
generated
vendored
Normal file
11
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactElement.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
166
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactElement.js
generated
vendored
Normal file
166
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactElement.js
generated
vendored
Normal file
|
@ -0,0 +1,166 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var ReactIs = _interopRequireWildcard(require('react-is'));
|
||||
|
||||
var _markup = require('./lib/markup');
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// Given element.props.children, or subtree during recursive traversal,
|
||||
// return flattened array of children.
|
||||
const getChildren = (arg, children = []) => {
|
||||
if (Array.isArray(arg)) {
|
||||
arg.forEach(item => {
|
||||
getChildren(item, children);
|
||||
});
|
||||
} else if (arg != null && arg !== false) {
|
||||
children.push(arg);
|
||||
}
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
const getType = element => {
|
||||
const type = element.type;
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || 'Unknown';
|
||||
}
|
||||
|
||||
if (ReactIs.isFragment(element)) {
|
||||
return 'React.Fragment';
|
||||
}
|
||||
|
||||
if (ReactIs.isSuspense(element)) {
|
||||
return 'React.Suspense';
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (ReactIs.isContextProvider(element)) {
|
||||
return 'Context.Provider';
|
||||
}
|
||||
|
||||
if (ReactIs.isContextConsumer(element)) {
|
||||
return 'Context.Consumer';
|
||||
}
|
||||
|
||||
if (ReactIs.isForwardRef(element)) {
|
||||
if (type.displayName) {
|
||||
return type.displayName;
|
||||
}
|
||||
|
||||
const functionName = type.render.displayName || type.render.name || '';
|
||||
return functionName !== ''
|
||||
? 'ForwardRef(' + functionName + ')'
|
||||
: 'ForwardRef';
|
||||
}
|
||||
|
||||
if (ReactIs.isMemo(element)) {
|
||||
const functionName =
|
||||
type.displayName || type.type.displayName || type.type.name || '';
|
||||
return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
|
||||
}
|
||||
}
|
||||
|
||||
return 'UNDEFINED';
|
||||
};
|
||||
|
||||
const getPropKeys = element => {
|
||||
const {props} = element;
|
||||
return Object.keys(props)
|
||||
.filter(key => key !== 'children' && props[key] !== undefined)
|
||||
.sort();
|
||||
};
|
||||
|
||||
const serialize = (element, config, indentation, depth, refs, printer) =>
|
||||
++depth > config.maxDepth
|
||||
? (0, _markup.printElementAsLeaf)(getType(element), config)
|
||||
: (0, _markup.printElement)(
|
||||
getType(element),
|
||||
(0, _markup.printProps)(
|
||||
getPropKeys(element),
|
||||
element.props,
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
(0, _markup.printChildren)(
|
||||
getChildren(element.props.children),
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
config,
|
||||
indentation
|
||||
);
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val => val && ReactIs.isElement(val);
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
18
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactTestComponent.d.ts
generated
vendored
Normal file
18
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactTestComponent.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare type ReactTestObject = {
|
||||
$$typeof: symbol;
|
||||
type: string;
|
||||
props?: Record<string, unknown>;
|
||||
children?: null | Array<ReactTestChild>;
|
||||
};
|
||||
declare type ReactTestChild = ReactTestObject | string | number;
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
65
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactTestComponent.js
generated
vendored
Normal file
65
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/ReactTestComponent.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var _markup = require('./lib/markup');
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
const testSymbol =
|
||||
typeof Symbol === 'function' && Symbol.for
|
||||
? Symbol.for('react.test.json')
|
||||
: 0xea71357;
|
||||
|
||||
const getPropKeys = object => {
|
||||
const {props} = object;
|
||||
return props
|
||||
? Object.keys(props)
|
||||
.filter(key => props[key] !== undefined)
|
||||
.sort()
|
||||
: [];
|
||||
};
|
||||
|
||||
const serialize = (object, config, indentation, depth, refs, printer) =>
|
||||
++depth > config.maxDepth
|
||||
? (0, _markup.printElementAsLeaf)(object.type, config)
|
||||
: (0, _markup.printElement)(
|
||||
object.type,
|
||||
object.props
|
||||
? (0, _markup.printProps)(
|
||||
getPropKeys(object),
|
||||
object.props,
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: '',
|
||||
object.children
|
||||
? (0, _markup.printChildren)(
|
||||
object.children,
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: '',
|
||||
config,
|
||||
indentation
|
||||
);
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val => val && val.$$typeof === testSymbol;
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
7
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts
generated
vendored
Normal file
7
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export default function escapeHTML(str: string): string;
|
16
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/escapeHTML.js
generated
vendored
Normal file
16
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/escapeHTML.js
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = escapeHTML;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
function escapeHTML(str) {
|
||||
return str.replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
13
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/markup.d.ts
generated
vendored
Normal file
13
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/markup.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { Config, Printer, Refs } from '../../types';
|
||||
export declare const printProps: (keys: Array<string>, props: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
||||
export declare const printChildren: (children: Array<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
||||
export declare const printText: (text: string, config: Config) => string;
|
||||
export declare const printComment: (comment: string, config: Config) => string;
|
||||
export declare const printElement: (type: string, printedProps: string, printedChildren: string, config: Config, indentation: string) => string;
|
||||
export declare const printElementAsLeaf: (type: string, config: Config) => string;
|
147
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/markup.js
generated
vendored
Normal file
147
web/node_modules/jest-diff/node_modules/pretty-format/build/plugins/lib/markup.js
generated
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = void 0;
|
||||
|
||||
var _escapeHTML = _interopRequireDefault(require('./escapeHTML'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// Return empty string if keys is empty.
|
||||
const printProps = (keys, props, config, indentation, depth, refs, printer) => {
|
||||
const indentationNext = indentation + config.indent;
|
||||
const colors = config.colors;
|
||||
return keys
|
||||
.map(key => {
|
||||
const value = props[key];
|
||||
let printed = printer(value, config, indentationNext, depth, refs);
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (printed.indexOf('\n') !== -1) {
|
||||
printed =
|
||||
config.spacingOuter +
|
||||
indentationNext +
|
||||
printed +
|
||||
config.spacingOuter +
|
||||
indentation;
|
||||
}
|
||||
|
||||
printed = '{' + printed + '}';
|
||||
}
|
||||
|
||||
return (
|
||||
config.spacingInner +
|
||||
indentation +
|
||||
colors.prop.open +
|
||||
key +
|
||||
colors.prop.close +
|
||||
'=' +
|
||||
colors.value.open +
|
||||
printed +
|
||||
colors.value.close
|
||||
);
|
||||
})
|
||||
.join('');
|
||||
}; // Return empty string if children is empty.
|
||||
|
||||
exports.printProps = printProps;
|
||||
|
||||
const printChildren = (children, config, indentation, depth, refs, printer) =>
|
||||
children
|
||||
.map(
|
||||
child =>
|
||||
config.spacingOuter +
|
||||
indentation +
|
||||
(typeof child === 'string'
|
||||
? printText(child, config)
|
||||
: printer(child, config, indentation, depth, refs))
|
||||
)
|
||||
.join('');
|
||||
|
||||
exports.printChildren = printChildren;
|
||||
|
||||
const printText = (text, config) => {
|
||||
const contentColor = config.colors.content;
|
||||
return (
|
||||
contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
|
||||
);
|
||||
};
|
||||
|
||||
exports.printText = printText;
|
||||
|
||||
const printComment = (comment, config) => {
|
||||
const commentColor = config.colors.comment;
|
||||
return (
|
||||
commentColor.open +
|
||||
'<!--' +
|
||||
(0, _escapeHTML.default)(comment) +
|
||||
'-->' +
|
||||
commentColor.close
|
||||
);
|
||||
}; // Separate the functions to format props, children, and element,
|
||||
// so a plugin could override a particular function, if needed.
|
||||
// Too bad, so sad: the traditional (but unnecessary) space
|
||||
// in a self-closing tagColor requires a second test of printedProps.
|
||||
|
||||
exports.printComment = printComment;
|
||||
|
||||
const printElement = (
|
||||
type,
|
||||
printedProps,
|
||||
printedChildren,
|
||||
config,
|
||||
indentation
|
||||
) => {
|
||||
const tagColor = config.colors.tag;
|
||||
return (
|
||||
tagColor.open +
|
||||
'<' +
|
||||
type +
|
||||
(printedProps &&
|
||||
tagColor.close +
|
||||
printedProps +
|
||||
config.spacingOuter +
|
||||
indentation +
|
||||
tagColor.open) +
|
||||
(printedChildren
|
||||
? '>' +
|
||||
tagColor.close +
|
||||
printedChildren +
|
||||
config.spacingOuter +
|
||||
indentation +
|
||||
tagColor.open +
|
||||
'</' +
|
||||
type
|
||||
: (printedProps && !config.min ? '' : ' ') + '/') +
|
||||
'>' +
|
||||
tagColor.close
|
||||
);
|
||||
};
|
||||
|
||||
exports.printElement = printElement;
|
||||
|
||||
const printElementAsLeaf = (type, config) => {
|
||||
const tagColor = config.colors.tag;
|
||||
return (
|
||||
tagColor.open +
|
||||
'<' +
|
||||
type +
|
||||
tagColor.close +
|
||||
' …' +
|
||||
tagColor.open +
|
||||
' />' +
|
||||
tagColor.close
|
||||
);
|
||||
};
|
||||
|
||||
exports.printElementAsLeaf = printElementAsLeaf;
|
100
web/node_modules/jest-diff/node_modules/pretty-format/build/types.d.ts
generated
vendored
Normal file
100
web/node_modules/jest-diff/node_modules/pretty-format/build/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare type Colors = {
|
||||
comment: {
|
||||
close: string;
|
||||
open: string;
|
||||
};
|
||||
content: {
|
||||
close: string;
|
||||
open: string;
|
||||
};
|
||||
prop: {
|
||||
close: string;
|
||||
open: string;
|
||||
};
|
||||
tag: {
|
||||
close: string;
|
||||
open: string;
|
||||
};
|
||||
value: {
|
||||
close: string;
|
||||
open: string;
|
||||
};
|
||||
};
|
||||
declare type Indent = (arg0: string) => string;
|
||||
export declare type Refs = Array<unknown>;
|
||||
declare type Print = (arg0: unknown) => string;
|
||||
export declare type Theme = {
|
||||
comment: string;
|
||||
content: string;
|
||||
prop: string;
|
||||
tag: string;
|
||||
value: string;
|
||||
};
|
||||
declare type ThemeReceived = {
|
||||
comment?: string;
|
||||
content?: string;
|
||||
prop?: string;
|
||||
tag?: string;
|
||||
value?: string;
|
||||
};
|
||||
export declare type Options = {
|
||||
callToJSON: boolean;
|
||||
escapeRegex: boolean;
|
||||
escapeString: boolean;
|
||||
highlight: boolean;
|
||||
indent: number;
|
||||
maxDepth: number;
|
||||
min: boolean;
|
||||
plugins: Plugins;
|
||||
printFunctionName: boolean;
|
||||
theme: Theme;
|
||||
};
|
||||
export declare type OptionsReceived = {
|
||||
callToJSON?: boolean;
|
||||
escapeRegex?: boolean;
|
||||
escapeString?: boolean;
|
||||
highlight?: boolean;
|
||||
indent?: number;
|
||||
maxDepth?: number;
|
||||
min?: boolean;
|
||||
plugins?: Plugins;
|
||||
printFunctionName?: boolean;
|
||||
theme?: ThemeReceived;
|
||||
};
|
||||
export declare type Config = {
|
||||
callToJSON: boolean;
|
||||
colors: Colors;
|
||||
escapeRegex: boolean;
|
||||
escapeString: boolean;
|
||||
indent: string;
|
||||
maxDepth: number;
|
||||
min: boolean;
|
||||
plugins: Plugins;
|
||||
printFunctionName: boolean;
|
||||
spacingInner: string;
|
||||
spacingOuter: string;
|
||||
};
|
||||
export declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
||||
declare type Test = (arg0: any) => boolean;
|
||||
export declare type NewPlugin = {
|
||||
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
||||
test: Test;
|
||||
};
|
||||
declare type PluginOptions = {
|
||||
edgeSpacing: string;
|
||||
min: boolean;
|
||||
spacing: string;
|
||||
};
|
||||
export declare type OldPlugin = {
|
||||
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
||||
test: Test;
|
||||
};
|
||||
export declare type Plugin = NewPlugin | OldPlugin;
|
||||
export declare type Plugins = Array<Plugin>;
|
||||
export {};
|
1
web/node_modules/jest-diff/node_modules/pretty-format/build/types.js
generated
vendored
Normal file
1
web/node_modules/jest-diff/node_modules/pretty-format/build/types.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
37
web/node_modules/jest-diff/node_modules/pretty-format/package.json
generated
vendored
Normal file
37
web/node_modules/jest-diff/node_modules/pretty-format/package.json
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "pretty-format",
|
||||
"version": "26.6.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/jest.git",
|
||||
"directory": "packages/pretty-format"
|
||||
},
|
||||
"license": "MIT",
|
||||
"description": "Stringify any JavaScript value.",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
"author": "James Kyle <me@thejameskyle.com>",
|
||||
"dependencies": {
|
||||
"@jest/types": "^26.6.2",
|
||||
"ansi-regex": "^5.0.0",
|
||||
"ansi-styles": "^4.0.0",
|
||||
"react-is": "^17.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-is": "^16.7.1",
|
||||
"@types/react-test-renderer": "*",
|
||||
"immutable": "4.0.0-rc.9",
|
||||
"jest-util": "^26.6.2",
|
||||
"react": "*",
|
||||
"react-dom": "*",
|
||||
"react-test-renderer": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4c46930615602cbf983fb7e8e82884c282a624d5"
|
||||
}
|
29
web/node_modules/jest-diff/package.json
generated
vendored
Normal file
29
web/node_modules/jest-diff/package.json
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "jest-diff",
|
||||
"version": "26.6.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/jest.git",
|
||||
"directory": "packages/jest-diff"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
"dependencies": {
|
||||
"chalk": "^4.0.0",
|
||||
"diff-sequences": "^26.6.2",
|
||||
"jest-get-type": "^26.3.0",
|
||||
"pretty-format": "^26.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/test-utils": "^26.6.2",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.14.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4c46930615602cbf983fb7e8e82884c282a624d5"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue