initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

24
node_modules/jest-leak-detector/README.md generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# jest-leak-detector
Module for verifying whether an object has been garbage collected or not.
Internally creates a weak reference to the object, and forces garbage collection
to happen. If the reference is gone, it meant no one else was pointing to the
object.
## Example
```javascript
let reference = {};
const detector = new LeakDetector(reference);
// Reference is held in memory.
console.log(detector.isLeaked()); // true
// We destroy the only reference to the object.
reference = null;
// Reference is gone.
console.log(detector.isLeaked()); // false
```

87
node_modules/jest-leak-detector/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,87 @@
/**
* Copyright (c) 2017-present, Facebook, Inc. 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.
*
*
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _prettyFormat;
function _load_prettyFormat() {
return _prettyFormat = _interopRequireDefault(require('pretty-format'));
}
var _v;
function _load_v() {
return _v = _interopRequireDefault(require('v8'));
}
var _vm;
function _load_vm() {
return _vm = _interopRequireDefault(require('vm'));
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const PRIMITIVE_TYPES = new Set(['undefined', 'boolean', 'number', 'string', 'symbol']);
exports.default = class {
constructor(value) {
if (this._isPrimitive(value)) {
throw new TypeError(['Primitives cannot leak memory.', 'You passed a ' + typeof value + ': <' + (0, (_prettyFormat || _load_prettyFormat()).default)(value) + '>'].join(' '));
}
let weak;
try {
// eslint-disable-next-line import/no-extraneous-dependencies
weak = require('weak');
} catch (err) {
if (!err || err.code !== 'MODULE_NOT_FOUND') {
throw err;
}
throw new Error('The leaking detection mechanism requires the "weak" package to be installed and work. ' + 'Please install it as a dependency on your main project');
}
weak(value, () => this._isReferenceBeingHeld = false);
this._isReferenceBeingHeld = true;
// Ensure value is not leaked by the closure created by the "weak" callback.
value = null;
}
isLeaking() {
this._runGarbageCollector();
return this._isReferenceBeingHeld;
}
_runGarbageCollector() {
const isGarbageCollectorHidden = !global.gc;
// GC is usually hidden, so we have to expose it before running.
(_v || _load_v()).default.setFlagsFromString('--expose-gc');
(_vm || _load_vm()).default.runInNewContext('gc')();
// The GC was not initially exposed, so let's hide it again.
if (isGarbageCollectorHidden) {
(_v || _load_v()).default.setFlagsFromString('--no-expose-gc');
}
}
_isPrimitive(value) {
return value === null || PRIMITIVE_TYPES.has(typeof value);
}
};

View File

@@ -0,0 +1,10 @@
'use strict';
module.exports = () => {
const pattern = [
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)',
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'
].join('|');
return new RegExp(pattern, 'g');
};

View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.

View File

@@ -0,0 +1,121 @@
{
"_args": [
[
"ansi-regex@^3.0.0",
"/home/bernhard/freifunk-app/node_modules/jest-leak-detector/node_modules/pretty-format"
]
],
"_from": "ansi-regex@>=3.0.0 <4.0.0",
"_id": "ansi-regex@3.0.0",
"_inCache": true,
"_installable": true,
"_location": "/jest-leak-detector/ansi-regex",
"_nodeVersion": "4.8.3",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/ansi-regex-3.0.0.tgz_1497985412590_0.5700640194118023"
},
"_npmUser": {
"email": "sindresorhus@gmail.com",
"name": "sindresorhus"
},
"_npmVersion": "2.15.11",
"_phantomChildren": {},
"_requested": {
"name": "ansi-regex",
"raw": "ansi-regex@^3.0.0",
"rawSpec": "^3.0.0",
"scope": null,
"spec": ">=3.0.0 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/jest-leak-detector/pretty-format"
],
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"_shasum": "ed0317c322064f79466c02966bddb605ab37d998",
"_shrinkwrap": null,
"_spec": "ansi-regex@^3.0.0",
"_where": "/home/bernhard/freifunk-app/node_modules/jest-leak-detector/node_modules/pretty-format",
"author": {
"email": "sindresorhus@gmail.com",
"name": "Sindre Sorhus",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/chalk/ansi-regex/issues"
},
"dependencies": {},
"description": "Regular expression for matching ANSI escape codes",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"directories": {},
"dist": {
"shasum": "ed0317c322064f79466c02966bddb605ab37d998",
"tarball": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"gitHead": "0a8cc19946c03c38520fe8c086b8adb66f9cce0b",
"homepage": "https://github.com/chalk/ansi-regex#readme",
"keywords": [
"256",
"ansi",
"cli",
"color",
"colors",
"colour",
"command-line",
"console",
"escape",
"find",
"formatting",
"match",
"pattern",
"re",
"regex",
"regexp",
"rgb",
"shell",
"string",
"styles",
"terminal",
"test",
"text",
"tty",
"xterm"
],
"license": "MIT",
"maintainers": [
{
"name": "dthree",
"email": "threedeecee@gmail.com"
},
{
"name": "qix",
"email": "i.am.qix@gmail.com"
},
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"name": "ansi-regex",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/ansi-regex.git"
},
"scripts": {
"test": "xo && ava",
"view-supported": "node fixtures/view-codes.js"
},
"version": "3.0.0"
}

View File

@@ -0,0 +1,46 @@
# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```
$ npm install ansi-regex
```
## Usage
```js
const ansiRegex = require('ansi-regex');
ansiRegex().test('\u001B[4mcake\u001B[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
//=> ['\u001B[4m', '\u001B[0m']
```
## FAQ
### Why do you test for codes not in the ECMA 48 standard?
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
## License
MIT

View File

@@ -0,0 +1,165 @@
'use strict';
const colorConvert = require('color-convert');
const wrapAnsi16 = (fn, offset) => function () {
const code = fn.apply(colorConvert, arguments);
return `\u001B[${code + offset}m`;
};
const wrapAnsi256 = (fn, offset) => function () {
const code = fn.apply(colorConvert, arguments);
return `\u001B[${38 + offset};5;${code}m`;
};
const wrapAnsi16m = (fn, offset) => function () {
const rgb = fn.apply(colorConvert, arguments);
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
};
function assembleStyles() {
const codes = new Map();
const styles = {
modifier: {
reset: [0, 0],
// 21 isn't widely supported and 22 does the same thing
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
color: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39],
// Bright color
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39]
},
bgColor: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
// Bright color
bgBlackBright: [100, 49],
bgRedBright: [101, 49],
bgGreenBright: [102, 49],
bgYellowBright: [103, 49],
bgBlueBright: [104, 49],
bgMagentaBright: [105, 49],
bgCyanBright: [106, 49],
bgWhiteBright: [107, 49]
}
};
// Fix humans
styles.color.grey = styles.color.gray;
for (const groupName of Object.keys(styles)) {
const group = styles[groupName];
for (const styleName of Object.keys(group)) {
const style = group[styleName];
styles[styleName] = {
open: `\u001B[${style[0]}m`,
close: `\u001B[${style[1]}m`
};
group[styleName] = styles[styleName];
codes.set(style[0], style[1]);
}
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
Object.defineProperty(styles, 'codes', {
value: codes,
enumerable: false
});
}
const ansi2ansi = n => n;
const rgb2rgb = (r, g, b) => [r, g, b];
styles.color.close = '\u001B[39m';
styles.bgColor.close = '\u001B[49m';
styles.color.ansi = {
ansi: wrapAnsi16(ansi2ansi, 0)
};
styles.color.ansi256 = {
ansi256: wrapAnsi256(ansi2ansi, 0)
};
styles.color.ansi16m = {
rgb: wrapAnsi16m(rgb2rgb, 0)
};
styles.bgColor.ansi = {
ansi: wrapAnsi16(ansi2ansi, 10)
};
styles.bgColor.ansi256 = {
ansi256: wrapAnsi256(ansi2ansi, 10)
};
styles.bgColor.ansi16m = {
rgb: wrapAnsi16m(rgb2rgb, 10)
};
for (let key of Object.keys(colorConvert)) {
if (typeof colorConvert[key] !== 'object') {
continue;
}
const suite = colorConvert[key];
if (key === 'ansi16') {
key = 'ansi';
}
if ('ansi16' in suite) {
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
}
if ('ansi256' in suite) {
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
}
if ('rgb' in suite) {
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
}
}
return styles;
}
// Make the export immutable
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});

View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.

View File

@@ -0,0 +1,122 @@
{
"_args": [
[
"ansi-styles@^3.2.0",
"/home/bernhard/freifunk-app/node_modules/jest-leak-detector/node_modules/pretty-format"
]
],
"_from": "ansi-styles@>=3.2.0 <4.0.0",
"_id": "ansi-styles@3.2.1",
"_inCache": true,
"_installable": true,
"_location": "/jest-leak-detector/ansi-styles",
"_nodeVersion": "8.9.4",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/ansi-styles_3.2.1_1519983600652_0.7656433427334486"
},
"_npmUser": {
"email": "sindresorhus@gmail.com",
"name": "sindresorhus"
},
"_npmVersion": "5.6.0",
"_phantomChildren": {},
"_requested": {
"name": "ansi-styles",
"raw": "ansi-styles@^3.2.0",
"rawSpec": "^3.2.0",
"scope": null,
"spec": ">=3.2.0 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/jest-leak-detector/pretty-format"
],
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"_shasum": "41fbb20243e50b12be0f04b8dedbf07520ce841d",
"_shrinkwrap": null,
"_spec": "ansi-styles@^3.2.0",
"_where": "/home/bernhard/freifunk-app/node_modules/jest-leak-detector/node_modules/pretty-format",
"author": {
"email": "sindresorhus@gmail.com",
"name": "Sindre Sorhus",
"url": "sindresorhus.com"
},
"ava": {
"require": "babel-polyfill"
},
"bugs": {
"url": "https://github.com/chalk/ansi-styles/issues"
},
"dependencies": {
"color-convert": "^1.9.0"
},
"description": "ANSI escape codes for styling strings in the terminal",
"devDependencies": {
"ava": "*",
"babel-polyfill": "^6.23.0",
"svg-term-cli": "^2.1.1",
"xo": "*"
},
"directories": {},
"dist": {
"fileCount": 4,
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"shasum": "41fbb20243e50b12be0f04b8dedbf07520ce841d",
"tarball": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"unpackedSize": 9371
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"gitHead": "de7527a86c1cf49906b0eb32a0de1402d849ccc2",
"homepage": "https://github.com/chalk/ansi-styles#readme",
"keywords": [
"256",
"ansi",
"cli",
"color",
"colors",
"colour",
"command-line",
"console",
"escape",
"formatting",
"log",
"logging",
"rgb",
"shell",
"string",
"styles",
"terminal",
"text",
"tty",
"xterm"
],
"license": "MIT",
"maintainers": [
{
"name": "qix",
"email": "i.am.qix@gmail.com"
},
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"name": "ansi-styles",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/ansi-styles.git"
},
"scripts": {
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor",
"test": "xo && ava"
},
"version": "3.2.1"
}

View File

@@ -0,0 +1,147 @@
# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
## Install
```
$ npm install ansi-styles
```
## Usage
```js
const style = require('ansi-styles');
console.log(`${style.green.open}Hello world!${style.green.close}`);
// Color conversion between 16/256/truecolor
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
// may be degraded to fit that color palette. This means terminals
// that do not support 16 million colors will best-match the
// original color.
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(Not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(Not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray` ("bright black")
- `redBright`
- `greenBright`
- `yellowBright`
- `blueBright`
- `magentaBright`
- `cyanBright`
- `whiteBright`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
- `bgBlackBright`
- `bgRedBright`
- `bgGreenBright`
- `bgYellowBright`
- `bgBlueBright`
- `bgMagentaBright`
- `bgCyanBright`
- `bgWhiteBright`
## Advanced usage
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
- `style.modifier`
- `style.color`
- `style.bgColor`
###### Example
```js
console.log(style.color.green.open);
```
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
###### Example
```js
console.log(style.codes.get(36));
//=> 39
```
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
To use these, call the associated conversion function with the intended output, for example:
```js
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
```
## Related
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
## License
MIT

View File

@@ -0,0 +1,492 @@
# pretty-format
> Stringify any JavaScript value.
* Supports all built-in JavaScript types
* primitive types: `Boolean`, `null`, `Number`, `String`, `Symbol`,
`undefined`
* other non-collection types: `Date`, `Error`, `Function`, `RegExp`
* collection types:
* `arguments`, `Array`, `ArrayBuffer`, `DataView`, `Float32Array`,
`Float64Array`, `Int8Array`, `Int16Array`, `Int32Array`, `Uint8Array`,
`Uint8ClampedArray`, `Uint16Array`, `Uint32Array`,
* `Map`, `Set`, `WeakMap`, `WeakSet`
* `Object`
* [Blazingly fast](https://gist.github.com/thejameskyle/2b04ffe4941aafa8f970de077843a8fd)
* similar performance to `JSON.stringify` in v8
* significantly faster than `util.format` in Node.js
* 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]
*/
```
| key | type | default | description |
| :------------------ | :-------- | :--------- | :------------------------------------------------------ |
| `callToJSON` | `boolean` | `true` | call `toJSON` method (if it exists) on objects |
| `escapeRegex` | `boolean` | `false` | escape special characters in regular expressions |
| `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 prettyFormat = require('pretty-format');
const ReactElement = prettyFormat.plugins.ReactElement;
const ReactTestComponent = prettyFormat.plugins.ReactTestComponent;
const React = require('react');
const renderer = require('react-test-renderer');
```
```js
// ES2015 modules and destructuring assignment
import prettyFormat from 'pretty-format';
const {ReactElement, ReactTestComponent} = prettyFormat.plugins;
import React from 'react';
import renderer from 'react-test-renderer';
```
```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
| 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 |
| `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. Of
course, `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],
}
*/
```

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.printIteratorEntries = printIteratorEntries;
exports.printIteratorValues = printIteratorValues;
exports.printListItems = printListItems;
exports.printObjectProperties = printObjectProperties;
const getSymbols = Object.getOwnPropertySymbols || (obj => []); /**
* Copyright (c) 2014-present, Facebook, Inc. 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 isSymbol = key =>
// $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value
typeof key === 'symbol' || toString.call(key) === '[object Symbol]';
// Return entries (for example, of a map)
// with spacing, indentation, and comma
// without surrounding punctuation (for example, braces)
function printIteratorEntries(
// Flow 0.51.0: property `@@iterator` of $Iterator not found in Object
// To allow simplistic getRecordIterator in immutable.js
iterator, config, indentation, depth, refs, printer) {
let separator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ': ';
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 = '';
let keys = Object.keys(val).sort();
const symbols = getSymbols(val);
if (symbols.length) {
keys = keys.filter(key => !isSymbol(key)).concat(symbols);
}
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;
}

View File

@@ -0,0 +1,353 @@
'use strict';
var _ansiStyles = require('ansi-styles');
var _ansiStyles2 = _interopRequireDefault(_ansiStyles);
var _collections = require('./collections');
var _asymmetric_matcher = require('./plugins/asymmetric_matcher');
var _asymmetric_matcher2 = _interopRequireDefault(_asymmetric_matcher);
var _convert_ansi = require('./plugins/convert_ansi');
var _convert_ansi2 = _interopRequireDefault(_convert_ansi);
var _dom_collection = require('./plugins/dom_collection');
var _dom_collection2 = _interopRequireDefault(_dom_collection);
var _dom_element = require('./plugins/dom_element');
var _dom_element2 = _interopRequireDefault(_dom_element);
var _immutable = require('./plugins/immutable');
var _immutable2 = _interopRequireDefault(_immutable);
var _react_element = require('./plugins/react_element');
var _react_element2 = _interopRequireDefault(_react_element);
var _react_test_component = require('./plugins/react_test_component');
var _react_test_component2 = _interopRequireDefault(_react_test_component);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 toString = Object.prototype.toString;
const toISOString = Date.prototype.toISOString;
const errorToString = Error.prototype.toString;
const regExpToString = RegExp.prototype.toString;
const symbolToString = Symbol.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';
// Is val is equal to global window object? Works even if it does not exist :)
/* global window */
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 printFunction(val, printFunctionName) {
if (!printFunctionName) {
return '[Function]';
}
return '[Function ' + (val.name || 'anonymous') + ']';
}
function printSymbol(val) {
return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
}
function printError(val) {
return '[' + errorToString.call(val) + ']';
}
function printBasicValue(val, printFunctionName, escapeRegex) {
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 === 'string') {
return '"' + val.replace(/"|\\/g, '\\$&') + '"';
}
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 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;
}
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 printPlugin(plugin, val, config, indentation, depth, refs) {
let printed;
try {
printed = plugin.serialize ? 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);
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,
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
// $FlowFixMe: Flow thinks keys from `Colors` are missing from `DEFAULT_THEME_KEYS`
) => DEFAULT_THEME_KEYS.reduce((colors, key) => {
const value = options.theme && options.theme[key] !== undefined ? options.theme[key] : DEFAULT_THEME[key];
const color = _ansiStyles2.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 = () =>
// $FlowFixMe: Flow thinks keys from `Colors` are missing from `DEFAULT_THEME_KEYS`
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 getConfig = options => ({
callToJSON: options && options.callToJSON !== undefined ? options.callToJSON : DEFAULT_OPTIONS.callToJSON,
colors: options && options.highlight ? getColorsHighlight(options) : getColorsEmpty(),
escapeRegex: getEscapeRegex(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(' ');
}
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));
if (basicResult !== null) {
return basicResult;
}
return printComplexValue(val, getConfig(options), '', 0, []);
}
prettyFormat.plugins = {
AsymmetricMatcher: _asymmetric_matcher2.default,
ConvertAnsi: _convert_ansi2.default,
DOMCollection: _dom_collection2.default,
DOMElement: _dom_element2.default,
Immutable: _immutable2.default,
ReactElement: _react_element2.default,
ReactTestComponent: _react_test_component2.default
};
module.exports = prettyFormat;

View File

@@ -0,0 +1,52 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _collections = require('../collections');
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 asymmetricMatcher = Symbol.for('jest.asymmetricMatcher');
const SPACE = ' ';
const serialize = exports.serialize = (val, config, indentation, depth, refs, printer) => {
const stringedValue = val.toString();
if (stringedValue === 'ArrayContaining') {
if (++depth > config.maxDepth) {
return '[' + stringedValue + ']';
}
return stringedValue + SPACE + '[' + (0, _collections.printListItems)(val.sample, config, indentation, depth, refs, printer) + ']';
}
if (stringedValue === 'ObjectContaining') {
if (++depth > config.maxDepth) {
return '[' + stringedValue + ']';
}
return stringedValue + SPACE + '{' + (0, _collections.printObjectProperties)(val.sample, config, indentation, depth, refs, printer) + '}';
}
if (stringedValue === 'StringMatching') {
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
}
if (stringedValue === 'StringContaining') {
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
}
return val.toAsymmetricMatcher();
};
const test = exports.test = val => val && val.$$typeof === asymmetricMatcher;
exports.default = { serialize, test };

View File

@@ -0,0 +1,77 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.serialize = exports.test = undefined;
var _ansiRegex = require('ansi-regex');
var _ansiRegex2 = _interopRequireDefault(_ansiRegex);
var _ansiStyles = require('ansi-styles');
var _ansiStyles2 = _interopRequireDefault(_ansiStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const toHumanReadableAnsi = text => {
return text.replace((0, _ansiRegex2.default)(), (match, offset, string) => {
switch (match) {
case _ansiStyles2.default.red.close:
case _ansiStyles2.default.green.close:
case _ansiStyles2.default.cyan.close:
case _ansiStyles2.default.gray.close:
case _ansiStyles2.default.white.close:
case _ansiStyles2.default.yellow.close:
case _ansiStyles2.default.bgRed.close:
case _ansiStyles2.default.bgGreen.close:
case _ansiStyles2.default.bgYellow.close:
case _ansiStyles2.default.inverse.close:
case _ansiStyles2.default.dim.close:
case _ansiStyles2.default.bold.close:
case _ansiStyles2.default.reset.open:
case _ansiStyles2.default.reset.close:
return '</>';
case _ansiStyles2.default.red.open:
return '<red>';
case _ansiStyles2.default.green.open:
return '<green>';
case _ansiStyles2.default.cyan.open:
return '<cyan>';
case _ansiStyles2.default.gray.open:
return '<gray>';
case _ansiStyles2.default.white.open:
return '<white>';
case _ansiStyles2.default.yellow.open:
return '<yellow>';
case _ansiStyles2.default.bgRed.open:
return '<bgRed>';
case _ansiStyles2.default.bgGreen.open:
return '<bgGreen>';
case _ansiStyles2.default.bgYellow.open:
return '<bgYellow>';
case _ansiStyles2.default.inverse.open:
return '<inverse>';
case _ansiStyles2.default.dim.open:
return '<dim>';
case _ansiStyles2.default.bold.open:
return '<bold>';
default:
return '';
}
});
}; /**
* Copyright (c) 2014-present, Facebook, Inc. 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 test = exports.test = val => typeof val === 'string' && val.match((0, _ansiRegex2.default)());
const serialize = exports.serialize = (val, config, indentation, depth, refs, printer) => printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
exports.default = { serialize, test };

View File

@@ -0,0 +1,47 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.serialize = exports.test = undefined;
var _collections = require('../collections');
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 SPACE = ' ';
const COLLECTION_NAMES = ['DOMStringMap', 'NamedNodeMap'];
const test = exports.test = val => val && val.constructor && COLLECTION_NAMES.indexOf(val.constructor.name) !== -1;
const convertCollectionToObject = collection => {
let result = {};
if (collection.constructor.name === 'NamedNodeMap') {
for (let i = 0; i < collection.length; i++) {
result[collection[i].name] = collection[i].value;
}
} else {
result = Object.assign({}, collection);
}
return result;
};
const serialize = exports.serialize = (collection, config, indentation, depth, refs, printer) => {
if (++depth > config.maxDepth) {
return '[' + collection.constructor.name + ']';
}
return collection.constructor.name + SPACE + '{' + (0, _collections.printObjectProperties)(convertCollectionToObject(collection), config, indentation, depth, refs, printer) + '}';
};
exports.default = { serialize, test };

View File

@@ -0,0 +1,53 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.serialize = exports.test = undefined;
var _markup = require('./lib/markup');
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
const testNode = (nodeType, name) => nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name) || nodeType === TEXT_NODE && name === 'Text' || nodeType === COMMENT_NODE && name === 'Comment';
const test = exports.test = val => val && val.constructor && val.constructor.name && testNode(val.nodeType, val.constructor.name);
// Convert array of attribute objects to keys array and props object.
const keysMapper = attribute => attribute.name;
const propsReducer = (props, attribute) => {
props[attribute.name] = attribute.value;
return props;
};
const serialize = exports.serialize = (node, config, indentation, depth, refs, printer) => {
if (node.nodeType === TEXT_NODE) {
return (0, _markup.printText)(node.data, config);
}
if (node.nodeType === COMMENT_NODE) {
return (0, _markup.printComment)(node.data, config);
}
const type = node.tagName.toLowerCase();
if (++depth > config.maxDepth) {
return (0, _markup.printElementAsLeaf)(type, config);
}
return (0, _markup.printElement)(type, (0, _markup.printProps)(Array.prototype.map.call(node.attributes, keysMapper).sort(), Array.prototype.reduce.call(node.attributes, propsReducer, {}), config, indentation + config.indent, depth, refs, printer), (0, _markup.printChildren)(Array.prototype.slice.call(node.childNodes), config, indentation + config.indent, depth, refs, printer), config, indentation);
};
exports.default = { serialize, test };

View File

@@ -0,0 +1,108 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _collections = require('../collections');
// SENTINEL constants are from https://github.com/facebook/immutable-js
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 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.
const 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 };
}
};
};
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 = exports.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.
const test = exports.test = val => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
exports.default = { serialize, test };

View File

@@ -0,0 +1,18 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = escapeHTML;
/**
* Copyright (c) 2014-present, Facebook, Inc. 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, '&lt;').replace(/>/g, '&gt;');
}

View File

@@ -0,0 +1,69 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = undefined;
var _escape_html = require('./escape_html');
var _escape_html2 = _interopRequireDefault(_escape_html);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Return empty string if keys is empty.
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 printProps = exports.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.
const printChildren = exports.printChildren = (children, config, indentation, depth, refs, printer) => {
return children.map(child => config.spacingOuter + indentation + (typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs))).join('');
};
const printText = exports.printText = (text, config) => {
const contentColor = config.colors.content;
return contentColor.open + (0, _escape_html2.default)(text) + contentColor.close;
};
const printComment = exports.printComment = (comment, config) => {
const commentColor = config.colors.comment;
return commentColor.open + '<!--' + (0, _escape_html2.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.
const printElement = exports.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;
};
const printElementAsLeaf = exports.printElementAsLeaf = (type, config) => {
const tagColor = config.colors.tag;
return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close;
};

View File

@@ -0,0 +1,50 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _markup = require('./lib/markup');
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 elementSymbol = Symbol.for('react.element');
// Given element.props.children, or subtree during recursive traversal,
// return flattened array of children.
const getChildren = function (arg) {
let children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
if (Array.isArray(arg)) {
arg.forEach(item => {
getChildren(item, children);
});
} else if (arg != null && arg !== false) {
children.push(arg);
}
return children;
};
const getType = element => {
if (typeof element.type === 'string') {
return element.type;
}
if (typeof element.type === 'function') {
return element.type.displayName || element.type.name || 'Unknown';
}
return 'UNDEFINED';
};
const serialize = exports.serialize = (element, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? (0, _markup.printElementAsLeaf)(getType(element), config) : (0, _markup.printElement)(getType(element), (0, _markup.printProps)(Object.keys(element.props).filter(key => key !== 'children').sort(), 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);
const test = exports.test = val => val && val.$$typeof === elementSymbol;
exports.default = { serialize, test };

View File

@@ -0,0 +1,29 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _markup = require('./lib/markup');
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 testSymbol = Symbol.for('react.test.json');
const serialize = exports.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)(Object.keys(object.props).sort(),
// Despite ternary expression, Flow 0.51.0 found incorrect error:
// undefined is incompatible with the expected param type of Object
// $FlowFixMe
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);
const test = exports.test = val => val && val.$$typeof === testSymbol;
exports.default = { serialize, test };

View File

@@ -0,0 +1,95 @@
{
"_args": [
[
"pretty-format@^22.4.3",
"/home/bernhard/freifunk-app/node_modules/jest-leak-detector"
]
],
"_from": "pretty-format@>=22.4.3 <23.0.0",
"_id": "pretty-format@22.4.3",
"_inCache": true,
"_installable": true,
"_location": "/jest-leak-detector/pretty-format",
"_nodeVersion": "8.9.1",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/pretty-format_22.4.3_1521648490562_0.8268179225620371"
},
"_npmUser": {
"email": "mjesun@hotmail.com",
"name": "mjesun"
},
"_npmVersion": "5.5.1",
"_phantomChildren": {},
"_requested": {
"name": "pretty-format",
"raw": "pretty-format@^22.4.3",
"rawSpec": "^22.4.3",
"scope": null,
"spec": ">=22.4.3 <23.0.0",
"type": "range"
},
"_requiredBy": [
"/jest-leak-detector"
],
"_resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-22.4.3.tgz",
"_shasum": "f873d780839a9c02e9664c8a082e9ee79eaac16f",
"_shrinkwrap": null,
"_spec": "pretty-format@^22.4.3",
"_where": "/home/bernhard/freifunk-app/node_modules/jest-leak-detector",
"author": {
"email": "me@thejameskyle.com",
"name": "James Kyle"
},
"browser": "build-es5/index.js",
"bugs": {
"url": "https://github.com/facebook/jest/issues"
},
"dependencies": {
"ansi-regex": "^3.0.0",
"ansi-styles": "^3.2.0"
},
"description": "Stringify any JavaScript value.",
"devDependencies": {},
"directories": {},
"dist": {
"fileCount": 16,
"integrity": "sha512-S4oT9/sT6MN7/3COoOy+ZJeA92VmOnveLHgrwBE3Z1W5N9S2A1QGNYiE1z75DAENbJrXXUb+OWXhpJcg05QKQQ==",
"shasum": "f873d780839a9c02e9664c8a082e9ee79eaac16f",
"tarball": "https://registry.npmjs.org/pretty-format/-/pretty-format-22.4.3.tgz",
"unpackedSize": 428862
},
"homepage": "https://github.com/facebook/jest#readme",
"license": "MIT",
"main": "build/index.js",
"maintainers": [
{
"name": "aaronabramov",
"email": "aaron@abramov.io"
},
{
"name": "cpojer",
"email": "christoph.pojer@gmail.com"
},
{
"name": "fb",
"email": "opensource+npm@fb.com"
},
{
"name": "jeanlauliac",
"email": "jean@lauliac.com"
},
{
"name": "mjesun",
"email": "mjesun@hotmail.com"
}
],
"name": "pretty-format",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/facebook/jest.git"
},
"version": "22.4.3"
}

View File

@@ -0,0 +1,215 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. 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 util from 'util';
const chalk = require('chalk');
const React = require('react');
const ReactTestRenderer = require('react-test-renderer');
const leftPad = require('left-pad');
const prettyFormat = require('../build');
const ReactTestComponent = require('../build/plugins/react_test_component');
const worldGeoJson = require('./world.geo.json');
const NANOSECONDS = 1000000000;
let TIMES_TO_RUN = 100000;
function testCase(name, fn) {
let result, error, time, total;
try {
result = fn();
} catch (err) {
error = err;
}
if (!error) {
const start = process.hrtime();
for (let i = 0; i < TIMES_TO_RUN; i++) {
fn();
}
const diff = process.hrtime(start);
total = diff[0] * 1e9 + diff[1];
time = Math.round(total / TIMES_TO_RUN);
}
return {
error,
name,
result,
time,
total,
};
}
function test(name, value, ignoreResult, prettyFormatOpts) {
const formatted = testCase('prettyFormat() ', () =>
prettyFormat(value, prettyFormatOpts),
);
const inspected = testCase('util.inspect() ', () => {
return util.inspect(value, {
depth: null,
showHidden: true,
});
});
const stringified = testCase('JSON.stringify()', () => {
return JSON.stringify(value, null, ' ');
});
const results = [formatted, inspected, stringified].sort((a, b) => {
return a.time - b.time;
});
const winner = results[0];
results.forEach((item, index) => {
item.isWinner = index === 0;
item.isLoser = index === results.length - 1;
});
function log(current) {
let message = current.name;
if (current.time) {
message += ' - ' + leftPad(current.time, 6) + 'ns';
}
if (current.total) {
message +=
' - ' +
current.total / NANOSECONDS +
's total (' +
TIMES_TO_RUN +
' runs)';
}
if (current.error) {
message += ' - Error: ' + current.error.message;
}
if (!ignoreResult && current.result) {
message += ' - ' + JSON.stringify(current.result);
}
message = ' ' + message + ' ';
if (current.error) {
message = chalk.dim(message);
}
const diff = current.time - winner.time;
if (diff > winner.time * 0.85) {
message = chalk.bgRed.black(message);
} else if (diff > winner.time * 0.65) {
message = chalk.bgYellow.black(message);
} else if (!current.error) {
message = chalk.bgGreen.black(message);
} else {
message = chalk.dim(message);
}
console.log(' ' + message);
}
console.log(name + ': ');
results.forEach(log);
console.log();
}
function returnArguments() {
return arguments;
}
test('empty arguments', returnArguments());
test('arguments', returnArguments(1, 2, 3));
test('an empty array', []);
test('an array with items', [1, 2, 3]);
test('a typed array', new Uint32Array(3));
test('an array buffer', new ArrayBuffer(3));
test('a nested array', [[1, 2, 3]]);
test('true', true);
test('false', false);
test('an error', new Error());
test('a typed error with a message', new TypeError('message'));
/* eslint-disable no-new-func */
test('a function constructor', new Function());
/* eslint-enable no-new-func */
test('an anonymous function', () => {});
function named() {}
test('a named function', named);
test('Infinity', Infinity);
test('-Infinity', -Infinity);
test('an empty map', new Map());
const mapWithValues = new Map();
const mapWithNonStringKeys = new Map();
mapWithValues.set('prop1', 'value1');
mapWithValues.set('prop2', 'value2');
mapWithNonStringKeys.set({prop: 'value'}, {prop: 'value'});
test('a map with values', mapWithValues);
test('a map with non-string keys', mapWithNonStringKeys);
test('NaN', NaN);
test('null', null);
test('a number', 123);
test('a date', new Date(10e11));
test('an empty object', {});
test('an object with properties', {prop1: 'value1', prop2: 'value2'});
const objectWithPropsAndSymbols = {prop: 'value1'};
objectWithPropsAndSymbols[Symbol('symbol1')] = 'value2';
objectWithPropsAndSymbols[Symbol('symbol2')] = 'value3';
test('an object with properties and symbols', objectWithPropsAndSymbols);
test('an object with sorted properties', {a: 2, b: 1});
test('regular expressions from constructors', new RegExp('regexp'));
test('regular expressions from literals', /regexp/gi);
test('an empty set', new Set());
const setWithValues = new Set();
setWithValues.add('value1');
setWithValues.add('value2');
test('a set with values', setWithValues);
test('a string', 'string');
test('a symbol', Symbol('symbol'));
test('undefined', undefined);
test('a WeakMap', new WeakMap());
test('a WeakSet', new WeakSet());
test('deeply nested objects', {prop: {prop: {prop: 'value'}}});
const circularReferences = {};
circularReferences.prop = circularReferences;
test('circular references', circularReferences);
const parallelReferencesInner = {};
const parallelReferences = {
prop1: parallelReferencesInner,
prop2: parallelReferencesInner,
};
test('parallel references', parallelReferences);
test('able to customize indent', {prop: 'value'});
const bigObj = {};
for (let i = 0; i < 50; i++) {
bigObj[i] = i;
}
test('big object', bigObj);
const element = React.createElement(
'div',
{onClick: () => {}, prop: {a: 1, b: 2}},
React.createElement('div', {prop: {a: 1, b: 2}}),
React.createElement('div'),
React.createElement(
'div',
{prop: {a: 1, b: 2}},
React.createElement('div', null, React.createElement('div')),
),
);
test('react', ReactTestRenderer.create(element).toJSON(), false, {
plugins: [ReactTestComponent],
});
TIMES_TO_RUN = 100;
test('massive', worldGeoJson, true);

File diff suppressed because one or more lines are too long

81
node_modules/jest-leak-detector/package.json generated vendored Normal file
View File

@@ -0,0 +1,81 @@
{
"_args": [
[
"jest-leak-detector@^22.4.0",
"/home/bernhard/freifunk-app/node_modules/jest-runner"
]
],
"_from": "jest-leak-detector@>=22.4.0 <23.0.0",
"_id": "jest-leak-detector@22.4.3",
"_inCache": true,
"_installable": true,
"_location": "/jest-leak-detector",
"_nodeVersion": "8.9.1",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/jest-leak-detector_22.4.3_1521648547529_0.5540752035668366"
},
"_npmUser": {
"email": "mjesun@hotmail.com",
"name": "mjesun"
},
"_npmVersion": "5.5.1",
"_phantomChildren": {
"color-convert": "1.9.2"
},
"_requested": {
"name": "jest-leak-detector",
"raw": "jest-leak-detector@^22.4.0",
"rawSpec": "^22.4.0",
"scope": null,
"spec": ">=22.4.0 <23.0.0",
"type": "range"
},
"_requiredBy": [
"/jest-runner"
],
"_resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-22.4.3.tgz",
"_shasum": "2b7b263103afae8c52b6b91241a2de40117e5b35",
"_shrinkwrap": null,
"_spec": "jest-leak-detector@^22.4.0",
"_where": "/home/bernhard/freifunk-app/node_modules/jest-runner",
"bugs": {
"url": "https://github.com/facebook/jest/issues"
},
"dependencies": {
"pretty-format": "^22.4.3"
},
"description": "Module for verifying whether an object has been garbage collected or not.",
"devDependencies": {
"weak": "^1.0.1"
},
"directories": {},
"dist": {
"fileCount": 3,
"integrity": "sha512-NZpR/Ls7+ndO57LuXROdgCGz2RmUdC541tTImL9bdUtU3WadgFGm0yV+Ok4Fuia/1rLAn5KaJ+i76L6e3zGJYQ==",
"shasum": "2b7b263103afae8c52b6b91241a2de40117e5b35",
"tarball": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-22.4.3.tgz",
"unpackedSize": 3177
},
"homepage": "https://github.com/facebook/jest#readme",
"license": "MIT",
"main": "build/index.js",
"maintainers": [
{
"name": "cpojer",
"email": "christoph.pojer@gmail.com"
},
{
"name": "mjesun",
"email": "mjesun@hotmail.com"
}
],
"name": "jest-leak-detector",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/facebook/jest.git"
},
"version": "22.4.3"
}