Updating NPM dependencies
This commit is contained in:
125
node_modules/expect/build/matchers.js
generated
vendored
125
node_modules/expect/build/matchers.js
generated
vendored
@@ -5,39 +5,18 @@ Object.defineProperty(exports, '__esModule', {
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _jestGetType = _interopRequireWildcard(require('jest-get-type'));
|
||||
var _jestGetType = _interopRequireDefault(require('jest-get-type'));
|
||||
|
||||
var _jestMatcherUtils = require('jest-matcher-utils');
|
||||
|
||||
var _jasmineUtils = require('./jasmineUtils');
|
||||
|
||||
var _print = require('./print');
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
var _jasmineUtils = require('./jasmineUtils');
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,6 +26,8 @@ function _interopRequireWildcard(obj) {
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable local/ban-types-eventually */
|
||||
// Omit colon and one or more spaces, so can call getLabelPrinter.
|
||||
const EXPECTED_LABEL = 'Expected';
|
||||
const RECEIVED_LABEL = 'Received';
|
||||
@@ -141,18 +122,56 @@ const matchers = {
|
||||
toBeCloseTo(received, expected, precision = 2) {
|
||||
const matcherName = 'toBeCloseTo';
|
||||
const secondArgument = arguments.length === 3 ? 'precision' : undefined;
|
||||
const isNot = this.isNot;
|
||||
const options = {
|
||||
isNot: this.isNot,
|
||||
isNot,
|
||||
promise: this.promise,
|
||||
secondArgument,
|
||||
secondArgumentColor: arg => arg
|
||||
};
|
||||
(0, _jestMatcherUtils.ensureNumbers)(
|
||||
received,
|
||||
expected,
|
||||
matcherName,
|
||||
options
|
||||
);
|
||||
|
||||
if (typeof expected !== 'number') {
|
||||
throw new Error(
|
||||
(0, _jestMatcherUtils.matcherErrorMessage)(
|
||||
(0, _jestMatcherUtils.matcherHint)(
|
||||
matcherName,
|
||||
undefined,
|
||||
undefined,
|
||||
options
|
||||
),
|
||||
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
|
||||
'expected'
|
||||
)} value must be a number`,
|
||||
(0, _jestMatcherUtils.printWithType)(
|
||||
'Expected',
|
||||
expected,
|
||||
_jestMatcherUtils.printExpected
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof received !== 'number') {
|
||||
throw new Error(
|
||||
(0, _jestMatcherUtils.matcherErrorMessage)(
|
||||
(0, _jestMatcherUtils.matcherHint)(
|
||||
matcherName,
|
||||
undefined,
|
||||
undefined,
|
||||
options
|
||||
),
|
||||
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
|
||||
'received'
|
||||
)} value must be a number`,
|
||||
(0, _jestMatcherUtils.printWithType)(
|
||||
'Received',
|
||||
received,
|
||||
_jestMatcherUtils.printReceived
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
let pass = false;
|
||||
let expectedDiff = 0;
|
||||
let receivedDiff = 0;
|
||||
@@ -183,13 +202,12 @@ const matchers = {
|
||||
received
|
||||
)}\n` +
|
||||
'\n' +
|
||||
`Expected precision: ${(0, _jestMatcherUtils.stringify)(
|
||||
precision
|
||||
)}\n` +
|
||||
`Expected difference: not < ${(0,
|
||||
_jestMatcherUtils.printExpected)(expectedDiff)}\n` +
|
||||
`Received difference: ${(0,
|
||||
_jestMatcherUtils.printReceived)(receivedDiff)}`)
|
||||
(0, _print.printCloseTo)(
|
||||
receivedDiff,
|
||||
expectedDiff,
|
||||
precision,
|
||||
isNot
|
||||
))
|
||||
: () =>
|
||||
(0, _jestMatcherUtils.matcherHint)(
|
||||
matcherName,
|
||||
@@ -201,15 +219,12 @@ const matchers = {
|
||||
`Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
|
||||
`Received: ${(0, _jestMatcherUtils.printReceived)(received)}\n` +
|
||||
'\n' +
|
||||
`Expected precision: ${(0, _jestMatcherUtils.stringify)(
|
||||
precision
|
||||
)}\n` +
|
||||
`Expected difference: < ${(0, _jestMatcherUtils.printExpected)(
|
||||
expectedDiff
|
||||
)}\n` +
|
||||
`Received difference: ${(0, _jestMatcherUtils.printReceived)(
|
||||
receivedDiff
|
||||
)}`;
|
||||
(0, _print.printCloseTo)(
|
||||
receivedDiff,
|
||||
expectedDiff,
|
||||
precision,
|
||||
isNot
|
||||
);
|
||||
return {
|
||||
message,
|
||||
pass
|
||||
@@ -388,7 +403,7 @@ const matchers = {
|
||||
'Expected constructor',
|
||||
expected
|
||||
) +
|
||||
((0, _jestGetType.isPrimitive)(received) ||
|
||||
(_jestGetType.default.isPrimitive(received) ||
|
||||
Object.getPrototypeOf(received) === null
|
||||
? `\nReceived value has no prototype\nReceived value: ${(0,
|
||||
_jestMatcherUtils.printReceived)(received)}`
|
||||
@@ -794,8 +809,9 @@ const matchers = {
|
||||
};
|
||||
|
||||
if (
|
||||
typeof received !== 'string' &&
|
||||
(!received || typeof received.length !== 'number')
|
||||
typeof (received === null || received === void 0
|
||||
? void 0
|
||||
: received.length) !== 'number'
|
||||
) {
|
||||
throw new Error(
|
||||
(0, _jestMatcherUtils.matcherErrorMessage)(
|
||||
@@ -941,8 +957,7 @@ const matchers = {
|
||||
}
|
||||
|
||||
const result = (0, _utils.getPath)(received, expectedPath);
|
||||
const lastTraversedObject = result.lastTraversedObject,
|
||||
hasEndProp = result.hasEndProp;
|
||||
const {lastTraversedObject, hasEndProp} = result;
|
||||
const receivedPath = result.traversedPath;
|
||||
const hasCompletePath = receivedPath.length === expectedPathLength;
|
||||
const receivedValue = hasCompletePath ? result.value : lastTraversedObject;
|
||||
@@ -1111,7 +1126,7 @@ const matchers = {
|
||||
const pass =
|
||||
typeof expected === 'string'
|
||||
? received.includes(expected)
|
||||
: expected.test(received);
|
||||
: new RegExp(expected).test(received);
|
||||
const message = pass
|
||||
? () =>
|
||||
typeof expected === 'string'
|
||||
|
||||
Reference in New Issue
Block a user