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

221
node_modules/expect/build/asymmetric_matchers.js generated vendored Normal file
View File

@@ -0,0 +1,221 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.stringMatching = exports.stringContaining = exports.objectContaining = exports.arrayContaining = exports.anything = exports.any = undefined;
var _jasmine_utils = require('./jasmine_utils');
class AsymmetricMatcher {
constructor() {
this.$$typeof = Symbol.for('jest.asymmetricMatcher');
}
} /**
* 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.
*
*
*/
class Any extends AsymmetricMatcher {
constructor(sample) {
super();
if (typeof sample === 'undefined') {
throw new TypeError('any() expects to be passed a constructor function. ' + 'Please pass one or use anything() to match any object.');
}
this.sample = sample;
}
asymmetricMatch(other) {
if (this.sample == String) {
return typeof other == 'string' || other instanceof String;
}
if (this.sample == Number) {
return typeof other == 'number' || other instanceof Number;
}
if (this.sample == Function) {
return typeof other == 'function' || other instanceof Function;
}
if (this.sample == Object) {
return typeof other == 'object';
}
if (this.sample == Boolean) {
return typeof other == 'boolean';
}
return other instanceof this.sample;
}
toString() {
return 'Any';
}
getExpectedType() {
if (this.sample == String) {
return 'string';
}
if (this.sample == Number) {
return 'number';
}
if (this.sample == Function) {
return 'function';
}
if (this.sample == Object) {
return 'object';
}
if (this.sample == Boolean) {
return 'boolean';
}
return (0, _jasmine_utils.fnNameFor)(this.sample);
}
toAsymmetricMatcher() {
return 'Any<' + (0, _jasmine_utils.fnNameFor)(this.sample) + '>';
}
}
class Anything extends AsymmetricMatcher {
asymmetricMatch(other) {
return !(0, _jasmine_utils.isUndefined)(other) && other !== null;
}
toString() {
return 'Anything';
}
// No getExpectedType method, because it matches either null or undefined.
toAsymmetricMatcher() {
return 'Anything';
}
}
class ArrayContaining extends AsymmetricMatcher {
constructor(sample) {
super();
this.sample = sample;
}
asymmetricMatch(other) {
if (!Array.isArray(this.sample)) {
throw new Error("You must provide an array to ArrayContaining, not '" + typeof this.sample + "'.");
}
return this.sample.length === 0 || Array.isArray(other) && this.sample.every(item => other.some(another => (0, _jasmine_utils.equals)(item, another)));
}
toString() {
return 'ArrayContaining';
}
getExpectedType() {
return 'array';
}
}
class ObjectContaining extends AsymmetricMatcher {
constructor(sample) {
super();
this.sample = sample;
}
asymmetricMatch(other) {
if (typeof this.sample !== 'object') {
throw new Error("You must provide an object to ObjectContaining, not '" + typeof this.sample + "'.");
}
for (const property in this.sample) {
if (!(0, _jasmine_utils.hasProperty)(other, property) || !(0, _jasmine_utils.equals)(this.sample[property], other[property])) {
return false;
}
}
return true;
}
toString() {
return 'ObjectContaining';
}
getExpectedType() {
return 'object';
}
}
class StringContaining extends AsymmetricMatcher {
constructor(sample) {
super();
if (!(0, _jasmine_utils.isA)('String', sample)) {
throw new Error('Expected is not a string');
}
this.sample = sample;
}
asymmetricMatch(other) {
if (!(0, _jasmine_utils.isA)('String', other)) {
return false;
}
return other.includes(this.sample);
}
toString() {
return 'StringContaining';
}
getExpectedType() {
return 'string';
}
}
class StringMatching extends AsymmetricMatcher {
constructor(sample) {
super();
if (!(0, _jasmine_utils.isA)('String', sample) && !(0, _jasmine_utils.isA)('RegExp', sample)) {
throw new Error('Expected is not a String or a RegExp');
}
this.sample = new RegExp(sample);
}
asymmetricMatch(other) {
if (!(0, _jasmine_utils.isA)('String', other)) {
return false;
}
return this.sample.test(other);
}
toString() {
return 'StringMatching';
}
getExpectedType() {
return 'string';
}
}
const any = exports.any = expectedObject => new Any(expectedObject);
const anything = exports.anything = () => new Anything();
const arrayContaining = exports.arrayContaining = sample => new ArrayContaining(sample);
const objectContaining = exports.objectContaining = sample => new ObjectContaining(sample);
const stringContaining = exports.stringContaining = expected => new StringContaining(expected);
const stringMatching = exports.stringMatching = expected => new StringMatching(expected);

View File

