Updating NPM dependencies
This commit is contained in:
162
node_modules/expect/build/index.js
generated
vendored
162
node_modules/expect/build/index.js
generated
vendored
@@ -2,7 +2,15 @@
|
||||
|
||||
var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils'));
|
||||
|
||||
var _utils = require('./utils');
|
||||
var _asymmetricMatchers = require('./asymmetricMatchers');
|
||||
|
||||
var _extractExpectedAssertionsErrors = _interopRequireDefault(
|
||||
require('./extractExpectedAssertionsErrors')
|
||||
);
|
||||
|
||||
var _jasmineUtils = require('./jasmineUtils');
|
||||
|
||||
var _jestMatchersObject = require('./jestMatchersObject');
|
||||
|
||||
var _matchers = _interopRequireDefault(require('./matchers'));
|
||||
|
||||
@@ -10,65 +18,55 @@ var _spyMatchers = _interopRequireDefault(require('./spyMatchers'));
|
||||
|
||||
var _toThrowMatchers = _interopRequireWildcard(require('./toThrowMatchers'));
|
||||
|
||||
var _jasmineUtils = require('./jasmineUtils');
|
||||
|
||||
var _asymmetricMatchers = require('./asymmetricMatchers');
|
||||
|
||||
var _jestMatchersObject = require('./jestMatchersObject');
|
||||
|
||||
var _extractExpectedAssertionsErrors = _interopRequireDefault(
|
||||
require('./extractExpectedAssertionsErrors')
|
||||
);
|
||||
var _utils = require('./utils');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
|
||||
|
||||
@@ -99,10 +97,8 @@ const isPromise = obj =>
|
||||
(typeof obj === 'object' || typeof obj === 'function') &&
|
||||
typeof obj.then === 'function';
|
||||
|
||||
const createToThrowErrorMatchingSnapshotMatcher = function createToThrowErrorMatchingSnapshotMatcher(
|
||||
matcher
|
||||
) {
|
||||
return function(received, testNameOrInlineSnapshot) {
|
||||
const createToThrowErrorMatchingSnapshotMatcher = function (matcher) {
|
||||
return function (received, testNameOrInlineSnapshot) {
|
||||
return matcher.apply(this, [received, testNameOrInlineSnapshot, true]);
|
||||
};
|
||||
};
|
||||
@@ -224,12 +220,15 @@ const makeRejectMatcher = (matcherName, matcher, isNot, actual, outerErr) => (
|
||||
isNot,
|
||||
promise: 'rejects'
|
||||
};
|
||||
const actualWrapper = typeof actual === 'function' ? actual() : actual;
|
||||
|
||||
if (!isPromise(actual)) {
|
||||
if (!isPromise(actualWrapper)) {
|
||||
throw new JestAssertionError(
|
||||
matcherUtils.matcherErrorMessage(
|
||||
matcherUtils.matcherHint(matcherName, undefined, '', options),
|
||||
`${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`,
|
||||
`${matcherUtils.RECEIVED_COLOR(
|
||||
'received'
|
||||
)} value must be a promise or a function returning a promise`,
|
||||
matcherUtils.printWithType(
|
||||
'Received',
|
||||
actual,
|
||||
@@ -240,7 +239,7 @@ const makeRejectMatcher = (matcherName, matcher, isNot, actual, outerErr) => (
|
||||
}
|
||||
|
||||
const innerErr = new JestAssertionError();
|
||||
return actual.then(
|
||||
return actualWrapper.then(
|
||||
result => {
|
||||
outerErr.message =
|
||||
matcherUtils.matcherHint(matcherName, undefined, '', options) +
|
||||
@@ -260,30 +259,25 @@ const makeRejectMatcher = (matcherName, matcher, isNot, actual, outerErr) => (
|
||||
const makeThrowingMatcher = (matcher, isNot, promise, actual, err) =>
|
||||
function throwingMatcher(...args) {
|
||||
let throws = true;
|
||||
|
||||
const utils = _objectSpread({}, matcherUtils, {
|
||||
const utils = {
|
||||
...matcherUtils,
|
||||
iterableEquality: _utils.iterableEquality,
|
||||
subsetEquality: _utils.subsetEquality
|
||||
});
|
||||
|
||||
const matcherContext = _objectSpread(
|
||||
{
|
||||
// When throws is disabled, the matcher will not throw errors during test
|
||||
// execution but instead add them to the global matcher state. If a
|
||||
// matcher throws, test execution is normally stopped immediately. The
|
||||
// snapshot matcher uses it because we want to log all snapshot
|
||||
// failures in a test.
|
||||
dontThrow: () => (throws = false)
|
||||
},
|
||||
(0, _jestMatchersObject.getState)(),
|
||||
{
|
||||
equals: _jasmineUtils.equals,
|
||||
error: err,
|
||||
isNot,
|
||||
promise,
|
||||
utils
|
||||
}
|
||||
);
|
||||
};
|
||||
const matcherContext = {
|
||||
// When throws is disabled, the matcher will not throw errors during test
|
||||
// execution but instead add them to the global matcher state. If a
|
||||
// matcher throws, test execution is normally stopped immediately. The
|
||||
// snapshot matcher uses it because we want to log all snapshot
|
||||
// failures in a test.
|
||||
dontThrow: () => (throws = false),
|
||||
...(0, _jestMatchersObject.getState)(),
|
||||
equals: _jasmineUtils.equals,
|
||||
error: err,
|
||||
isNot,
|
||||
promise,
|
||||
utils
|
||||
};
|
||||
|
||||
const processResult = (result, asyncError) => {
|
||||
_validateResult(result);
|
||||
@@ -322,7 +316,7 @@ const makeThrowingMatcher = (matcher, isNot, promise, actual, err) =>
|
||||
}
|
||||
};
|
||||
|
||||
const handlError = error => {
|
||||
const handleError = error => {
|
||||
if (
|
||||
matcher[_jestMatchersObject.INTERNAL_MATCHER_FLAG] === true &&
|
||||
!(error instanceof JestAssertionError) &&
|
||||
@@ -339,7 +333,14 @@ const makeThrowingMatcher = (matcher, isNot, promise, actual, err) =>
|
||||
let potentialResult;
|
||||
|
||||
try {
|
||||
potentialResult = matcher.call(matcherContext, actual, ...args);
|
||||
potentialResult =
|
||||
matcher[_jestMatchersObject.INTERNAL_MATCHER_FLAG] === true
|
||||
? matcher.call(matcherContext, actual, ...args) // It's a trap specifically for inline snapshot to capture this name
|
||||
: // in the stack trace, so that it can correctly get the custom matcher
|
||||
// function call.
|
||||
(function __EXTERNAL_MATCHER_TRAP__() {
|
||||
return matcher.call(matcherContext, actual, ...args);
|
||||
})();
|
||||
|
||||
if (isPromise(potentialResult)) {
|
||||
const asyncResult = potentialResult;
|
||||
@@ -351,13 +352,13 @@ const makeThrowingMatcher = (matcher, isNot, promise, actual, err) =>
|
||||
|
||||
return asyncResult
|
||||
.then(aResult => processResult(aResult, asyncError))
|
||||
.catch(error => handlError(error));
|
||||
.catch(handleError);
|
||||
} else {
|
||||
const syncResult = potentialResult;
|
||||
return processResult(syncResult);
|
||||
}
|
||||
} catch (error) {
|
||||
return handlError(error);
|
||||
return handleError(error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -430,6 +431,5 @@ expect.getState = _jestMatchersObject.getState;
|
||||
expect.setState = _jestMatchersObject.setState;
|
||||
expect.extractExpectedAssertionsErrors =
|
||||
_extractExpectedAssertionsErrors.default;
|
||||
const expectExport = expect; // eslint-disable-next-line no-redeclare
|
||||
|
||||
const expectExport = expect;
|
||||
module.exports = expectExport;
|
||||
|
||||
Reference in New Issue
Block a user