jest-matcher-utils
Advanced tools
Comparing version 20.0.3 to 20.1.0-alpha.1
@@ -1,13 +0,3 @@ | ||
'use strict'; /** | ||
* Copyright (c) 2014, 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 chalk = require('chalk'); | ||
const prettyFormat = require('pretty-format');var _require$plugins = | ||
@@ -18,8 +8,8 @@ | ||
require('pretty-format').plugins;const AsymmetricMatcher = _require$plugins.AsymmetricMatcher,ReactElement = _require$plugins.ReactElement,HTMLElement = _require$plugins.HTMLElement,Immutable = _require$plugins.Immutable; | ||
const PLUGINS = [AsymmetricMatcher, ReactElement, HTMLElement].concat( | ||
Immutable); | ||
var _chalk = require('chalk');var _chalk2 = _interopRequireDefault(_chalk); | ||
var _jestGetType = require('jest-get-type');var _jestGetType2 = _interopRequireDefault(_jestGetType); | ||
var _prettyFormat = require('pretty-format');var _prettyFormat2 = _interopRequireDefault(_prettyFormat);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}var _prettyFormat$plugins = | ||
@@ -31,15 +21,16 @@ | ||
_prettyFormat2.default.plugins; /** | ||
* Copyright (c) 2014, 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. | ||
* | ||
* | ||
*/const AsymmetricMatcher = _prettyFormat$plugins.AsymmetricMatcher,HTMLElement = _prettyFormat$plugins.HTMLElement,Immutable = _prettyFormat$plugins.Immutable,ReactElement = _prettyFormat$plugins.ReactElement,ReactTestComponent = _prettyFormat$plugins.ReactTestComponent;const PLUGINS = [ReactTestComponent, ReactElement, HTMLElement, AsymmetricMatcher].concat(Immutable); | ||
const EXPECTED_COLOR = _chalk2.default.green; | ||
const EXPECTED_BG = _chalk2.default.bgGreen; | ||
const RECEIVED_COLOR = _chalk2.default.red; | ||
const RECEIVED_BG = _chalk2.default.bgRed; | ||
const EXPECTED_COLOR = chalk.green; | ||
const EXPECTED_BG = chalk.bgGreen; | ||
const RECEIVED_COLOR = chalk.red; | ||
const RECEIVED_BG = chalk.bgRed; | ||
const NUMBERS = [ | ||
@@ -62,36 +53,2 @@ 'zero', | ||
// get the type of a value with handling the edge cases like `typeof []` | ||
// and `typeof null` | ||
const getType = value => { | ||
if (typeof value === 'undefined') { | ||
return 'undefined'; | ||
} else if (value === null) { | ||
return 'null'; | ||
} else if (Array.isArray(value)) { | ||
return 'array'; | ||
} else if (typeof value === 'boolean') { | ||
return 'boolean'; | ||
} else if (typeof value === 'function') { | ||
return 'function'; | ||
} else if (typeof value === 'number') { | ||
return 'number'; | ||
} else if (typeof value === 'string') { | ||
return 'string'; | ||
} else if (typeof value === 'object') { | ||
if (value.constructor === RegExp) { | ||
return 'regexp'; | ||
} else if (value.constructor === Map) { | ||
return 'map'; | ||
} else if (value.constructor === Set) { | ||
return 'set'; | ||
} | ||
return 'object'; | ||
// $FlowFixMe https://github.com/facebook/flow/issues/1015 | ||
} else if (typeof value === 'symbol') { | ||
return 'symbol'; | ||
} | ||
throw new Error(`value of unknown type: ${value}`); | ||
}; | ||
const stringify = function (object) {let maxDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; | ||
@@ -102,3 +59,3 @@ const MAX_LENGTH = 10000; | ||
try { | ||
result = prettyFormat(object, { | ||
result = (0, _prettyFormat2.default)(object, { | ||
maxDepth, | ||
@@ -109,3 +66,3 @@ min: true, | ||
} catch (e) { | ||
result = prettyFormat(object, { | ||
result = (0, _prettyFormat2.default)(object, { | ||
callToJSON: false, | ||
@@ -136,3 +93,3 @@ maxDepth, | ||
{ | ||
const type = getType(received); | ||
const type = (0, _jestGetType2.default)(received); | ||
return ( | ||
@@ -202,8 +159,8 @@ name + | ||
return ( | ||
chalk.dim('expect' + (isDirectExpectCall ? '' : '(')) + | ||
_chalk2.default.dim('expect' + (isDirectExpectCall ? '' : '(')) + | ||
RECEIVED_COLOR(received) + | ||
chalk.dim((isDirectExpectCall ? '' : ')') + matcherName + '(') + | ||
_chalk2.default.dim((isDirectExpectCall ? '' : ')') + matcherName + '(') + | ||
EXPECTED_COLOR(expected) + ( | ||
secondArgument ? `, ${EXPECTED_COLOR(secondArgument)}` : '') + | ||
chalk.dim(')')); | ||
_chalk2.default.dim(')')); | ||
@@ -221,3 +178,2 @@ }; | ||
ensureNumbers, | ||
getType, | ||
highlightTrailingWhitespace, | ||
@@ -224,0 +180,0 @@ matcherHint, |
{ | ||
"name": "jest-matcher-utils", | ||
"description": "A set of utility functions for jest-matchers and related packages", | ||
"version": "20.0.3", | ||
"version": "20.1.0-alpha.1", | ||
"repository": { | ||
@@ -11,7 +11,7 @@ "type": "git", | ||
"main": "build/index.js", | ||
"browser": "build-es5/index.js", | ||
"dependencies": { | ||
"chalk": "^1.1.3", | ||
"pretty-format": "^20.0.3" | ||
"jest-get-type": "^20.1.0-alpha.1", | ||
"pretty-format": "^20.1.0-alpha.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5571
3
3
134
2
1
+ Addedansi-regex@3.0.1(transitive)
+ Addedjest-get-type@20.1.0-echo.1(transitive)
+ Addedpretty-format@20.1.0-echo.1(transitive)
- Removedpretty-format@20.0.3(transitive)