@@ -0,0 +1,69 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _jestMatcherUtils = require('jest-matcher-utils');
var _jest_matchers_object = require('./jest_matchers_object');
/**
* 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 resetAssertionsLocalState = () => {
(0, _jest_matchers_object.setState)({
assertionCalls: 0,
expectedAssertionsNumber: null,
isExpectingAssertions: false
});
};
// Create and format all errors related to the mismatched number of `expect`
// calls and reset the matchers state.
const extractExpectedAssertionsErrors = () => {
const result = [];
var _getState = (0, _jest_matchers_object.getState)();
const assertionCalls = _getState.assertionCalls,
expectedAssertionsNumber = _getState.expectedAssertionsNumber,
isExpectingAssertions = _getState.isExpectingAssertions;
resetAssertionsLocalState();
if (typeof expectedAssertionsNumber === 'number' && assertionCalls !== expectedAssertionsNumber) {
const numOfAssertionsExpected = (0, _jestMatcherUtils.EXPECTED_COLOR)((0, _jestMatcherUtils.pluralize)('assertion', expectedAssertionsNumber));
const error = new Error((0, _jestMatcherUtils.matcherHint)('.assertions', '', String(expectedAssertionsNumber), {
isDirectExpectCall: true
}) + '\n\n' + `Expected ${numOfAssertionsExpected} to be called but received ` + (0, _jestMatcherUtils.RECEIVED_COLOR)((0, _jestMatcherUtils.pluralize)('assertion call', assertionCalls || 0)) + '.');
result.push({
actual: assertionCalls,
error,
expected: expectedAssertionsNumber
});
}
if (isExpectingAssertions && assertionCalls === 0) {
const expected = (0, _jestMatcherUtils.EXPECTED_COLOR)('at least one assertion');
const received = (0, _jestMatcherUtils.RECEIVED_COLOR)('received none');
const error = new Error((0, _jestMatcherUtils.matcherHint)('.hasAssertions', '', '', {
isDirectExpectCall: true
}) + '\n\n' + `Expected ${expected} to be called but ${received}.`);
result.push({
actual: 'none',
error,
expected: 'at least one'
});
}
return result;
};
exports.default = extractExpectedAssertionsErrors;

24
node_modules/expect/build/fake_chalk.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
var _ansiStyles = require('ansi-styles');
var _ansiStyles2 = _interopRequireDefault(_ansiStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const returnInput = str => str; /**
* 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 allColorsAsFunc = Object.keys(_ansiStyles2.default).map(style => ({ [style]: returnInput })).reduce((acc, cur) => Object.assign(acc, cur));
Object.keys(allColorsAsFunc).map(color => allColorsAsFunc[color]).forEach(style => {
Object.assign(style, allColorsAsFunc);
Object.assign(returnInput, style);
});
module.exports = allColorsAsFunc;

217
node_modules/expect/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,217 @@
'use strict';
var _jestMatcherUtils = require('jest-matcher-utils');
var utils = _interopRequireWildcard(_jestMatcherUtils);
var _matchers = require('./matchers');
var _matchers2 = _interopRequireDefault(_matchers);
var _spy_matchers = require('./spy_matchers');
var _spy_matchers2 = _interopRequireDefault(_spy_matchers);
var _to_throw_matchers = require('./to_throw_matchers');
var _to_throw_matchers2 = _interopRequireDefault(_to_throw_matchers);
var _jasmine_utils = require('./jasmine_utils');
var _asymmetric_matchers = require('./asymmetric_matchers');
var _jest_matchers_object = require('./jest_matchers_object');
var _extract_expected_assertions_errors = require('./extract_expected_assertions_errors');
var _extract_expected_assertions_errors2 = _interopRequireDefault(_extract_expected_assertions_errors);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
class JestAssertionError extends Error {} /**
* 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 isPromise = obj => {
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
};
const createToThrowErrorMatchingSnapshotMatcher = function (matcher) {
return function (received, testName) {
return matcher.apply(this, [received, testName, true]);
};
};
const getPromiseMatcher = (name, matcher) => {
if (name === 'toThrow' || name === 'toThrowError') {
return (0, _to_throw_matchers.createMatcher)('.' + name, true);
} else if (name === 'toThrowErrorMatchingSnapshot') {
return createToThrowErrorMatchingSnapshotMatcher(matcher);
}
return null;
};
const expect = function (actual) {
if ((arguments.length <= 1 ? 0 : arguments.length - 1) !== 0) {
throw new Error('Expect takes at most one argument.');
}
const allMatchers = (0, _jest_matchers_object.getMatchers)();
const expectation = {
not: {},
rejects: { not: {} },
resolves: { not: {} }
};
Object.keys(allMatchers).forEach(name => {
const matcher = allMatchers[name];
const promiseMatcher = getPromiseMatcher(name, matcher) || matcher;
expectation[name] = makeThrowingMatcher(matcher, false, actual);
expectation.not[name] = makeThrowingMatcher(matcher, true, actual);
expectation.resolves[name] = makeResolveMatcher(name, promiseMatcher, false, actual);
expectation.resolves.not[name] = makeResolveMatcher(name, promiseMatcher, true, actual);
expectation.rejects[name] = makeRejectMatcher(name, promiseMatcher, false, actual);
expectation.rejects.not[name] = makeRejectMatcher(name, matcher, true, actual);
});
return expectation;
};
const getMessage = message => {
return message && message() || utils.RECEIVED_COLOR('No message was specified for this matcher.');
};
const makeResolveMatcher = (matcherName, matcher, isNot, actual) => function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
const matcherStatement = `.resolves.${isNot ? 'not.' : ''}${matcherName}`;
if (!isPromise(actual)) {
throw new JestAssertionError(utils.matcherHint(matcherStatement, 'received', '') + '\n\n' + `${utils.RECEIVED_COLOR('received')} value must be a Promise.\n` + utils.printWithType('Received', actual, utils.printReceived));
}
return actual.then(result => makeThrowingMatcher(matcher, isNot, result).apply(null, args), reason => {
const err = new JestAssertionError(utils.matcherHint(matcherStatement, 'received', '') + '\n\n' + `Expected ${utils.RECEIVED_COLOR('received')} Promise to resolve, ` + 'instead it rejected to value\n' + ` ${utils.printReceived(reason)}`);
return Promise.reject(err);
});
};
const makeRejectMatcher = (matcherName, matcher, isNot, actual) => function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
const matcherStatement = `.rejects.${isNot ? 'not.' : ''}${matcherName}`;
if (!isPromise(actual)) {
throw new JestAssertionError(utils.matcherHint(matcherStatement, 'received', '') + '\n\n' + `${utils.RECEIVED_COLOR('received')} value must be a Promise.\n` + utils.printWithType('Received', actual, utils.printReceived));
}
return actual.then(result => {
const err = new JestAssertionError(utils.matcherHint(matcherStatement, 'received', '') + '\n\n' + `Expected ${utils.RECEIVED_COLOR('received')} Promise to reject, ` + 'instead it resolved to value\n' + ` ${utils.printReceived(result)}`);
return Promise.reject(err);
}, reason => makeThrowingMatcher(matcher, isNot, reason).apply(null, args));
};
const makeThrowingMatcher = (matcher, isNot, actual) => {
return function throwingMatcher() {
let throws = true;
const matcherContext = Object.assign(
// 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, _jest_matchers_object.getState)(), {
equals: _jasmine_utils.equals,
isNot,
utils
});
let result;
try {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
result = matcher.apply(matcherContext, [actual].concat(args));
} catch (error) {
if (matcher[_jest_matchers_object.INTERNAL_MATCHER_FLAG] === true && !(error instanceof JestAssertionError) && error.name !== 'PrettyFormatPluginError' &&
// Guard for some environments (browsers) that do not support this feature.
Error.captureStackTrace) {
// Try to remove this and deeper functions from the stack trace frame.
Error.captureStackTrace(error, throwingMatcher);
}
throw error;
}
_validateResult(result);
(0, _jest_matchers_object.getState)().assertionCalls++;
if (result.pass && isNot || !result.pass && !isNot) {
// XOR
const message = getMessage(result.message);
const error = new JestAssertionError(message);
// Passing the result of the matcher with the error so that a custom
// reporter could access the actual and expected objects of the result
// for example in order to display a custom visual diff
error.matcherResult = result;
// Try to remove this function from the stack trace frame.
// Guard for some environments (browsers) that do not support this feature.
if (Error.captureStackTrace) {
Error.captureStackTrace(error, throwingMatcher);
}
if (throws) {
throw error;
} else {
(0, _jest_matchers_object.getState)().suppressedErrors.push(error);
}
}
};
};
expect.extend = matchers => (0, _jest_matchers_object.setMatchers)(matchers, false);
expect.anything = _asymmetric_matchers.anything;
expect.any = _asymmetric_matchers.any;
expect.objectContaining = _asymmetric_matchers.objectContaining;
expect.arrayContaining = _asymmetric_matchers.arrayContaining;
expect.stringContaining = _asymmetric_matchers.stringContaining;
expect.stringMatching = _asymmetric_matchers.stringMatching;
const _validateResult = result => {
if (typeof result !== 'object' || typeof result.pass !== 'boolean' || result.message && typeof result.message !== 'string' && typeof result.message !== 'function') {
throw new Error('Unexpected return from a matcher function.\n' + 'Matcher functions should ' + 'return an object in the following format:\n' + ' {message?: string | function, pass: boolean}\n' + `'${utils.stringify(result)}' was returned`);
}
};
// add default jest matchers
(0, _jest_matchers_object.setMatchers)(_matchers2.default, true);
(0, _jest_matchers_object.setMatchers)(_spy_matchers2.default, true);
(0, _jest_matchers_object.setMatchers)(_to_throw_matchers2.default, true);
expect.addSnapshotSerializer = () => void 0;
expect.assertions = expected => {
(0, _jest_matchers_object.getState)().expectedAssertionsNumber = expected;
};
expect.hasAssertions = expected => {
utils.ensureNoExpected(expected, '.hasAssertions');
(0, _jest_matchers_object.getState)().isExpectingAssertions = true;
};
expect.getState = _jest_matchers_object.getState;
expect.setState = _jest_matchers_object.setState;
expect.extractExpectedAssertionsErrors = _extract_expected_assertions_errors2.default;
module.exports = expect;

291
node_modules/expect/build/jasmine_utils.js generated vendored Normal file
View File

@@ -0,0 +1,291 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.equals = equals;
exports.isA = isA;
exports.fnNameFor = fnNameFor;
exports.isUndefined = isUndefined;
exports.hasProperty = hasProperty;
exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed;
exports.isImmutableUnorderedSet = isImmutableUnorderedSet;
// Extracted out of jasmine 2.5.2
function equals(a, b, customTesters) {
customTesters = customTesters || [];
return eq(a, b, [], [], customTesters);
} /*
Copyright (c) 2008-2016 Pivotal Labs
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.
*/
/* eslint-disable */
function isAsymmetric(obj) {
return obj && isA('Function', obj.asymmetricMatch);
}
function asymmetricMatch(a, b) {
var asymmetricA = isAsymmetric(a),
asymmetricB = isAsymmetric(b);
if (asymmetricA && asymmetricB) {
return undefined;
}
if (asymmetricA) {
return a.asymmetricMatch(b);
}
if (asymmetricB) {
return b.asymmetricMatch(a);
}
}
// Equality function lovingly adapted from isEqual in
// [Underscore](http://underscorejs.org)
function eq(a, b, aStack, bStack, customTesters) {
var result = true;
var asymmetricResult = asymmetricMatch(a, b);
if (asymmetricResult !== undefined) {
return asymmetricResult;
}
for (var i = 0; i < customTesters.length; i++) {
var customTesterResult = customTesters[i](a, b);
if (customTesterResult !== undefined) {
return customTesterResult;
}
}
if (a instanceof Error && b instanceof Error) {
return a.message == b.message;
}
if (Object.is(a, b)) {
return true;
}
// A strict comparison is necessary because `null == undefined`.
if (a === null || b === null) {
return a === b;
}
var className = Object.prototype.toString.call(a);
if (className != Object.prototype.toString.call(b)) {
return false;
}
switch (className) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return a == String(b);
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
return a != +a ? b != +b : a === 0 ? 1 / a == 1 / b : a == +b;
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a == +b;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') {
return false;
}
var aIsDomNode = isDomNode(a);
var bIsDomNode = isDomNode(b);
if (aIsDomNode && bIsDomNode) {
// At first try to use DOM3 method isEqualNode
if (a.isEqualNode) {
return a.isEqualNode(b);
}
// IE8 doesn't support isEqualNode, try to use outerHTML && innerText
var aIsElement = a instanceof Element;
var bIsElement = b instanceof Element;
if (aIsElement && bIsElement) {
return a.outerHTML == b.outerHTML;
}
if (aIsElement || bIsElement) {
return false;
}
return a.innerText == b.innerText && a.textContent == b.textContent;
}
if (aIsDomNode || bIsDomNode) {
return false;
}
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (aStack[length] == a) {
return bStack[length] == b;
}
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
bStack.push(b);
var size = 0;
// Recursively compare objects and arrays.
// Compare array lengths to determine if a deep comparison is necessary.
if (className == '[object Array]') {
size = a.length;
if (size !== b.length) {
return false;
}
while (size--) {
result = eq(a[size], b[size], aStack, bStack, customTesters);
if (!result) {
return false;
}
}
}
// Deep compare objects.
var aKeys = keys(a, className == '[object Array]'),
key;
size = aKeys.length;
// Ensure that both objects contain the same number of properties before comparing deep equality.
if (keys(b, className == '[object Array]').length !== size) {
return false;
}
while (size--) {
key = aKeys[size];
// Deep compare each member
result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters);
if (!result) {
return false;
}
}
// Remove the first object from the stack of traversed objects.
aStack.pop();
bStack.pop();
return result;
}
function keys(obj, isArray) {
var allKeys = function (o) {
var keys = [];
for (var key in o) {
if (has(o, key)) {
keys.push(key);
}
}
return keys.concat(Object.getOwnPropertySymbols(o));
}(obj);
if (!isArray) {
return allKeys;
}
var extraKeys = [];
if (allKeys.length === 0) {
return allKeys;
}
for (var x = 0; x < allKeys.length; x++) {
if (!allKeys[x].match(/^[0-9]+$/)) {
extraKeys.push(allKeys[x]);
}
}
return extraKeys;
}
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined;
}
function isA(typeName, value) {
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
}
function isDomNode(obj) {
return obj.nodeType > 0;
}
function fnNameFor(func) {
if (func.name) {
return func.name;
}
const matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
return matches ? matches[1] : '<anonymous>';
}
function isUndefined(obj) {
return obj === void 0;
}
function getPrototype(obj) {
if (Object.getPrototypeOf) {
return Object.getPrototypeOf(obj);
}
if (obj.constructor.prototype == obj) {
return null;
}
return obj.constructor.prototype;
}
function hasProperty(obj, property) {
if (!obj) {
return false;
}
if (Object.prototype.hasOwnProperty.call(obj, property)) {
return true;
}
return hasProperty(getPrototype(obj), property);
}
// SENTINEL constants are from https://github.com/facebook/immutable-js
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
function isImmutableUnorderedKeyed(maybeKeyed) {
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL] && !maybeKeyed[IS_ORDERED_SENTINEL]);
}
function isImmutableUnorderedSet(maybeSet) {
return !!(maybeSet && maybeSet[IS_SET_SENTINEL] && !maybeSet[IS_ORDERED_SENTINEL]);
}

