aboutsummaryrefslogtreecommitdiff
path: root/node_modules/pretty-format/build/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/pretty-format/build/plugins')
-rw-r--r--node_modules/pretty-format/build/plugins/AsymmetricMatcher.js54
-rw-r--r--node_modules/pretty-format/build/plugins/ReactElement.js95
-rw-r--r--node_modules/pretty-format/build/plugins/ReactTestComponent.js80
-rw-r--r--node_modules/pretty-format/build/plugins/escapeHTML.js16
4 files changed, 0 insertions, 245 deletions
diff --git a/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js b/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js
deleted file mode 100644
index ec529fbc3..000000000
--- a/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- */
-
-'use strict';
-
-const asymmetricMatcher = Symbol.for('jest.asymmetricMatcher');
-const SPACE = ' ';
-
-class ArrayContaining extends Array {}
-class ObjectContaining extends Object {}
-
-const printAsymmetricMatcher = (
-val,
-print,
-indent,
-opts,
-colors) =>
-{
- const stringedValue = val.toString();
-
- if (stringedValue === 'ArrayContaining') {
- const array = ArrayContaining.from(val.sample);
- return opts.spacing === SPACE ?
- stringedValue + SPACE + print(array) :
- print(array);
- }
-
- if (stringedValue === 'ObjectContaining') {
- const object = Object.assign(new ObjectContaining(), val.sample);
- return opts.spacing === SPACE ?
- stringedValue + SPACE + print(object) :
- print(object);
- }
-
- if (stringedValue === 'StringMatching') {
- return stringedValue + SPACE + print(val.sample);
- }
-
- if (stringedValue === 'StringContaining') {
- return stringedValue + SPACE + print(val.sample);
- }
-
- return val.toAsymmetricMatcher();
-};
-
-module.exports = {
- print: printAsymmetricMatcher,
- test: object => object && object.$$typeof === asymmetricMatcher }; \ No newline at end of file
diff --git a/node_modules/pretty-format/build/plugins/ReactElement.js b/node_modules/pretty-format/build/plugins/ReactElement.js
deleted file mode 100644
index 76f3350ac..000000000
--- a/node_modules/pretty-format/build/plugins/ReactElement.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-/* eslint-disable max-len */
-'use strict';
-
-const escapeHTML = require('./escapeHTML');
-
-const reactElement = Symbol.for('react.element');
-
-function traverseChildren(opaqueChildren, cb) {
- if (Array.isArray(opaqueChildren)) {
- opaqueChildren.forEach(child => traverseChildren(child, cb));
- } else if (opaqueChildren != null && opaqueChildren !== false) {
- cb(opaqueChildren);
- }
-}
-
-function printChildren(flatChildren, print, indent, colors, opts) {
- return flatChildren.map(node => {
- if (typeof node === 'object') {
- return printElement(node, print, indent, colors, opts);
- } else if (typeof node === 'string') {
- return colors.content.open + escapeHTML(node) + colors.content.close;
- } else {
- return print(node);
- }
- }).join(opts.edgeSpacing);
-}
-
-function printProps(props, print, indent, colors, opts) {
- return Object.keys(props).sort().map(name => {
- if (name === 'children') {
- return '';
- }
-
- const prop = props[name];
- let printed = print(prop);
-
- if (typeof prop !== 'string') {
- if (printed.indexOf('\n') !== -1) {
- printed = '{' + opts.edgeSpacing + indent(indent(printed) + opts.edgeSpacing + '}');
- } else {
- printed = '{' + printed + '}';
- }
- }
-
- return opts.spacing + indent(colors.prop.open + name + colors.prop.close + '=') + colors.value.open + printed + colors.value.close;
- }).join('');
-}
-
-function printElement(element, print, indent, colors, opts) {
- let result = colors.tag.open + '<';
- let elementName;
- if (typeof element.type === 'string') {
- elementName = element.type;
- } else if (typeof element.type === 'function') {
- elementName = element.type.displayName || element.type.name || 'Unknown';
- } else {
- elementName = 'Unknown';
- }
- result += elementName + colors.tag.close;
- result += printProps(element.props, print, indent, colors, opts);
-
- const opaqueChildren = element.props.children;
- const hasProps = !!Object.keys(element.props).
- filter(propName => propName !== 'children').
- length;
- const closeInNewLine = hasProps && !opts.min;
-
- if (opaqueChildren) {
- const flatChildren = [];
- traverseChildren(opaqueChildren, child => {
- flatChildren.push(child);
- });
- const children = printChildren(flatChildren, print, indent, colors, opts);
- result += colors.tag.open + (closeInNewLine ? '\n' : '') + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + elementName + '>' + colors.tag.close;
- } else {
- result += colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close;
- }
-
- return result;
-}
-
-module.exports = {
- print(val, print, indent, opts, colors) {
- return printElement(val, print, indent, colors, opts);
- },
- test(object) {
- return object && object.$$typeof === reactElement;
- } }; \ No newline at end of file
diff --git a/node_modules/pretty-format/build/plugins/ReactTestComponent.js b/node_modules/pretty-format/build/plugins/ReactTestComponent.js
deleted file mode 100644
index fdf31b6d5..000000000
--- a/node_modules/pretty-format/build/plugins/ReactTestComponent.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- *
- */
-/* eslint-disable max-len */
-'use strict';
-
-const escapeHTML = require('./escapeHTML');
-
-const reactTestInstance = Symbol.for('react.test.json');
-
-
-
-
-
-
-
-// Child can be `number` in Stack renderer but not in Fiber renderer.
-
-
-function printChildren(children, print, indent, colors, opts) {
- return children.map(child => printInstance(child, print, indent, colors, opts)).join(opts.edgeSpacing);
-}
-
-function printProps(props, print, indent, colors, opts) {
- return Object.keys(props).sort().map(name => {
- const prop = props[name];
- let printed = print(prop);
-
- if (typeof prop !== 'string') {
- if (printed.indexOf('\n') !== -1) {
- printed = '{' + opts.edgeSpacing + indent(indent(printed) + opts.edgeSpacing + '}');
- } else {
- printed = '{' + printed + '}';
- }
- }
-
- return opts.spacing + indent(colors.prop.open + name + colors.prop.close + '=') + colors.value.open + printed + colors.value.close;
- }).join('');
-}
-
-function printInstance(instance, print, indent, colors, opts) {
- if (typeof instance == 'number') {
- return print(instance);
- } else if (typeof instance === 'string') {
- return colors.content.open + escapeHTML(instance) + colors.content.close;
- }
-
- let closeInNewLine = false;
- let result = colors.tag.open + '<' + instance.type + colors.tag.close;
-
- if (instance.props) {
- // If assignments are in opposite order, Flow 0.39.0 finds incorrect error:
- // element of Object.keys. Expected object instead of possibly undefined value
- closeInNewLine = !!Object.keys(instance.props).length && !opts.min;
- result += printProps(instance.props, print, indent, colors, opts);
- }
-
- if (instance.children) {
- const children = printChildren(instance.children, print, indent, colors, opts);
- result += colors.tag.open + (closeInNewLine ? '\n' : '') + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + instance.type + '>' + colors.tag.close;
- } else {
- result += colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close;
- }
-
- return result;
-}
-
-module.exports = {
- print(val, print, indent, opts, colors) {
- return printInstance(val, print, indent, colors, opts);
- },
- test(object) {
- return object && object.$$typeof === reactTestInstance;
- } }; \ No newline at end of file
diff --git a/node_modules/pretty-format/build/plugins/escapeHTML.js b/node_modules/pretty-format/build/plugins/escapeHTML.js
deleted file mode 100644
index de6dda184..000000000
--- a/node_modules/pretty-format/build/plugins/escapeHTML.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- *
- */
-'use strict';
-
-function escapeHTML(str) {
- return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
-}
-
-module.exports = escapeHTML; \ No newline at end of file