56
node_modules/expect/build/jest_matchers_object.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
// Global matchers object holds the list of available matchers and
// the state, that can hold matcher specific values that change over time.
const JEST_MATCHERS_OBJECT = Symbol.for('$$jest-matchers-object');
// Notes a built-in/internal Jest matcher.
// Jest may override the stack trace of Errors thrown by internal matchers.
/**
* 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 INTERNAL_MATCHER_FLAG = exports.INTERNAL_MATCHER_FLAG = Symbol.for('$$jest-internal-matcher');
if (!global[JEST_MATCHERS_OBJECT]) {
Object.defineProperty(global, JEST_MATCHERS_OBJECT, {
value: {
matchers: Object.create(null),
state: {
assertionCalls: 0,
expectedAssertionsNumber: null,
isExpectingAssertions: false,
suppressedErrors: [] // errors that are not thrown immediately.
}
}
});
}
const getState = exports.getState = () => global[JEST_MATCHERS_OBJECT].state;
const setState = exports.setState = state => {
Object.assign(global[JEST_MATCHERS_OBJECT].state, state);
};
const getMatchers = exports.getMatchers = () => global[JEST_MATCHERS_OBJECT].matchers;
const setMatchers = exports.setMatchers = (matchers, isInternal) => {
Object.keys(matchers).forEach(key => {
const matcher = matchers[key];
Object.defineProperty(matcher, INTERNAL_MATCHER_FLAG, {
value: isInternal
});
});
Object.assign(global[JEST_MATCHERS_OBJECT].matchers, matchers);
};

304
node_modules/expect/build/matchers.js generated vendored Normal file
View File

@@ -0,0 +1,304 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _jestDiff = require('jest-diff');
var _jestDiff2 = _interopRequireDefault(_jestDiff);
var _jestGetType = require('jest-get-type');
var _jestGetType2 = _interopRequireDefault(_jestGetType);
var _jestRegexUtil = require('jest-regex-util');
var _jestMatcherUtils = require('jest-matcher-utils');
var _utils = require('./utils');
var _jasmine_utils = require('./jasmine_utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const matchers = {
toBe(received, expected) {
const comment = 'Object.is equality';
const pass = Object.is(received, expected);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBe', undefined, undefined, {
comment
}) + '\n\n' + `Expected value to not be:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}` : () => {
const suggestToEqual = (0, _jestGetType2.default)(received) === (0, _jestGetType2.default)(expected) && ((0, _jestGetType2.default)(received) === 'object' || (0, _jestGetType2.default)(expected) === 'array') && (0, _jasmine_utils.equals)(received, expected, [_utils.iterableEquality]);
const diffString = (0, _jestDiff2.default)(expected, received, {
expand: this.expand
});
return (0, _jestMatcherUtils.matcherHint)('.toBe', undefined, undefined, {
comment
}) + '\n\n' + `Expected value to be:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}` + (diffString ? `\n\nDifference:\n\n${diffString}` : '') + (suggestToEqual ? ` ${_jestMatcherUtils.SUGGEST_TO_EQUAL}` : '');
};
// Passing the the actual and expected objects so that a custom reporter
// could access them, for example in order to display a custom visual diff,
// or create a different error message
return { actual: received, expected, message, name: 'toBe', pass };
},
toBeCloseTo(actual, expected) {
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
const secondArgument = arguments.length === 3 ? 'precision' : null;
(0, _jestMatcherUtils.ensureNumbers)(actual, expected, '.toBeCloseTo');
const pass = Math.abs(expected - actual) < Math.pow(10, -precision) / 2;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeCloseTo', undefined, undefined, {
secondArgument
}) + '\n\n' + `Expected value not to be close to (with ${(0, _jestMatcherUtils.printExpected)(precision)}-digit precision):\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeCloseTo', undefined, undefined, {
secondArgument
}) + '\n\n' + `Expected value to be close to (with ${(0, _jestMatcherUtils.printExpected)(precision)}-digit precision):\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeDefined(actual, expected) {
(0, _jestMatcherUtils.ensureNoExpected)(expected, '.toBeDefined');
const pass = actual !== void 0;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeDefined', 'received', '') + '\n\n' + `Expected value not to be defined, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeDefined', 'received', '') + '\n\n' + `Expected value to be defined, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeFalsy(actual, expected) {
(0, _jestMatcherUtils.ensureNoExpected)(expected, '.toBeFalsy');
const pass = !actual;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeFalsy', 'received', '') + '\n\n' + `Expected value not to be falsy, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeFalsy', 'received', '') + '\n\n' + `Expected value to be falsy, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeGreaterThan(actual, expected) {
(0, _jestMatcherUtils.ensureNumbers)(actual, expected, '.toBeGreaterThan');
const pass = actual > expected;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeGreaterThan') + '\n\n' + `Expected value not to be greater than:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeGreaterThan') + '\n\n' + `Expected value to be greater than:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeGreaterThanOrEqual(actual, expected) {
(0, _jestMatcherUtils.ensureNumbers)(actual, expected, '.toBeGreaterThanOrEqual');
const pass = actual >= expected;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeGreaterThanOrEqual') + '\n\n' + `Expected value not to be greater than or equal:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeGreaterThanOrEqual') + '\n\n' + `Expected value to be greater than or equal:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeInstanceOf(received, constructor) {
const constType = (0, _jestGetType2.default)(constructor);
if (constType !== 'function') {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toBeInstanceOf', 'value', 'constructor') + `\n\n` + `Expected constructor to be a function. Instead got:\n` + ` ${(0, _jestMatcherUtils.printExpected)(constType)}`);
}
const pass = received instanceof constructor;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeInstanceOf', 'value', 'constructor') + '\n\n' + `Expected value not to be an instance of:\n` + ` ${(0, _jestMatcherUtils.printExpected)(constructor.name || constructor)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}\n` : () => (0, _jestMatcherUtils.matcherHint)('.toBeInstanceOf', 'value', 'constructor') + '\n\n' + `Expected value to be an instance of:\n` + ` ${(0, _jestMatcherUtils.printExpected)(constructor.name || constructor)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}\n` + `Constructor:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received.constructor && received.constructor.name)}`;
return { message, pass };
},
toBeLessThan(actual, expected) {
(0, _jestMatcherUtils.ensureNumbers)(actual, expected, '.toBeLessThan');
const pass = actual < expected;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeLessThan') + '\n\n' + `Expected value not to be less than:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeLessThan') + '\n\n' + `Expected value to be less than:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeLessThanOrEqual(actual, expected) {
(0, _jestMatcherUtils.ensureNumbers)(actual, expected, '.toBeLessThanOrEqual');
const pass = actual <= expected;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeLessThanOrEqual') + '\n\n' + `Expected value not to be less than or equal:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeLessThanOrEqual') + '\n\n' + `Expected value to be less than or equal:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeNaN(actual, expected) {
(0, _jestMatcherUtils.ensureNoExpected)(expected, '.toBeNaN');
const pass = Number.isNaN(actual);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeNaN', 'received', '') + '\n\n' + `Expected value not to be NaN, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeNaN', 'received', '') + '\n\n' + `Expected value to be NaN, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeNull(actual, expected) {
(0, _jestMatcherUtils.ensureNoExpected)(expected, '.toBeNull');
const pass = actual === null;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeNull', 'received', '') + '\n\n' + `Expected value not to be null, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeNull', 'received', '') + '\n\n' + `Expected value to be null, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeTruthy(actual, expected) {
(0, _jestMatcherUtils.ensureNoExpected)(expected, '.toBeTruthy');
const pass = !!actual;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeTruthy', 'received', '') + '\n\n' + `Expected value not to be truthy, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeTruthy', 'received', '') + '\n\n' + `Expected value to be truthy, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toBeUndefined(actual, expected) {
(0, _jestMatcherUtils.ensureNoExpected)(expected, '.toBeUndefined');
const pass = actual === void 0;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toBeUndefined', 'received', '') + '\n\n' + `Expected value not to be undefined, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}` : () => (0, _jestMatcherUtils.matcherHint)('.toBeUndefined', 'received', '') + '\n\n' + `Expected value to be undefined, instead received\n` + ` ${(0, _jestMatcherUtils.printReceived)(actual)}`;
return { message, pass };
},
toContain(collection, value) {
const collectionType = (0, _jestGetType2.default)(collection);
let converted = null;
if (Array.isArray(collection) || typeof collection === 'string') {
// strings have `indexOf` so we don't need to convert
// arrays have `indexOf` and we don't want to make a copy
converted = collection;
} else {
try {
converted = Array.from(collection);
} catch (e) {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toContainEqual', 'collection', 'value') + '\n\n' + `Expected ${(0, _jestMatcherUtils.RECEIVED_COLOR)('collection')} to be an array-like structure.\n` + (0, _jestMatcherUtils.printWithType)('Received', collection, _jestMatcherUtils.printReceived));
}
}
// At this point, we're either a string or an Array,
// which was converted from an array-like structure.
const pass = converted.indexOf(value) != -1;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toContain', collectionType, 'value') + '\n\n' + `Expected ${collectionType}:\n` + ` ${(0, _jestMatcherUtils.printReceived)(collection)}\n` + `Not to contain value:\n` + ` ${(0, _jestMatcherUtils.printExpected)(value)}\n` : () => (0, _jestMatcherUtils.matcherHint)('.toContain', collectionType, 'value') + '\n\n' + `Expected ${collectionType}:\n` + ` ${(0, _jestMatcherUtils.printReceived)(collection)}\n` + `To contain value:\n` + ` ${(0, _jestMatcherUtils.printExpected)(value)}`;
return { message, pass };
},
toContainEqual(collection, value) {
const collectionType = (0, _jestGetType2.default)(collection);
let converted = null;
if (Array.isArray(collection)) {
converted = collection;
} else {
try {
converted = Array.from(collection);
} catch (e) {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toContainEqual', 'collection', 'value') + '\n\n' + `Expected ${(0, _jestMatcherUtils.RECEIVED_COLOR)('collection')} to be an array-like structure.\n` + (0, _jestMatcherUtils.printWithType)('Received', collection, _jestMatcherUtils.printReceived));
}
}
const pass = converted.findIndex(item => (0, _jasmine_utils.equals)(item, value, [_utils.iterableEquality])) !== -1;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toContainEqual', collectionType, 'value') + '\n\n' + `Expected ${collectionType}:\n` + ` ${(0, _jestMatcherUtils.printReceived)(collection)}\n` + `Not to contain a value equal to:\n` + ` ${(0, _jestMatcherUtils.printExpected)(value)}\n` : () => (0, _jestMatcherUtils.matcherHint)('.toContainEqual', collectionType, 'value') + '\n\n' + `Expected ${collectionType}:\n` + ` ${(0, _jestMatcherUtils.printReceived)(collection)}\n` + `To contain a value equal to:\n` + ` ${(0, _jestMatcherUtils.printExpected)(value)}`;
return { message, pass };
},
toEqual(received, expected) {
const pass = (0, _jasmine_utils.equals)(received, expected, [_utils.iterableEquality]);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toEqual') + '\n\n' + `Expected value to not equal:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}` : () => {
const diffString = (0, _jestDiff2.default)(expected, received, {
expand: this.expand
});
return (0, _jestMatcherUtils.matcherHint)('.toEqual') + '\n\n' + `Expected value to equal:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}` + (diffString ? `\n\nDifference:\n\n${diffString}` : '');
};
// Passing the the actual and expected objects so that a custom reporter
// could access them, for example in order to display a custom visual diff,
// or create a different error message
return { actual: received, expected, message, name: 'toEqual', pass };
},
toHaveLength(received, length) {
if (typeof received !== 'string' && (!received || typeof received.length !== 'number')) {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toHaveLength', 'received', 'length') + '\n\n' + `Expected value to have a 'length' property that is a number. ` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}\n` + (received ? `received.length:\n ${(0, _jestMatcherUtils.printReceived)(received.length)}` : ''));
}
const pass = received.length === length;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toHaveLength', 'received', 'length') + '\n\n' + `Expected value to not have length:\n` + ` ${(0, _jestMatcherUtils.printExpected)(length)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}\n` + `received.length:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received.length)}` : () => (0, _jestMatcherUtils.matcherHint)('.toHaveLength', 'received', 'length') + '\n\n' + `Expected value to have length:\n` + ` ${(0, _jestMatcherUtils.printExpected)(length)}\n` + `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}\n` + `received.length:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received.length)}`;
return { message, pass };
},
toHaveProperty(object, keyPath, value) {
const valuePassed = arguments.length === 3;
const secondArgument = valuePassed ? 'value' : null;
if (!object && typeof object !== 'string' && typeof object !== 'number') {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toHaveProperty', 'object', 'path', {
secondArgument
}) + '\n\n' + `Expected ${(0, _jestMatcherUtils.RECEIVED_COLOR)('object')} to be an object. Received:\n` + ` ${(0, _jestGetType2.default)(object)}: ${(0, _jestMatcherUtils.printReceived)(object)}`);
}
const keyPathType = (0, _jestGetType2.default)(keyPath);
if (keyPathType !== 'string' && keyPathType !== 'array') {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toHaveProperty', 'object', 'path', {
secondArgument
}) + '\n\n' + `Expected ${(0, _jestMatcherUtils.EXPECTED_COLOR)('path')} to be a string or an array. Received:\n` + ` ${(0, _jestGetType2.default)(keyPath)}: ${(0, _jestMatcherUtils.printReceived)(keyPath)}`);
}
const result = (0, _utils.getPath)(object, keyPath);
const lastTraversedObject = result.lastTraversedObject,
hasEndProp = result.hasEndProp;
const pass = valuePassed ? (0, _jasmine_utils.equals)(result.value, value, [_utils.iterableEquality]) : hasEndProp;
const traversedPath = result.traversedPath.join('.');
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toHaveProperty', 'object', 'path', {
secondArgument
}) + '\n\n' + `Expected the object:\n` + ` ${(0, _jestMatcherUtils.printReceived)(object)}\n` + `Not to have a nested property:\n` + ` ${(0, _jestMatcherUtils.printExpected)(keyPath)}\n` + (valuePassed ? `With a value of:\n ${(0, _jestMatcherUtils.printExpected)(value)}\n` : '') : () => {
const diffString = valuePassed && hasEndProp ? (0, _jestDiff2.default)(value, result.value, { expand: this.expand }) : '';
return (0, _jestMatcherUtils.matcherHint)('.toHaveProperty', 'object', 'path', {
secondArgument
}) + '\n\n' + `Expected the object:\n` + ` ${(0, _jestMatcherUtils.printReceived)(object)}\n` + `To have a nested property:\n` + ` ${(0, _jestMatcherUtils.printExpected)(keyPath)}\n` + (valuePassed ? `With a value of:\n ${(0, _jestMatcherUtils.printExpected)(value)}\n` : '') + (hasEndProp ? `Received:\n` + ` ${(0, _jestMatcherUtils.printReceived)(result.value)}` + (diffString ? `\n\nDifference:\n\n${diffString}` : '') : traversedPath ? `Received:\n ${(0, _jestMatcherUtils.RECEIVED_COLOR)('object')}.${traversedPath}: ${(0, _jestMatcherUtils.printReceived)(lastTraversedObject)}` : '');
};
if (pass === undefined) {
throw new Error('pass must be initialized');
}
return { message, pass };
},
toMatch(received, expected) {
if (typeof received !== 'string') {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toMatch', 'string', 'expected') + '\n\n' + `${(0, _jestMatcherUtils.RECEIVED_COLOR)('string')} value must be a string.\n` + (0, _jestMatcherUtils.printWithType)('Received', received, _jestMatcherUtils.printReceived));
}
if (!(expected instanceof RegExp) && !(typeof expected === 'string')) {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toMatch', 'string', 'expected') + '\n\n' + `${(0, _jestMatcherUtils.EXPECTED_COLOR)('expected')} value must be a string or a regular expression.\n` + (0, _jestMatcherUtils.printWithType)('Expected', expected, _jestMatcherUtils.printExpected));
}
const pass = new RegExp(typeof expected === 'string' ? (0, _jestRegexUtil.escapeStrForRegex)(expected) : expected).test(received);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toMatch') + `\n\nExpected value not to match:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}` + `\nReceived:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}` : () => (0, _jestMatcherUtils.matcherHint)('.toMatch') + `\n\nExpected value to match:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}` + `\nReceived:\n` + ` ${(0, _jestMatcherUtils.printReceived)(received)}`;
return { message, pass };
},
toMatchObject(receivedObject, expectedObject) {
if (typeof receivedObject !== 'object' || receivedObject === null) {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toMatchObject', 'object', 'expected') + '\n\n' + `${(0, _jestMatcherUtils.RECEIVED_COLOR)('received')} value must be an object.\n` + (0, _jestMatcherUtils.printWithType)('Received', receivedObject, _jestMatcherUtils.printReceived));
}
if (typeof expectedObject !== 'object' || expectedObject === null) {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not].toMatchObject', 'object', 'expected') + '\n\n' + `${(0, _jestMatcherUtils.EXPECTED_COLOR)('expected')} value must be an object.\n` + (0, _jestMatcherUtils.printWithType)('Expected', expectedObject, _jestMatcherUtils.printExpected));
}
const pass = (0, _jasmine_utils.equals)(receivedObject, expectedObject, [_utils.iterableEquality, _utils.subsetEquality]);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not.toMatchObject') + `\n\nExpected value not to match object:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expectedObject)}` + `\nReceived:\n` + ` ${(0, _jestMatcherUtils.printReceived)(receivedObject)}` : () => {
const diffString = (0, _jestDiff2.default)(expectedObject, (0, _utils.getObjectSubset)(receivedObject, expectedObject), {
expand: this.expand
});
return (0, _jestMatcherUtils.matcherHint)('.toMatchObject') + `\n\nExpected value to match object:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expectedObject)}` + `\nReceived:\n` + ` ${(0, _jestMatcherUtils.printReceived)(receivedObject)}` + (diffString ? `\nDifference:\n${diffString}` : '');
};
return { message, pass };
}
}; /**
* 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.
*
*
*/
exports.default = matchers;

161
node_modules/expect/build/spy_matchers.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _jestMatcherUtils = require('jest-matcher-utils');
var _jasmine_utils = require('./jasmine_utils');
var _utils = require('./utils');
const CALL_PRINT_LIMIT = 3; /**
* 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 LAST_CALL_PRINT_LIMIT = 1;
const createToBeCalledMatcher = matcherName => (received, expected) => {
(0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName);
ensureMock(received, matcherName);
const receivedIsSpy = isSpy(received);
const type = receivedIsSpy ? 'spy' : 'mock function';
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
const count = receivedIsSpy ? received.calls.count() : received.mock.calls.length;
const calls = receivedIsSpy ? received.calls.all().map(x => x.args) : received.mock.calls;
const pass = count > 0;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + matcherName, receivedName, '') + '\n\n' + `Expected ${type} not to be called ` + formatReceivedCalls(calls, CALL_PRINT_LIMIT, { sameSentence: true }) : () => (0, _jestMatcherUtils.matcherHint)(matcherName, receivedName, '') + '\n\n' + `Expected ${type} to have been called.`;
return { message, pass };
};
const createToBeCalledWithMatcher = matcherName => function (received) {
for (var _len = arguments.length, expected = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
expected[_key - 1] = arguments[_key];
}
ensureMock(received, matcherName);
const receivedIsSpy = isSpy(received);
const type = receivedIsSpy ? 'spy' : 'mock function';
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
const calls = receivedIsSpy ? received.calls.all().map(x => x.args) : received.mock.calls;
var _partition = (0, _utils.partition)(calls, call => (0, _jasmine_utils.equals)(call, expected, [_utils.iterableEquality])),
_partition2 = _slicedToArray(_partition, 2);
const match = _partition2[0],
fail = _partition2[1];
const pass = match.length > 0;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + matcherName, receivedName) + '\n\n' + `Expected ${type} not to have been called with:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}` : () => (0, _jestMatcherUtils.matcherHint)(matcherName, receivedName) + '\n\n' + `Expected ${type} to have been called with:\n` + formatMismatchedCalls(fail, expected, CALL_PRINT_LIMIT);
return { message, pass };
};
const createLastCalledWithMatcher = matcherName => function (received) {
for (var _len2 = arguments.length, expected = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
expected[_key2 - 1] = arguments[_key2];
}
ensureMock(received, matcherName);
const receivedIsSpy = isSpy(received);
const type = receivedIsSpy ? 'spy' : 'mock function';
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
const calls = receivedIsSpy ? received.calls.all().map(x => x.args) : received.mock.calls;
const pass = (0, _jasmine_utils.equals)(calls[calls.length - 1], expected, [_utils.iterableEquality]);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + matcherName, receivedName) + '\n\n' + `Expected ${type} to not have been last called with:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expected)}` : () => (0, _jestMatcherUtils.matcherHint)(matcherName, receivedName) + '\n\n' + `Expected ${type} to have been last called with:\n` + formatMismatchedCalls(calls, expected, LAST_CALL_PRINT_LIMIT);
return { message, pass };
};
const spyMatchers = {
lastCalledWith: createLastCalledWithMatcher('.lastCalledWith'),
toBeCalled: createToBeCalledMatcher('.toBeCalled'),
toBeCalledWith: createToBeCalledWithMatcher('.toBeCalledWith'),
toHaveBeenCalled: createToBeCalledMatcher('.toHaveBeenCalled'),
toHaveBeenCalledTimes(received, expected) {
const matcherName = '.toHaveBeenCalledTimes';
(0, _jestMatcherUtils.ensureExpectedIsNumber)(expected, matcherName);
ensureMock(received, matcherName);
const receivedIsSpy = isSpy(received);
const type = receivedIsSpy ? 'spy' : 'mock function';
const receivedName = receivedIsSpy ? 'spy' : received.getMockName();
const count = receivedIsSpy ? received.calls.count() : received.mock.calls.length;
const pass = count === expected;
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + matcherName, receivedName, String(expected)) + `\n\n` + `Expected ${type} not to be called ` + `${(0, _jestMatcherUtils.EXPECTED_COLOR)((0, _jestMatcherUtils.pluralize)('time', expected))}, but it was` + ` called exactly ${(0, _jestMatcherUtils.RECEIVED_COLOR)((0, _jestMatcherUtils.pluralize)('time', count))}.` : () => (0, _jestMatcherUtils.matcherHint)(matcherName, receivedName, String(expected)) + '\n\n' + `Expected ${type} to have been called ` + `${(0, _jestMatcherUtils.EXPECTED_COLOR)((0, _jestMatcherUtils.pluralize)('time', expected))},` + ` but it was called ${(0, _jestMatcherUtils.RECEIVED_COLOR)((0, _jestMatcherUtils.pluralize)('time', count))}.`;
return { message, pass };
},
toHaveBeenCalledWith: createToBeCalledWithMatcher('.toHaveBeenCalledWith'),
toHaveBeenLastCalledWith: createLastCalledWithMatcher('.toHaveBeenLastCalledWith')
};
const isSpy = spy => spy.calls && typeof spy.calls.count === 'function';
const ensureMock = (mockOrSpy, matcherName) => {
if (!mockOrSpy || (mockOrSpy.calls === undefined || mockOrSpy.calls.all === undefined) && mockOrSpy._isMockFunction !== true) {
throw new Error((0, _jestMatcherUtils.matcherHint)('[.not]' + matcherName, 'jest.fn()', '') + '\n\n' + `${(0, _jestMatcherUtils.RECEIVED_COLOR)('jest.fn()')} value must be a mock function ` + `or spy.\n` + (0, _jestMatcherUtils.printWithType)('Received', mockOrSpy, _jestMatcherUtils.printReceived));
}
};
const getPrintedCalls = (calls, limit, sep, fn) => {
const result = [];
let i = calls.length;
while (--i >= 0 && --limit >= 0) {
result.push(fn(calls[i]));
}
return result.join(sep);
};
const formatReceivedCalls = (calls, limit, options) => {
if (calls.length) {
const but = options && options.sameSentence ? 'but' : 'But';
const count = calls.length - limit;
const printedCalls = getPrintedCalls(calls, limit, ', ', _jestMatcherUtils.printReceived);
return `${but} it was ${options && options.isLast ? 'last ' : ''}called ` + `with:\n ` + printedCalls + (count > 0 ? '\nand ' + (0, _jestMatcherUtils.RECEIVED_COLOR)((0, _jestMatcherUtils.pluralize)('more call', count)) + '.' : '');
} else {
return `But it was ${(0, _jestMatcherUtils.RECEIVED_COLOR)('not called')}.`;
}
};
const formatMismatchedCalls = (calls, expected, limit) => {
if (calls.length) {
return getPrintedCalls(calls, limit, '\n\n', formatMismatchedArgs.bind(null, expected));
} else {
return ` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + `But it was ${(0, _jestMatcherUtils.RECEIVED_COLOR)('not called')}.`;
}
};
const formatMismatchedArgs = (expected, received) => {
const length = Math.max(expected.length, received.length);
const printedArgs = [];
for (let i = 0; i < length; i++) {
if (!(0, _jasmine_utils.equals)(expected[i], received[i], [_utils.iterableEquality])) {
printedArgs.push(` ${(0, _jestMatcherUtils.printExpected)(expected[i])} as argument ${i + 1}, ` + `but it was called with ${(0, _jestMatcherUtils.printReceived)(received[i])}.`);
} else if (i >= expected.length) {
printedArgs.push(` Did not expect argument ${i + 1} ` + `but it was called with ${(0, _jestMatcherUtils.printReceived)(received[i])}.`);
}
}
return printedArgs.join('\n');
};
exports.default = spyMatchers;

121
node_modules/expect/build/to_throw_matchers.js generated vendored Normal file
View File

@@ -0,0 +1,121 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createMatcher = undefined;
var _jestGetType = require('jest-get-type');
var _jestGetType2 = _interopRequireDefault(_jestGetType);
var _jestRegexUtil = require('jest-regex-util');
var _jestMessageUtil = require('jest-message-util');
var _jestMatcherUtils = require('jest-matcher-utils');
var _jasmine_utils = require('./jasmine_utils');
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 createMatcher = exports.createMatcher = (matcherName, fromPromise) => (actual, expected) => {
const value = expected;
let error;
if (fromPromise) {
error = actual;
} else {
if (typeof actual !== 'function') {
throw new Error((0, _jestMatcherUtils.matcherHint)(matcherName, 'function', (0, _jestGetType2.default)(value)) + '\n\n' + 'Received value must be a function, but instead ' + `"${(0, _jestGetType2.default)(actual)}" was found`);
}
try {
actual();
} catch (e) {
error = e;
}
}
if (typeof expected === 'string') {
expected = new RegExp((0, _jestRegexUtil.escapeStrForRegex)(expected));
}
if (typeof expected === 'function') {
return toThrowMatchingError(matcherName, error, expected);
} else if (expected instanceof RegExp) {
return toThrowMatchingStringOrRegexp(matcherName, error, expected, value);
} else if (expected && typeof expected === 'object') {
return toThrowMatchingErrorInstance(matcherName, error, expected);
} else if (expected === undefined) {
const pass = error !== undefined;
return {
message: pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + matcherName, 'function', '') + '\n\n' + 'Expected the function not to throw an error.\n' + printActualErrorMessage(error) : () => (0, _jestMatcherUtils.matcherHint)(matcherName, 'function', (0, _jestGetType2.default)(value)) + '\n\n' + 'Expected the function to throw an error.\n' + printActualErrorMessage(error),
pass
};
} else {
throw new Error((0, _jestMatcherUtils.matcherHint)('.not' + matcherName, 'function', (0, _jestGetType2.default)(value)) + '\n\n' + 'Unexpected argument passed.\nExpected: ' + `${(0, _jestMatcherUtils.printExpected)('string')}, ${(0, _jestMatcherUtils.printExpected)('Error (type)')} or ${(0, _jestMatcherUtils.printExpected)('regexp')}.\n` + (0, _jestMatcherUtils.printWithType)('Got', String(expected), _jestMatcherUtils.printExpected));
}
};
const matchers = {
toThrow: createMatcher('.toThrow'),
toThrowError: createMatcher('.toThrowError')
};
const toThrowMatchingStringOrRegexp = (name, error, pattern, value) => {
if (error && !error.message && !error.name) {
error = new Error(error);
}
const pass = !!(error && error.message.match(pattern));
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + name, 'function', (0, _jestGetType2.default)(value)) + '\n\n' + `Expected the function not to throw an error matching:\n` + ` ${(0, _jestMatcherUtils.printExpected)(value)}\n` + printActualErrorMessage(error) : () => (0, _jestMatcherUtils.matcherHint)(name, 'function', (0, _jestGetType2.default)(value)) + '\n\n' + `Expected the function to throw an error matching:\n` + ` ${(0, _jestMatcherUtils.printExpected)(value)}\n` + printActualErrorMessage(error);
return { message, pass };
};
const toThrowMatchingErrorInstance = (name, error, expectedError) => {
if (error && !error.message && !error.name) {
error = new Error(error);
}
const pass = (0, _jasmine_utils.equals)(error, expectedError);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + name, 'function', 'error') + '\n\n' + `Expected the function not to throw an error matching:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expectedError)}\n` + printActualErrorMessage(error) : () => (0, _jestMatcherUtils.matcherHint)(name, 'function', 'error') + '\n\n' + `Expected the function to throw an error matching:\n` + ` ${(0, _jestMatcherUtils.printExpected)(expectedError)}\n` + printActualErrorMessage(error);
return { message, pass };
};
const toThrowMatchingError = (name, error, ErrorClass) => {
const pass = !!(error && error instanceof ErrorClass);
const message = pass ? () => (0, _jestMatcherUtils.matcherHint)('.not' + name, 'function', 'type') + '\n\n' + `Expected the function not to throw an error of type:\n` + ` ${(0, _jestMatcherUtils.printExpected)(ErrorClass.name)}\n` + printActualErrorMessage(error) : () => (0, _jestMatcherUtils.matcherHint)(name, 'function', 'type') + '\n\n' + `Expected the function to throw an error of type:\n` + ` ${(0, _jestMatcherUtils.printExpected)(ErrorClass.name)}\n` + printActualErrorMessage(error);
return { message, pass };
};
const printActualErrorMessage = error => {
if (error) {
var _separateMessageFromS = (0, _jestMessageUtil.separateMessageFromStack)(error.stack);
const message = _separateMessageFromS.message,
stack = _separateMessageFromS.stack;
return `Instead, it threw:\n` + (0, _jestMatcherUtils.RECEIVED_COLOR)(' ' + (0, _jestMatcherUtils.highlightTrailingWhitespace)(message) + (0, _jestMessageUtil.formatStackTrace)(stack, {
rootDir: process.cwd(),
testMatch: []
}, {
noStackTrace: false
}));
}
return `But it didn't throw anything.`;
};
exports.default = matchers;

154
node_modules/expect/build/utils.js generated vendored Normal file
View File

@@ -0,0 +1,154 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.partition = exports.subsetEquality = exports.iterableEquality = exports.getObjectSubset = exports.getPath = exports.hasOwnProperty = undefined;
var _jasmine_utils = require('./jasmine_utils');
const hasOwnProperty = exports.hasOwnProperty = (object, value) => Object.prototype.hasOwnProperty.call(object, value) || Object.prototype.hasOwnProperty.call(object.constructor.prototype, value); /**
* 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 getPath = exports.getPath = (object, propertyPath) => {
if (!Array.isArray(propertyPath)) {
propertyPath = propertyPath.split('.');
}
if (propertyPath.length) {
const lastProp = propertyPath.length === 1;
const prop = propertyPath[0];
const newObject = object[prop];
if (!lastProp && (newObject === null || newObject === undefined)) {
// This is not the last prop in the chain. If we keep recursing it will
// hit a `can't access property X of undefined | null`. At this point we
// know that the chain has broken and we can return right away.
return {
hasEndProp: false,
lastTraversedObject: object,
traversedPath: []
};
}
const result = getPath(newObject, propertyPath.slice(1));
if (result.lastTraversedObject === null) {
result.lastTraversedObject = object;
}
result.traversedPath.unshift(prop);
if (lastProp) {
result.hasEndProp = hasOwnProperty(object, prop);
if (!result.hasEndProp) {
result.traversedPath.shift();
}
}
return result;
}
return {
lastTraversedObject: null,
traversedPath: [],
value: object
};
};
// Strip properties from object that are not present in the subset. Useful for
// printing the diff for toMatchObject() without adding unrelated noise.
const getObjectSubset = exports.getObjectSubset = (object, subset) => {
if (Array.isArray(object)) {
if (Array.isArray(subset) && subset.length === object.length) {
return subset.map((sub, i) => getObjectSubset(object[i], sub));
}
} else if (object instanceof Date) {
return object;
} else if (typeof object === 'object' && object !== null && typeof subset === 'object' && subset !== null) {
const trimmed = {};
Object.keys(subset).filter(key => hasOwnProperty(object, key)).forEach(key => trimmed[key] = getObjectSubset(object[key], subset[key]));
if (Object.keys(trimmed).length > 0) {
return trimmed;
}
}
return object;
};
const IteratorSymbol = Symbol.iterator;
const hasIterator = object => !!(object != null && object[IteratorSymbol]);
const iterableEquality = exports.iterableEquality = (a, b) => {
if (typeof a !== 'object' || typeof b !== 'object' || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) {
return undefined;
}
if (a.constructor !== b.constructor) {
return false;
}
if (a.size !== undefined) {
if (a.size !== b.size) {
return false;
} else if ((0, _jasmine_utils.isA)('Set', a) || (0, _jasmine_utils.isImmutableUnorderedSet)(a)) {
let allFound = true;
for (const aValue of a) {
if (!b.has(aValue)) {
allFound = false;
break;
}
}
if (allFound) {
return true;
}
} else if ((0, _jasmine_utils.isA)('Map', a) || (0, _jasmine_utils.isImmutableUnorderedKeyed)(a)) {
let allFound = true;
for (const aEntry of a) {
if (!b.has(aEntry[0]) || !(0, _jasmine_utils.equals)(aEntry[1], b.get(aEntry[0]), [iterableEquality])) {
allFound = false;
break;
}
}
if (allFound) {
return true;
}
}
}
const bIterator = b[IteratorSymbol]();
for (const aValue of a) {
const nextB = bIterator.next();
if (nextB.done || !(0, _jasmine_utils.equals)(aValue, nextB.value, [iterableEquality])) {
return false;
}
}
if (!bIterator.next().done) {
return false;
}
return true;
};
const isObjectWithKeys = a => a !== null && typeof a === 'object' && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
const subsetEquality = exports.subsetEquality = (object, subset) => {
if (!isObjectWithKeys(subset)) {
return undefined;
}
return Object.keys(subset).every(key => hasOwnProperty(object, key) && (0, _jasmine_utils.equals)(object[key], subset[key], [iterableEquality, subsetEquality]));
};
const partition = exports.partition = (items, predicate) => {
const result = [[], []];
items.forEach(item => result[predicate(item) ? 0 : 1].push(item));
return result;
};