diff options
| author | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
|---|---|---|
| committer | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
| commit | 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch) | |
| tree | 360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/expect/build | |
| parent | b500a50f1b97d93c98b36ed9a980f8188d648147 (diff) | |
| download | LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip  | |
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/expect/build')
22 files changed, 5700 insertions, 0 deletions
diff --git a/node_modules/expect/build/asymmetricMatchers.d.ts b/node_modules/expect/build/asymmetricMatchers.d.ts new file mode 100644 index 0000000..da50770 --- /dev/null +++ b/node_modules/expect/build/asymmetricMatchers.d.ts @@ -0,0 +1,75 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +import type { AsymmetricMatcher as AsymmetricMatcherInterface, MatcherState } from './types'; +export declare abstract class AsymmetricMatcher<T, State extends MatcherState = MatcherState> implements AsymmetricMatcherInterface { +    protected sample: T; +    protected inverse: boolean; +    $$typeof: symbol; +    constructor(sample: T, inverse?: boolean); +    protected getMatcherContext(): State; +    abstract asymmetricMatch(other: unknown): boolean; +    abstract toString(): string; +    getExpectedType?(): string; +    toAsymmetricMatcher?(): string; +} +declare class Any extends AsymmetricMatcher<any> { +    constructor(sample: unknown); +    asymmetricMatch(other: unknown): boolean; +    toString(): string; +    getExpectedType(): string; +    toAsymmetricMatcher(): string; +} +declare class Anything extends AsymmetricMatcher<void> { +    asymmetricMatch(other: unknown): boolean; +    toString(): string; +    toAsymmetricMatcher(): string; +} +declare class ArrayContaining extends AsymmetricMatcher<Array<unknown>> { +    constructor(sample: Array<unknown>, inverse?: boolean); +    asymmetricMatch(other: Array<unknown>): boolean; +    toString(): string; +    getExpectedType(): string; +} +declare class ObjectContaining extends AsymmetricMatcher<Record<string, unknown>> { +    constructor(sample: Record<string, unknown>, inverse?: boolean); +    asymmetricMatch(other: any): boolean; +    toString(): string; +    getExpectedType(): string; +} +declare class StringContaining extends AsymmetricMatcher<string> { +    constructor(sample: string, inverse?: boolean); +    asymmetricMatch(other: string): boolean; +    toString(): string; +    getExpectedType(): string; +} +declare class StringMatching extends AsymmetricMatcher<RegExp> { +    constructor(sample: string | RegExp, inverse?: boolean); +    asymmetricMatch(other: string): boolean; +    toString(): string; +    getExpectedType(): string; +} +declare class CloseTo extends AsymmetricMatcher<number> { +    private precision; +    constructor(sample: number, precision?: number, inverse?: boolean); +    asymmetricMatch(other: number): boolean; +    toString(): string; +    getExpectedType(): string; +} +export declare const any: (expectedObject: unknown) => Any; +export declare const anything: () => Anything; +export declare const arrayContaining: (sample: Array<unknown>) => ArrayContaining; +export declare const arrayNotContaining: (sample: Array<unknown>) => ArrayContaining; +export declare const objectContaining: (sample: Record<string, unknown>) => ObjectContaining; +export declare const objectNotContaining: (sample: Record<string, unknown>) => ObjectContaining; +export declare const stringContaining: (expected: string) => StringContaining; +export declare const stringNotContaining: (expected: string) => StringContaining; +export declare const stringMatching: (expected: string | RegExp) => StringMatching; +export declare const stringNotMatching: (expected: string | RegExp) => StringMatching; +export declare const closeTo: (expected: number, precision?: number | undefined) => CloseTo; +export declare const notCloseTo: (expected: number, precision?: number | undefined) => CloseTo; +export {}; diff --git a/node_modules/expect/build/asymmetricMatchers.js b/node_modules/expect/build/asymmetricMatchers.js new file mode 100644 index 0000000..ff3d093 --- /dev/null +++ b/node_modules/expect/build/asymmetricMatchers.js @@ -0,0 +1,432 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.stringNotMatching = +  exports.stringNotContaining = +  exports.stringMatching = +  exports.stringContaining = +  exports.objectNotContaining = +  exports.objectContaining = +  exports.notCloseTo = +  exports.closeTo = +  exports.arrayNotContaining = +  exports.arrayContaining = +  exports.anything = +  exports.any = +  exports.AsymmetricMatcher = +    void 0; + +var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils')); + +var _jasmineUtils = require('./jasmineUtils'); + +var _jestMatchersObject = require('./jestMatchersObject'); + +var _utils = require('./utils'); + +function _getRequireWildcardCache(nodeInterop) { +  if (typeof WeakMap !== 'function') return null; +  var cacheBabelInterop = new WeakMap(); +  var cacheNodeInterop = new WeakMap(); +  return (_getRequireWildcardCache = function (nodeInterop) { +    return nodeInterop ? cacheNodeInterop : cacheBabelInterop; +  })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { +  if (!nodeInterop && obj && obj.__esModule) { +    return obj; +  } +  if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { +    return {default: obj}; +  } +  var cache = _getRequireWildcardCache(nodeInterop); +  if (cache && cache.has(obj)) { +    return cache.get(obj); +  } +  var newObj = {}; +  var hasPropertyDescriptor = +    Object.defineProperty && Object.getOwnPropertyDescriptor; +  for (var key in obj) { +    if (key !== 'default' && 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; +  if (cache) { +    cache.set(obj, newObj); +  } +  return newObj; +} + +var global = (function () { +  if (typeof globalThis !== 'undefined') { +    return globalThis; +  } else if (typeof global !== 'undefined') { +    return global; +  } else if (typeof self !== 'undefined') { +    return self; +  } else if (typeof window !== 'undefined') { +    return window; +  } else { +    return Function('return this')(); +  } +})(); + +var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol; + +function _defineProperty(obj, key, value) { +  if (key in obj) { +    Object.defineProperty(obj, key, { +      value: value, +      enumerable: true, +      configurable: true, +      writable: true +    }); +  } else { +    obj[key] = value; +  } +  return obj; +} + +const utils = Object.freeze({ +  ...matcherUtils, +  iterableEquality: _utils.iterableEquality, +  subsetEquality: _utils.subsetEquality +}); + +class AsymmetricMatcher { +  constructor(sample, inverse = false) { +    _defineProperty(this, '$$typeof', Symbol.for('jest.asymmetricMatcher')); + +    this.sample = sample; +    this.inverse = inverse; +  } + +  getMatcherContext() { +    return { +      ...(0, _jestMatchersObject.getState)(), +      equals: _jasmineUtils.equals, +      isNot: this.inverse, +      utils +    }; +  } +} + +exports.AsymmetricMatcher = AsymmetricMatcher; + +class Any extends AsymmetricMatcher { +  constructor(sample) { +    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.' +      ); +    } + +    super(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 == Boolean) { +      return typeof other == 'boolean' || other instanceof Boolean; +    } + +    if (this.sample == BigInt) { +      return typeof other == 'bigint' || other instanceof BigInt; +    } + +    if (this.sample == Symbol) { +      return typeof other == 'symbol' || other instanceof Symbol; +    } + +    if (this.sample == Object) { +      return typeof other == 'object'; +    } + +    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, _jasmineUtils.fnNameFor)(this.sample); +  } + +  toAsymmetricMatcher() { +    return 'Any<' + (0, _jasmineUtils.fnNameFor)(this.sample) + '>'; +  } +} + +class Anything extends AsymmetricMatcher { +  asymmetricMatch(other) { +    return !(0, _jasmineUtils.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, inverse = false) { +    super(sample, inverse); +  } + +  asymmetricMatch(other) { +    if (!Array.isArray(this.sample)) { +      throw new Error( +        `You must provide an array to ${this.toString()}, not '` + +          typeof this.sample + +          "'." +      ); +    } + +    const result = +      this.sample.length === 0 || +      (Array.isArray(other) && +        this.sample.every(item => +          other.some(another => (0, _jasmineUtils.equals)(item, another)) +        )); +    return this.inverse ? !result : result; +  } + +  toString() { +    return `Array${this.inverse ? 'Not' : ''}Containing`; +  } + +  getExpectedType() { +    return 'array'; +  } +} + +class ObjectContaining extends AsymmetricMatcher { +  constructor(sample, inverse = false) { +    super(sample, inverse); +  } + +  asymmetricMatch(other) { +    if (typeof this.sample !== 'object') { +      throw new Error( +        `You must provide an object to ${this.toString()}, not '` + +          typeof this.sample + +          "'." +      ); +    } + +    let result = true; + +    for (const property in this.sample) { +      if ( +        !(0, _jasmineUtils.hasProperty)(other, property) || +        !(0, _jasmineUtils.equals)(this.sample[property], other[property]) +      ) { +        result = false; +        break; +      } +    } + +    return this.inverse ? !result : result; +  } + +  toString() { +    return `Object${this.inverse ? 'Not' : ''}Containing`; +  } + +  getExpectedType() { +    return 'object'; +  } +} + +class StringContaining extends AsymmetricMatcher { +  constructor(sample, inverse = false) { +    if (!(0, _jasmineUtils.isA)('String', sample)) { +      throw new Error('Expected is not a string'); +    } + +    super(sample, inverse); +  } + +  asymmetricMatch(other) { +    const result = +      (0, _jasmineUtils.isA)('String', other) && other.includes(this.sample); +    return this.inverse ? !result : result; +  } + +  toString() { +    return `String${this.inverse ? 'Not' : ''}Containing`; +  } + +  getExpectedType() { +    return 'string'; +  } +} + +class StringMatching extends AsymmetricMatcher { +  constructor(sample, inverse = false) { +    if ( +      !(0, _jasmineUtils.isA)('String', sample) && +      !(0, _jasmineUtils.isA)('RegExp', sample) +    ) { +      throw new Error('Expected is not a String or a RegExp'); +    } + +    super(new RegExp(sample), inverse); +  } + +  asymmetricMatch(other) { +    const result = +      (0, _jasmineUtils.isA)('String', other) && this.sample.test(other); +    return this.inverse ? !result : result; +  } + +  toString() { +    return `String${this.inverse ? 'Not' : ''}Matching`; +  } + +  getExpectedType() { +    return 'string'; +  } +} + +class CloseTo extends AsymmetricMatcher { +  constructor(sample, precision = 2, inverse = false) { +    if (!(0, _jasmineUtils.isA)('Number', sample)) { +      throw new Error('Expected is not a Number'); +    } + +    if (!(0, _jasmineUtils.isA)('Number', precision)) { +      throw new Error('Precision is not a Number'); +    } + +    super(sample); + +    _defineProperty(this, 'precision', void 0); + +    this.inverse = inverse; +    this.precision = precision; +  } + +  asymmetricMatch(other) { +    if (!(0, _jasmineUtils.isA)('Number', other)) { +      return false; +    } + +    let result = false; + +    if (other === Infinity && this.sample === Infinity) { +      result = true; // Infinity - Infinity is NaN +    } else if (other === -Infinity && this.sample === -Infinity) { +      result = true; // -Infinity - -Infinity is NaN +    } else { +      result = +        Math.abs(this.sample - other) < Math.pow(10, -this.precision) / 2; +    } + +    return this.inverse ? !result : result; +  } + +  toString() { +    return `Number${this.inverse ? 'Not' : ''}CloseTo`; +  } + +  getExpectedType() { +    return 'number'; +  } +} + +const any = expectedObject => new Any(expectedObject); + +exports.any = any; + +const anything = () => new Anything(); + +exports.anything = anything; + +const arrayContaining = sample => new ArrayContaining(sample); + +exports.arrayContaining = arrayContaining; + +const arrayNotContaining = sample => new ArrayContaining(sample, true); + +exports.arrayNotContaining = arrayNotContaining; + +const objectContaining = sample => new ObjectContaining(sample); + +exports.objectContaining = objectContaining; + +const objectNotContaining = sample => new ObjectContaining(sample, true); + +exports.objectNotContaining = objectNotContaining; + +const stringContaining = expected => new StringContaining(expected); + +exports.stringContaining = stringContaining; + +const stringNotContaining = expected => new StringContaining(expected, true); + +exports.stringNotContaining = stringNotContaining; + +const stringMatching = expected => new StringMatching(expected); + +exports.stringMatching = stringMatching; + +const stringNotMatching = expected => new StringMatching(expected, true); + +exports.stringNotMatching = stringNotMatching; + +const closeTo = (expected, precision) => new CloseTo(expected, precision); + +exports.closeTo = closeTo; + +const notCloseTo = (expected, precision) => +  new CloseTo(expected, precision, true); + +exports.notCloseTo = notCloseTo; diff --git a/node_modules/expect/build/extractExpectedAssertionsErrors.d.ts b/node_modules/expect/build/extractExpectedAssertionsErrors.d.ts new file mode 100644 index 0000000..03ccd3e --- /dev/null +++ b/node_modules/expect/build/extractExpectedAssertionsErrors.d.ts @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +import type { Expect } from './types'; +declare const extractExpectedAssertionsErrors: Expect['extractExpectedAssertionsErrors']; +export default extractExpectedAssertionsErrors; diff --git a/node_modules/expect/build/extractExpectedAssertionsErrors.js b/node_modules/expect/build/extractExpectedAssertionsErrors.js new file mode 100644 index 0000000..b3dcbdd --- /dev/null +++ b/node_modules/expect/build/extractExpectedAssertionsErrors.js @@ -0,0 +1,90 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +var _jestMatcherUtils = require('jest-matcher-utils'); + +var _jestMatchersObject = require('./jestMatchersObject'); + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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, _jestMatchersObject.setState)({ +    assertionCalls: 0, +    expectedAssertionsNumber: null, +    isExpectingAssertions: false +  }); +}; // Create and format all errors related to the mismatched number of `expect` +// calls and reset the matcher's state. + +const extractExpectedAssertionsErrors = () => { +  const result = []; +  const { +    assertionCalls, +    expectedAssertionsNumber, +    expectedAssertionsNumberError, +    isExpectingAssertions, +    isExpectingAssertionsError +  } = (0, _jestMatchersObject.getState)(); +  resetAssertionsLocalState(); + +  if ( +    typeof expectedAssertionsNumber === 'number' && +    assertionCalls !== expectedAssertionsNumber +  ) { +    const numOfAssertionsExpected = (0, _jestMatcherUtils.EXPECTED_COLOR)( +      (0, _jestMatcherUtils.pluralize)('assertion', expectedAssertionsNumber) +    ); +    expectedAssertionsNumberError.message = +      (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.toString(), +      error: expectedAssertionsNumberError, +      expected: expectedAssertionsNumber.toString() +    }); +  } + +  if (isExpectingAssertions && assertionCalls === 0) { +    const expected = (0, _jestMatcherUtils.EXPECTED_COLOR)( +      'at least one assertion' +    ); +    const received = (0, _jestMatcherUtils.RECEIVED_COLOR)('received none'); +    isExpectingAssertionsError.message = +      (0, _jestMatcherUtils.matcherHint)('.hasAssertions', '', '', { +        isDirectExpectCall: true +      }) + +      '\n\n' + +      `Expected ${expected} to be called but ${received}.`; +    result.push({ +      actual: 'none', +      error: isExpectingAssertionsError, +      expected: 'at least one' +    }); +  } + +  return result; +}; + +var _default = extractExpectedAssertionsErrors; +exports.default = _default; diff --git a/node_modules/expect/build/index.d.ts b/node_modules/expect/build/index.d.ts new file mode 100644 index 0000000..f8e44b9 --- /dev/null +++ b/node_modules/expect/build/index.d.ts @@ -0,0 +1,15 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +import type { Expect, MatcherState as JestMatcherState, Matchers as MatcherInterface } from './types'; +declare const expectExport: Expect<JestMatcherState>; +declare namespace expectExport { +    type MatcherState = JestMatcherState; +    interface Matchers<R, T = unknown> extends MatcherInterface<R, T> { +    } +} +export = expectExport; diff --git a/node_modules/expect/build/index.js b/node_modules/expect/build/index.js new file mode 100644 index 0000000..07ab2c9 --- /dev/null +++ b/node_modules/expect/build/index.js @@ -0,0 +1,485 @@ +'use strict'; + +var global = (function () { +  if (typeof globalThis !== 'undefined') { +    return globalThis; +  } else if (typeof global !== 'undefined') { +    return global; +  } else if (typeof self !== 'undefined') { +    return self; +  } else if (typeof window !== 'undefined') { +    return window; +  } else { +    return Function('return this')(); +  } +})(); + +var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol; + +var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils')); + +var _asymmetricMatchers = require('./asymmetricMatchers'); + +var _extractExpectedAssertionsErrors = _interopRequireDefault( +  require('./extractExpectedAssertionsErrors') +); + +var _jasmineUtils = require('./jasmineUtils'); + +var _jestMatchersObject = require('./jestMatchersObject'); + +var _matchers = _interopRequireDefault(require('./matchers')); + +var _spyMatchers = _interopRequireDefault(require('./spyMatchers')); + +var _toThrowMatchers = _interopRequireWildcard(require('./toThrowMatchers')); + +var _utils = require('./utils'); + +function _interopRequireDefault(obj) { +  return obj && obj.__esModule ? obj : {default: obj}; +} + +function _getRequireWildcardCache(nodeInterop) { +  if (typeof WeakMap !== 'function') return null; +  var cacheBabelInterop = new WeakMap(); +  var cacheNodeInterop = new WeakMap(); +  return (_getRequireWildcardCache = function (nodeInterop) { +    return nodeInterop ? cacheNodeInterop : cacheBabelInterop; +  })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { +  if (!nodeInterop && obj && obj.__esModule) { +    return obj; +  } +  if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { +    return {default: obj}; +  } +  var cache = _getRequireWildcardCache(nodeInterop); +  if (cache && cache.has(obj)) { +    return cache.get(obj); +  } +  var newObj = {}; +  var hasPropertyDescriptor = +    Object.defineProperty && Object.getOwnPropertyDescriptor; +  for (var key in obj) { +    if (key !== 'default' && 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; +  if (cache) { +    cache.set(obj, newObj); +  } +  return newObj; +} + +var global = (function () { +  if (typeof globalThis !== 'undefined') { +    return globalThis; +  } else if (typeof global !== 'undefined') { +    return global; +  } else if (typeof self !== 'undefined') { +    return self; +  } else if (typeof window !== 'undefined') { +    return window; +  } else { +    return Function('return this')(); +  } +})(); + +var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol; + +var global = (function () { +  if (typeof globalThis !== 'undefined') { +    return globalThis; +  } else if (typeof global !== 'undefined') { +    return global; +  } else if (typeof self !== 'undefined') { +    return self; +  } else if (typeof window !== 'undefined') { +    return window; +  } else { +    return Function('return this')(); +  } +})(); + +var Promise = global[Symbol.for('jest-native-promise')] || global.Promise; + +function _defineProperty(obj, key, value) { +  if (key in obj) { +    Object.defineProperty(obj, key, { +      value: value, +      enumerable: true, +      configurable: true, +      writable: true +    }); +  } else { +    obj[key] = value; +  } +  return obj; +} + +class JestAssertionError extends Error { +  constructor(...args) { +    super(...args); + +    _defineProperty(this, 'matcherResult', void 0); +  } +} + +const isPromise = obj => +  !!obj && +  (typeof obj === 'object' || typeof obj === 'function') && +  typeof obj.then === 'function'; + +const createToThrowErrorMatchingSnapshotMatcher = function (matcher) { +  return function (received, testNameOrInlineSnapshot) { +    return matcher.apply(this, [received, testNameOrInlineSnapshot, true]); +  }; +}; + +const getPromiseMatcher = (name, matcher) => { +  if (name === 'toThrow' || name === 'toThrowError') { +    return (0, _toThrowMatchers.createMatcher)(name, true); +  } else if ( +    name === 'toThrowErrorMatchingSnapshot' || +    name === 'toThrowErrorMatchingInlineSnapshot' +  ) { +    return createToThrowErrorMatchingSnapshotMatcher(matcher); +  } + +  return null; +}; + +const expect = (actual, ...rest) => { +  if (rest.length !== 0) { +    throw new Error('Expect takes at most one argument.'); +  } + +  const allMatchers = (0, _jestMatchersObject.getMatchers)(); +  const expectation = { +    not: {}, +    rejects: { +      not: {} +    }, +    resolves: { +      not: {} +    } +  }; +  const err = new JestAssertionError(); +  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, +      err +    ); +    expectation.resolves.not[name] = makeResolveMatcher( +      name, +      promiseMatcher, +      true, +      actual, +      err +    ); +    expectation.rejects[name] = makeRejectMatcher( +      name, +      promiseMatcher, +      false, +      actual, +      err +    ); +    expectation.rejects.not[name] = makeRejectMatcher( +      name, +      promiseMatcher, +      true, +      actual, +      err +    ); +  }); +  return expectation; +}; + +const getMessage = message => +  (message && message()) || +  matcherUtils.RECEIVED_COLOR('No message was specified for this matcher.'); + +const makeResolveMatcher = +  (matcherName, matcher, isNot, actual, outerErr) => +  (...args) => { +    const options = { +      isNot, +      promise: 'resolves' +    }; + +    if (!isPromise(actual)) { +      throw new JestAssertionError( +        matcherUtils.matcherErrorMessage( +          matcherUtils.matcherHint(matcherName, undefined, '', options), +          `${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`, +          matcherUtils.printWithType( +            'Received', +            actual, +            matcherUtils.printReceived +          ) +        ) +      ); +    } + +    const innerErr = new JestAssertionError(); +    return actual.then( +      result => +        makeThrowingMatcher(matcher, isNot, 'resolves', result, innerErr).apply( +          null, +          args +        ), +      reason => { +        outerErr.message = +          matcherUtils.matcherHint(matcherName, undefined, '', options) + +          '\n\n' + +          'Received promise rejected instead of resolved\n' + +          `Rejected to value: ${matcherUtils.printReceived(reason)}`; +        return Promise.reject(outerErr); +      } +    ); +  }; + +const makeRejectMatcher = +  (matcherName, matcher, isNot, actual, outerErr) => +  (...args) => { +    const options = { +      isNot, +      promise: 'rejects' +    }; +    const actualWrapper = typeof actual === 'function' ? actual() : actual; + +    if (!isPromise(actualWrapper)) { +      throw new JestAssertionError( +        matcherUtils.matcherErrorMessage( +          matcherUtils.matcherHint(matcherName, undefined, '', options), +          `${matcherUtils.RECEIVED_COLOR( +            'received' +          )} value must be a promise or a function returning a promise`, +          matcherUtils.printWithType( +            'Received', +            actual, +            matcherUtils.printReceived +          ) +        ) +      ); +    } + +    const innerErr = new JestAssertionError(); +    return actualWrapper.then( +      result => { +        outerErr.message = +          matcherUtils.matcherHint(matcherName, undefined, '', options) + +          '\n\n' + +          'Received promise resolved instead of rejected\n' + +          `Resolved to value: ${matcherUtils.printReceived(result)}`; +        return Promise.reject(outerErr); +      }, +      reason => +        makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply( +          null, +          args +        ) +    ); +  }; + +const makeThrowingMatcher = (matcher, isNot, promise, actual, err) => +  function throwingMatcher(...args) { +    let throws = true; +    const utils = { +      ...matcherUtils, +      iterableEquality: _utils.iterableEquality, +      subsetEquality: _utils.subsetEquality +    }; +    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); + +      (0, _jestMatchersObject.getState)().assertionCalls++; + +      if ((result.pass && isNot) || (!result.pass && !isNot)) { +        // XOR +        const message = getMessage(result.message); +        let error; + +        if (err) { +          error = err; +          error.message = message; +        } else if (asyncError) { +          error = asyncError; +          error.message = message; +        } else { +          error = new JestAssertionError(message); // 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); +          } +        } // 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, message}; + +        if (throws) { +          throw error; +        } else { +          (0, _jestMatchersObject.getState)().suppressedErrors.push(error); +        } +      } +    }; + +    const handleError = error => { +      if ( +        matcher[_jestMatchersObject.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; +    }; + +    let potentialResult; + +    try { +      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; +        const asyncError = new JestAssertionError(); + +        if (Error.captureStackTrace) { +          Error.captureStackTrace(asyncError, throwingMatcher); +        } + +        return asyncResult +          .then(aResult => processResult(aResult, asyncError)) +          .catch(handleError); +      } else { +        const syncResult = potentialResult; +        return processResult(syncResult); +      } +    } catch (error) { +      return handleError(error); +    } +  }; + +expect.extend = matchers => +  (0, _jestMatchersObject.setMatchers)(matchers, false, expect); + +expect.anything = _asymmetricMatchers.anything; +expect.any = _asymmetricMatchers.any; +expect.not = { +  arrayContaining: _asymmetricMatchers.arrayNotContaining, +  closeTo: _asymmetricMatchers.notCloseTo, +  objectContaining: _asymmetricMatchers.objectNotContaining, +  stringContaining: _asymmetricMatchers.stringNotContaining, +  stringMatching: _asymmetricMatchers.stringNotMatching +}; +expect.arrayContaining = _asymmetricMatchers.arrayContaining; +expect.closeTo = _asymmetricMatchers.closeTo; +expect.objectContaining = _asymmetricMatchers.objectContaining; +expect.stringContaining = _asymmetricMatchers.stringContaining; +expect.stringMatching = _asymmetricMatchers.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' + +        `'${matcherUtils.stringify(result)}' was returned` +    ); +  } +}; + +function assertions(expected) { +  const error = new Error(); + +  if (Error.captureStackTrace) { +    Error.captureStackTrace(error, assertions); +  } + +  (0, _jestMatchersObject.setState)({ +    expectedAssertionsNumber: expected, +    expectedAssertionsNumberError: error +  }); +} + +function hasAssertions(...args) { +  const error = new Error(); + +  if (Error.captureStackTrace) { +    Error.captureStackTrace(error, hasAssertions); +  } + +  matcherUtils.ensureNoExpected(args[0], '.hasAssertions'); +  (0, _jestMatchersObject.setState)({ +    isExpectingAssertions: true, +    isExpectingAssertionsError: error +  }); +} // add default jest matchers + +(0, _jestMatchersObject.setMatchers)(_matchers.default, true, expect); +(0, _jestMatchersObject.setMatchers)(_spyMatchers.default, true, expect); +(0, _jestMatchersObject.setMatchers)(_toThrowMatchers.default, true, expect); + +expect.addSnapshotSerializer = () => void 0; + +expect.assertions = assertions; +expect.hasAssertions = hasAssertions; +expect.getState = _jestMatchersObject.getState; +expect.setState = _jestMatchersObject.setState; +expect.extractExpectedAssertionsErrors = +  _extractExpectedAssertionsErrors.default; +const expectExport = expect; +module.exports = expectExport; diff --git a/node_modules/expect/build/jasmineUtils.d.ts b/node_modules/expect/build/jasmineUtils.d.ts new file mode 100644 index 0000000..1a2f0f6 --- /dev/null +++ b/node_modules/expect/build/jasmineUtils.d.ts @@ -0,0 +1,8 @@ +import type { Tester } from './types'; +export declare function equals(a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean): boolean; +export declare function isA(typeName: string, value: unknown): boolean; +export declare function fnNameFor(func: Function): string; +export declare function isUndefined(obj: any): boolean; +export declare function hasProperty(obj: object | null, property: string): boolean; +export declare function isImmutableUnorderedKeyed(maybeKeyed: any): boolean; +export declare function isImmutableUnorderedSet(maybeSet: any): boolean; diff --git a/node_modules/expect/build/jasmineUtils.js b/node_modules/expect/build/jasmineUtils.js new file mode 100644 index 0000000..447c40e --- /dev/null +++ b/node_modules/expect/build/jasmineUtils.js @@ -0,0 +1,279 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.equals = equals; +exports.fnNameFor = fnNameFor; +exports.hasProperty = hasProperty; +exports.isA = isA; +exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed; +exports.isImmutableUnorderedSet = isImmutableUnorderedSet; +exports.isUndefined = isUndefined; + +/* +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 */ +// Extracted out of jasmine 2.5.2 +function equals(a, b, customTesters, strictCheck) { +  customTesters = customTesters || []; +  return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey); +} + +const functionToString = Function.prototype.toString; + +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, hasKey) { +  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) { +    case '[object Boolean]': +    case '[object String]': +    case '[object Number]': +      if (typeof a !== typeof b) { +        // One is a primitive, one a `new Primitive()` +        return false; +      } else if (typeof a !== 'object' && typeof b !== 'object') { +        // both are proper primitives +        return Object.is(a, b); +      } else { +        // both are `new Primitive()`s +        return Object.is(a.valueOf(), b.valueOf()); +      } + +    case '[object Date]': +      // Coerce dates 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.flags === b.flags; +  } + +  if (typeof a !== 'object' || typeof b !== 'object') { +    return false; +  } // Use DOM3 method isEqualNode (IE>=9) + +  if (isDomNode(a) && isDomNode(b)) { +    return a.isEqualNode(b); +  } // Used to detect circular references. + +  var length = aStack.length; + +  while (length--) { +    // Linear search. Performance is inversely proportional to the number of +    // unique nested structures. +    // circular references at same depth are equal +    // circular reference is not equal to non-circular one +    if (aStack[length] === a) { +      return bStack[length] === b; +    } else if (bStack[length] === b) { +      return false; +    } +  } // Add the first object to the stack of traversed objects. + +  aStack.push(a); +  bStack.push(b); // Recursively compare objects and arrays. +  // Compare array lengths to determine if a deep comparison is necessary. + +  if (className == '[object Array]' && a.length !== b.length) { +    return false; +  } // Deep compare objects. + +  var aKeys = keys(a, hasKey), +    key; +  var size = aKeys.length; // Ensure that both objects contain the same number of properties before comparing deep equality. + +  if (keys(b, hasKey).length !== size) { +    return false; +  } + +  while (size--) { +    key = aKeys[size]; // Deep compare each member + +    result = +      hasKey(b, key) && +      eq(a[key], b[key], aStack, bStack, customTesters, hasKey); + +    if (!result) { +      return false; +    } +  } // Remove the first object from the stack of traversed objects. + +  aStack.pop(); +  bStack.pop(); +  return result; +} + +function keys(obj, hasKey) { +  var keys = []; + +  for (var key in obj) { +    if (hasKey(obj, key)) { +      keys.push(key); +    } +  } + +  return keys.concat( +    Object.getOwnPropertySymbols(obj).filter( +      symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable +    ) +  ); +} + +function hasDefinedKey(obj, key) { +  return hasKey(obj, key) && obj[key] !== undefined; +} + +function hasKey(obj, key) { +  return Object.prototype.hasOwnProperty.call(obj, key); +} + +function isA(typeName, value) { +  return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; +} + +function isDomNode(obj) { +  return ( +    obj !== null && +    typeof obj === 'object' && +    typeof obj.nodeType === 'number' && +    typeof obj.nodeName === 'string' && +    typeof obj.isEqualNode === 'function' +  ); +} + +function fnNameFor(func) { +  if (func.name) { +    return func.name; +  } + +  const matches = functionToString +    .call(func) +    .match(/^(?:async)?\s*function\s*\*?\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] +  ); +} diff --git a/node_modules/expect/build/jestMatchersObject.d.ts b/node_modules/expect/build/jestMatchersObject.d.ts new file mode 100644 index 0000000..ce40e41 --- /dev/null +++ b/node_modules/expect/build/jestMatchersObject.d.ts @@ -0,0 +1,13 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +import type { Expect, MatcherState, MatchersObject } from './types'; +export declare const INTERNAL_MATCHER_FLAG: unique symbol; +export declare const getState: <State extends MatcherState = MatcherState>() => State; +export declare const setState: <State extends MatcherState = MatcherState>(state: Partial<State>) => void; +export declare const getMatchers: <State extends MatcherState = MatcherState>() => MatchersObject<State>; +export declare const setMatchers: <State extends MatcherState = MatcherState>(matchers: MatchersObject<State>, isInternal: boolean, expect: Expect) => void; diff --git a/node_modules/expect/build/jestMatchersObject.js b/node_modules/expect/build/jestMatchersObject.js new file mode 100644 index 0000000..f183a34 --- /dev/null +++ b/node_modules/expect/build/jestMatchersObject.js @@ -0,0 +1,120 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.setState = +  exports.setMatchers = +  exports.getState = +  exports.getMatchers = +  exports.INTERNAL_MATCHER_FLAG = +    void 0; + +var _asymmetricMatchers = require('./asymmetricMatchers'); + +var global = (function () { +  if (typeof globalThis !== 'undefined') { +    return globalThis; +  } else if (typeof global !== 'undefined') { +    return global; +  } else if (typeof self !== 'undefined') { +    return self; +  } else if (typeof window !== 'undefined') { +    return window; +  } else { +    return Function('return this')(); +  } +})(); + +var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol; +// 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. + +const INTERNAL_MATCHER_FLAG = Symbol.for('$$jest-internal-matcher'); +exports.INTERNAL_MATCHER_FLAG = INTERNAL_MATCHER_FLAG; + +if (!global.hasOwnProperty(JEST_MATCHERS_OBJECT)) { +  const defaultState = { +    assertionCalls: 0, +    expectedAssertionsNumber: null, +    isExpectingAssertions: false, +    suppressedErrors: [] // errors that are not thrown immediately. +  }; +  Object.defineProperty(global, JEST_MATCHERS_OBJECT, { +    value: { +      matchers: Object.create(null), +      state: defaultState +    } +  }); +} + +const getState = () => global[JEST_MATCHERS_OBJECT].state; + +exports.getState = getState; + +const setState = state => { +  Object.assign(global[JEST_MATCHERS_OBJECT].state, state); +}; + +exports.setState = setState; + +const getMatchers = () => global[JEST_MATCHERS_OBJECT].matchers; + +exports.getMatchers = getMatchers; + +const setMatchers = (matchers, isInternal, expect) => { +  Object.keys(matchers).forEach(key => { +    const matcher = matchers[key]; +    Object.defineProperty(matcher, INTERNAL_MATCHER_FLAG, { +      value: isInternal +    }); + +    if (!isInternal) { +      // expect is defined +      class CustomMatcher extends _asymmetricMatchers.AsymmetricMatcher { +        constructor(inverse = false, ...sample) { +          super(sample, inverse); +        } + +        asymmetricMatch(other) { +          const {pass} = matcher.call( +            this.getMatcherContext(), +            other, +            ...this.sample +          ); +          return this.inverse ? !pass : pass; +        } + +        toString() { +          return `${this.inverse ? 'not.' : ''}${key}`; +        } + +        getExpectedType() { +          return 'any'; +        } + +        toAsymmetricMatcher() { +          return `${this.toString()}<${this.sample.map(String).join(', ')}>`; +        } +      } + +      Object.defineProperty(expect, key, { +        configurable: true, +        enumerable: true, +        value: (...sample) => new CustomMatcher(false, ...sample), +        writable: true +      }); +      Object.defineProperty(expect.not, key, { +        configurable: true, +        enumerable: true, +        value: (...sample) => new CustomMatcher(true, ...sample), +        writable: true +      }); +    } +  }); +  Object.assign(global[JEST_MATCHERS_OBJECT].matchers, matchers); +}; + +exports.setMatchers = setMatchers; diff --git a/node_modules/expect/build/matchers.d.ts b/node_modules/expect/build/matchers.d.ts new file mode 100644 index 0000000..6501473 --- /dev/null +++ b/node_modules/expect/build/matchers.d.ts @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +import type { MatchersObject } from './types'; +declare const matchers: MatchersObject; +export default matchers; diff --git a/node_modules/expect/build/matchers.js b/node_modules/expect/build/matchers.js new file mode 100644 index 0000000..e0cf502 --- /dev/null +++ b/node_modules/expect/build/matchers.js @@ -0,0 +1,1370 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +var _jestGetType = require('jest-get-type'); + +var _jestMatcherUtils = require('jest-matcher-utils'); + +var _jasmineUtils = require('./jasmineUtils'); + +var _print = require('./print'); + +var _utils = require('./utils'); + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ + +/* 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'; +const EXPECTED_VALUE_LABEL = 'Expected value'; +const RECEIVED_VALUE_LABEL = 'Received value'; // The optional property of matcher context is true if undefined. + +const isExpand = expand => expand !== false; + +const toStrictEqualTesters = [ +  _utils.iterableEquality, +  _utils.typeEquality, +  _utils.sparseArrayEquality, +  _utils.arrayBufferEquality +]; +const matchers = { +  toBe(received, expected) { +    const matcherName = 'toBe'; +    const options = { +      comment: 'Object.is equality', +      isNot: this.isNot, +      promise: this.promise +    }; +    const pass = Object.is(received, expected); +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          `Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}` +      : () => { +          const expectedType = (0, _jestGetType.getType)(expected); +          let deepEqualityName = null; + +          if (expectedType !== 'map' && expectedType !== 'set') { +            // If deep equality passes when referential identity fails, +            // but exclude map and set until review of their equality logic. +            if ( +              (0, _jasmineUtils.equals)( +                received, +                expected, +                toStrictEqualTesters, +                true +              ) +            ) { +              deepEqualityName = 'toStrictEqual'; +            } else if ( +              (0, _jasmineUtils.equals)(received, expected, [ +                _utils.iterableEquality +              ]) +            ) { +              deepEqualityName = 'toEqual'; +            } +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              undefined, +              undefined, +              options +            ) + +            '\n\n' + +            (deepEqualityName !== null +              ? (0, _jestMatcherUtils.DIM_COLOR)( +                  `If it should pass with deep equality, replace "${matcherName}" with "${deepEqualityName}"` +                ) + '\n\n' +              : '') + +            (0, _jestMatcherUtils.printDiffOrStringify)( +              expected, +              received, +              EXPECTED_LABEL, +              RECEIVED_LABEL, +              isExpand(this.expand) +            ) +          ); +        }; // Passing 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: matcherName, +      pass +    }; +  }, + +  toBeCloseTo(received, expected, precision = 2) { +    const matcherName = 'toBeCloseTo'; +    const secondArgument = arguments.length === 3 ? 'precision' : undefined; +    const isNot = this.isNot; +    const options = { +      isNot, +      promise: this.promise, +      secondArgument, +      secondArgumentColor: arg => arg +    }; + +    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; + +    if (received === Infinity && expected === Infinity) { +      pass = true; // Infinity - Infinity is NaN +    } else if (received === -Infinity && expected === -Infinity) { +      pass = true; // -Infinity - -Infinity is NaN +    } else { +      expectedDiff = Math.pow(10, -precision) / 2; +      receivedDiff = Math.abs(expected - received); +      pass = receivedDiff < expectedDiff; +    } + +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          `Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + +          (receivedDiff === 0 +            ? '' +            : `Received:     ${(0, _jestMatcherUtils.printReceived)( +                received +              )}\n` + +              '\n' + +              (0, _print.printCloseTo)( +                receivedDiff, +                expectedDiff, +                precision, +                isNot +              )) +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          `Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + +          `Received: ${(0, _jestMatcherUtils.printReceived)(received)}\n` + +          '\n' + +          (0, _print.printCloseTo)( +            receivedDiff, +            expectedDiff, +            precision, +            isNot +          ); +    return { +      message, +      pass +    }; +  }, + +  toBeDefined(received, expected) { +    const matcherName = 'toBeDefined'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    const pass = received !== void 0; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) + +      '\n\n' + +      `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeFalsy(received, expected) { +    const matcherName = 'toBeFalsy'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    const pass = !received; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) + +      '\n\n' + +      `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeGreaterThan(received, expected) { +    const matcherName = 'toBeGreaterThan'; +    const isNot = this.isNot; +    const options = { +      isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNumbers)( +      received, +      expected, +      matcherName, +      options +    ); +    const pass = received > expected; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)( +        matcherName, +        undefined, +        undefined, +        options +      ) + +      '\n\n' + +      `Expected:${isNot ? ' not' : ''} > ${(0, _jestMatcherUtils.printExpected)( +        expected +      )}\n` + +      `Received:${isNot ? '    ' : ''}   ${(0, _jestMatcherUtils.printReceived)( +        received +      )}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeGreaterThanOrEqual(received, expected) { +    const matcherName = 'toBeGreaterThanOrEqual'; +    const isNot = this.isNot; +    const options = { +      isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNumbers)( +      received, +      expected, +      matcherName, +      options +    ); +    const pass = received >= expected; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)( +        matcherName, +        undefined, +        undefined, +        options +      ) + +      '\n\n' + +      `Expected:${isNot ? ' not' : ''} >= ${(0, +      _jestMatcherUtils.printExpected)(expected)}\n` + +      `Received:${isNot ? '    ' : ''}    ${(0, +      _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeInstanceOf(received, expected) { +    const matcherName = 'toBeInstanceOf'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; + +    if (typeof expected !== 'function') { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.EXPECTED_COLOR)( +            'expected' +          )} value must be a function`, +          (0, _jestMatcherUtils.printWithType)( +            'Expected', +            expected, +            _jestMatcherUtils.printExpected +          ) +        ) +      ); +    } + +    const pass = received instanceof expected; +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          (0, _print.printExpectedConstructorNameNot)( +            'Expected constructor', +            expected +          ) + +          (typeof received.constructor === 'function' && +          received.constructor !== expected +            ? (0, _print.printReceivedConstructorNameNot)( +                'Received constructor', +                received.constructor, +                expected +              ) +            : '') +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          (0, _print.printExpectedConstructorName)( +            'Expected constructor', +            expected +          ) + +          ((0, _jestGetType.isPrimitive)(received) || +          Object.getPrototypeOf(received) === null +            ? `\nReceived value has no prototype\nReceived value: ${(0, +              _jestMatcherUtils.printReceived)(received)}` +            : typeof received.constructor !== 'function' +            ? `\nReceived value: ${(0, _jestMatcherUtils.printReceived)( +                received +              )}` +            : (0, _print.printReceivedConstructorName)( +                'Received constructor', +                received.constructor +              )); +    return { +      message, +      pass +    }; +  }, + +  toBeLessThan(received, expected) { +    const matcherName = 'toBeLessThan'; +    const isNot = this.isNot; +    const options = { +      isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNumbers)( +      received, +      expected, +      matcherName, +      options +    ); +    const pass = received < expected; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)( +        matcherName, +        undefined, +        undefined, +        options +      ) + +      '\n\n' + +      `Expected:${isNot ? ' not' : ''} < ${(0, _jestMatcherUtils.printExpected)( +        expected +      )}\n` + +      `Received:${isNot ? '    ' : ''}   ${(0, _jestMatcherUtils.printReceived)( +        received +      )}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeLessThanOrEqual(received, expected) { +    const matcherName = 'toBeLessThanOrEqual'; +    const isNot = this.isNot; +    const options = { +      isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNumbers)( +      received, +      expected, +      matcherName, +      options +    ); +    const pass = received <= expected; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)( +        matcherName, +        undefined, +        undefined, +        options +      ) + +      '\n\n' + +      `Expected:${isNot ? ' not' : ''} <= ${(0, +      _jestMatcherUtils.printExpected)(expected)}\n` + +      `Received:${isNot ? '    ' : ''}    ${(0, +      _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeNaN(received, expected) { +    const matcherName = 'toBeNaN'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    const pass = Number.isNaN(received); + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) + +      '\n\n' + +      `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeNull(received, expected) { +    const matcherName = 'toBeNull'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    const pass = received === null; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) + +      '\n\n' + +      `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeTruthy(received, expected) { +    const matcherName = 'toBeTruthy'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    const pass = !!received; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) + +      '\n\n' + +      `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toBeUndefined(received, expected) { +    const matcherName = 'toBeUndefined'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    const pass = received === void 0; + +    const message = () => +      (0, _jestMatcherUtils.matcherHint)(matcherName, undefined, '', options) + +      '\n\n' + +      `Received: ${(0, _jestMatcherUtils.printReceived)(received)}`; + +    return { +      message, +      pass +    }; +  }, + +  toContain(received, expected) { +    const matcherName = 'toContain'; +    const isNot = this.isNot; +    const options = { +      comment: 'indexOf', +      isNot, +      promise: this.promise +    }; + +    if (received == null) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +            'received' +          )} value must not be null nor undefined`, +          (0, _jestMatcherUtils.printWithType)( +            'Received', +            received, +            _jestMatcherUtils.printReceived +          ) +        ) +      ); +    } + +    if (typeof received === 'string') { +      const wrongTypeErrorMessage = `${(0, _jestMatcherUtils.EXPECTED_COLOR)( +        'expected' +      )} value must be a string if ${(0, _jestMatcherUtils.RECEIVED_COLOR)( +        'received' +      )} value is a string`; + +      if (typeof expected !== 'string') { +        throw new Error( +          (0, _jestMatcherUtils.matcherErrorMessage)( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              received, +              String(expected), +              options +            ), +            wrongTypeErrorMessage, +            (0, _jestMatcherUtils.printWithType)( +              'Expected', +              expected, +              _jestMatcherUtils.printExpected +            ) + +              '\n' + +              (0, _jestMatcherUtils.printWithType)( +                'Received', +                received, +                _jestMatcherUtils.printReceived +              ) +          ) +        ); +      } + +      const index = received.indexOf(String(expected)); +      const pass = index !== -1; + +      const message = () => { +        const labelExpected = `Expected ${ +          typeof expected === 'string' ? 'substring' : 'value' +        }`; +        const labelReceived = 'Received string'; +        const printLabel = (0, _jestMatcherUtils.getLabelPrinter)( +          labelExpected, +          labelReceived +        ); +        return ( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          `${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0, +          _jestMatcherUtils.printExpected)(expected)}\n` + +          `${printLabel(labelReceived)}${isNot ? '    ' : ''}${ +            isNot +              ? (0, _print.printReceivedStringContainExpectedSubstring)( +                  received, +                  index, +                  String(expected).length +                ) +              : (0, _jestMatcherUtils.printReceived)(received) +          }` +        ); +      }; + +      return { +        message, +        pass +      }; +    } + +    const indexable = Array.from(received); +    const index = indexable.indexOf(expected); +    const pass = index !== -1; + +    const message = () => { +      const labelExpected = 'Expected value'; +      const labelReceived = `Received ${(0, _jestGetType.getType)(received)}`; +      const printLabel = (0, _jestMatcherUtils.getLabelPrinter)( +        labelExpected, +        labelReceived +      ); +      return ( +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        `${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0, +        _jestMatcherUtils.printExpected)(expected)}\n` + +        `${printLabel(labelReceived)}${isNot ? '    ' : ''}${ +          isNot && Array.isArray(received) +            ? (0, _print.printReceivedArrayContainExpectedItem)(received, index) +            : (0, _jestMatcherUtils.printReceived)(received) +        }` + +        (!isNot && +        indexable.findIndex(item => +          (0, _jasmineUtils.equals)(item, expected, [_utils.iterableEquality]) +        ) !== -1 +          ? `\n\n${_jestMatcherUtils.SUGGEST_TO_CONTAIN_EQUAL}` +          : '') +      ); +    }; + +    return { +      message, +      pass +    }; +  }, + +  toContainEqual(received, expected) { +    const matcherName = 'toContainEqual'; +    const isNot = this.isNot; +    const options = { +      comment: 'deep equality', +      isNot, +      promise: this.promise +    }; + +    if (received == null) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +            'received' +          )} value must not be null nor undefined`, +          (0, _jestMatcherUtils.printWithType)( +            'Received', +            received, +            _jestMatcherUtils.printReceived +          ) +        ) +      ); +    } + +    const index = Array.from(received).findIndex(item => +      (0, _jasmineUtils.equals)(item, expected, [_utils.iterableEquality]) +    ); +    const pass = index !== -1; + +    const message = () => { +      const labelExpected = 'Expected value'; +      const labelReceived = `Received ${(0, _jestGetType.getType)(received)}`; +      const printLabel = (0, _jestMatcherUtils.getLabelPrinter)( +        labelExpected, +        labelReceived +      ); +      return ( +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        `${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0, +        _jestMatcherUtils.printExpected)(expected)}\n` + +        `${printLabel(labelReceived)}${isNot ? '    ' : ''}${ +          isNot && Array.isArray(received) +            ? (0, _print.printReceivedArrayContainExpectedItem)(received, index) +            : (0, _jestMatcherUtils.printReceived)(received) +        }` +      ); +    }; + +    return { +      message, +      pass +    }; +  }, + +  toEqual(received, expected) { +    const matcherName = 'toEqual'; +    const options = { +      comment: 'deep equality', +      isNot: this.isNot, +      promise: this.promise +    }; +    const pass = (0, _jasmineUtils.equals)(received, expected, [ +      _utils.iterableEquality +    ]); +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          `Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + +          ((0, _jestMatcherUtils.stringify)(expected) !== +          (0, _jestMatcherUtils.stringify)(received) +            ? `Received:     ${(0, _jestMatcherUtils.printReceived)(received)}` +            : '') +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          (0, _jestMatcherUtils.printDiffOrStringify)( +            expected, +            received, +            EXPECTED_LABEL, +            RECEIVED_LABEL, +            isExpand(this.expand) +          ); // Passing 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: matcherName, +      pass +    }; +  }, + +  toHaveLength(received, expected) { +    const matcherName = 'toHaveLength'; +    const isNot = this.isNot; +    const options = { +      isNot, +      promise: this.promise +    }; + +    if ( +      typeof (received === null || received === void 0 +        ? void 0 +        : received.length) !== 'number' +    ) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +            'received' +          )} value must have a length property whose value must be a number`, +          (0, _jestMatcherUtils.printWithType)( +            'Received', +            received, +            _jestMatcherUtils.printReceived +          ) +        ) +      ); +    } + +    (0, _jestMatcherUtils.ensureExpectedIsNonNegativeInteger)( +      expected, +      matcherName, +      options +    ); +    const pass = received.length === expected; + +    const message = () => { +      const labelExpected = 'Expected length'; +      const labelReceivedLength = 'Received length'; +      const labelReceivedValue = `Received ${(0, _jestGetType.getType)( +        received +      )}`; +      const printLabel = (0, _jestMatcherUtils.getLabelPrinter)( +        labelExpected, +        labelReceivedLength, +        labelReceivedValue +      ); +      return ( +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        `${printLabel(labelExpected)}${isNot ? 'not ' : ''}${(0, +        _jestMatcherUtils.printExpected)(expected)}\n` + +        (isNot +          ? '' +          : `${printLabel(labelReceivedLength)}${(0, +            _jestMatcherUtils.printReceived)(received.length)}\n`) + +        `${printLabel(labelReceivedValue)}${isNot ? '    ' : ''}${(0, +        _jestMatcherUtils.printReceived)(received)}` +      ); +    }; + +    return { +      message, +      pass +    }; +  }, + +  toHaveProperty(received, expectedPath, expectedValue) { +    const matcherName = 'toHaveProperty'; +    const expectedArgument = 'path'; +    const hasValue = arguments.length === 3; +    const options = { +      isNot: this.isNot, +      promise: this.promise, +      secondArgument: hasValue ? 'value' : '' +    }; + +    if (received === null || received === undefined) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            expectedArgument, +            options +          ), +          `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +            'received' +          )} value must not be null nor undefined`, +          (0, _jestMatcherUtils.printWithType)( +            'Received', +            received, +            _jestMatcherUtils.printReceived +          ) +        ) +      ); +    } + +    const expectedPathType = (0, _jestGetType.getType)(expectedPath); + +    if (expectedPathType !== 'string' && expectedPathType !== 'array') { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            expectedArgument, +            options +          ), +          `${(0, _jestMatcherUtils.EXPECTED_COLOR)( +            'expected' +          )} path must be a string or array`, +          (0, _jestMatcherUtils.printWithType)( +            'Expected', +            expectedPath, +            _jestMatcherUtils.printExpected +          ) +        ) +      ); +    } + +    const expectedPathLength = +      typeof expectedPath === 'string' +        ? (0, _utils.pathAsArray)(expectedPath).length +        : expectedPath.length; + +    if (expectedPathType === 'array' && expectedPathLength === 0) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            expectedArgument, +            options +          ), +          `${(0, _jestMatcherUtils.EXPECTED_COLOR)( +            'expected' +          )} path must not be an empty array`, +          (0, _jestMatcherUtils.printWithType)( +            'Expected', +            expectedPath, +            _jestMatcherUtils.printExpected +          ) +        ) +      ); +    } + +    const result = (0, _utils.getPath)(received, expectedPath); +    const {lastTraversedObject, hasEndProp} = result; +    const receivedPath = result.traversedPath; +    const hasCompletePath = receivedPath.length === expectedPathLength; +    const receivedValue = hasCompletePath ? result.value : lastTraversedObject; +    const pass = hasValue +      ? (0, _jasmineUtils.equals)(result.value, expectedValue, [ +          _utils.iterableEquality +        ]) +      : Boolean(hasEndProp); // theoretically undefined if empty path +    // Remove type cast if we rewrite getPath as iterative algorithm. +    // Delete this unique report if future breaking change +    // removes the edge case that expected value undefined +    // also matches absence of a property with the key path. + +    if (pass && !hasCompletePath) { +      const message = () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          expectedArgument, +          options +        ) + +        '\n\n' + +        `Expected path: ${(0, _jestMatcherUtils.printExpected)( +          expectedPath +        )}\n` + +        `Received path: ${(0, _jestMatcherUtils.printReceived)( +          expectedPathType === 'array' || receivedPath.length === 0 +            ? receivedPath +            : receivedPath.join('.') +        )}\n\n` + +        `Expected value: not ${(0, _jestMatcherUtils.printExpected)( +          expectedValue +        )}\n` + +        `Received value:     ${(0, _jestMatcherUtils.printReceived)( +          receivedValue +        )}\n\n` + +        (0, _jestMatcherUtils.DIM_COLOR)( +          'Because a positive assertion passes for expected value undefined if the property does not exist, this negative assertion fails unless the property does exist and has a defined value' +        ); + +      return { +        message, +        pass +      }; +    } + +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            expectedArgument, +            options +          ) + +          '\n\n' + +          (hasValue +            ? `Expected path: ${(0, _jestMatcherUtils.printExpected)( +                expectedPath +              )}\n\n` + +              `Expected value: not ${(0, _jestMatcherUtils.printExpected)( +                expectedValue +              )}` + +              ((0, _jestMatcherUtils.stringify)(expectedValue) !== +              (0, _jestMatcherUtils.stringify)(receivedValue) +                ? `\nReceived value:     ${(0, _jestMatcherUtils.printReceived)( +                    receivedValue +                  )}` +                : '') +            : `Expected path: not ${(0, _jestMatcherUtils.printExpected)( +                expectedPath +              )}\n\n` + +              `Received value: ${(0, _jestMatcherUtils.printReceived)( +                receivedValue +              )}`) +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected path: ${(0, _jestMatcherUtils.printExpected)( +            expectedPath +          )}\n` + +          (hasCompletePath +            ? '\n' + +              (0, _jestMatcherUtils.printDiffOrStringify)( +                expectedValue, +                receivedValue, +                EXPECTED_VALUE_LABEL, +                RECEIVED_VALUE_LABEL, +                isExpand(this.expand) +              ) +            : `Received path: ${(0, _jestMatcherUtils.printReceived)( +                expectedPathType === 'array' || receivedPath.length === 0 +                  ? receivedPath +                  : receivedPath.join('.') +              )}\n\n` + +              (hasValue +                ? `Expected value: ${(0, _jestMatcherUtils.printExpected)( +                    expectedValue +                  )}\n` +                : '') + +              `Received value: ${(0, _jestMatcherUtils.printReceived)( +                receivedValue +              )}`); +    return { +      message, +      pass +    }; +  }, + +  toMatch(received, expected) { +    const matcherName = 'toMatch'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; + +    if (typeof received !== 'string') { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +            'received' +          )} value must be a string`, +          (0, _jestMatcherUtils.printWithType)( +            'Received', +            received, +            _jestMatcherUtils.printReceived +          ) +        ) +      ); +    } + +    if ( +      !(typeof expected === 'string') && +      !(expected && typeof expected.test === 'function') +    ) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.EXPECTED_COLOR)( +            'expected' +          )} value must be a string or regular expression`, +          (0, _jestMatcherUtils.printWithType)( +            'Expected', +            expected, +            _jestMatcherUtils.printExpected +          ) +        ) +      ); +    } + +    const pass = +      typeof expected === 'string' +        ? received.includes(expected) +        : new RegExp(expected).test(received); +    const message = pass +      ? () => +          typeof expected === 'string' +            ? (0, _jestMatcherUtils.matcherHint)( +                matcherName, +                undefined, +                undefined, +                options +              ) + +              '\n\n' + +              `Expected substring: not ${(0, _jestMatcherUtils.printExpected)( +                expected +              )}\n` + +              `Received string:        ${(0, +              _print.printReceivedStringContainExpectedSubstring)( +                received, +                received.indexOf(expected), +                expected.length +              )}` +            : (0, _jestMatcherUtils.matcherHint)( +                matcherName, +                undefined, +                undefined, +                options +              ) + +              '\n\n' + +              `Expected pattern: not ${(0, _jestMatcherUtils.printExpected)( +                expected +              )}\n` + +              `Received string:      ${(0, +              _print.printReceivedStringContainExpectedResult)( +                received, +                typeof expected.exec === 'function' +                  ? expected.exec(received) +                  : null +              )}` +      : () => { +          const labelExpected = `Expected ${ +            typeof expected === 'string' ? 'substring' : 'pattern' +          }`; +          const labelReceived = 'Received string'; +          const printLabel = (0, _jestMatcherUtils.getLabelPrinter)( +            labelExpected, +            labelReceived +          ); +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              undefined, +              undefined, +              options +            ) + +            '\n\n' + +            `${printLabel(labelExpected)}${(0, _jestMatcherUtils.printExpected)( +              expected +            )}\n` + +            `${printLabel(labelReceived)}${(0, _jestMatcherUtils.printReceived)( +              received +            )}` +          ); +        }; +    return { +      message, +      pass +    }; +  }, + +  toMatchObject(received, expected) { +    const matcherName = 'toMatchObject'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; + +    if (typeof received !== 'object' || received === null) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +            'received' +          )} value must be a non-null object`, +          (0, _jestMatcherUtils.printWithType)( +            'Received', +            received, +            _jestMatcherUtils.printReceived +          ) +        ) +      ); +    } + +    if (typeof expected !== 'object' || expected === null) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.EXPECTED_COLOR)( +            'expected' +          )} value must be a non-null object`, +          (0, _jestMatcherUtils.printWithType)( +            'Expected', +            expected, +            _jestMatcherUtils.printExpected +          ) +        ) +      ); +    } + +    const pass = (0, _jasmineUtils.equals)(received, expected, [ +      _utils.iterableEquality, +      _utils.subsetEquality +    ]); +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          `Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}` + +          ((0, _jestMatcherUtils.stringify)(expected) !== +          (0, _jestMatcherUtils.stringify)(received) +            ? `\nReceived:     ${(0, _jestMatcherUtils.printReceived)( +                received +              )}` +            : '') +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          (0, _jestMatcherUtils.printDiffOrStringify)( +            expected, +            (0, _utils.getObjectSubset)(received, expected), +            EXPECTED_LABEL, +            RECEIVED_LABEL, +            isExpand(this.expand) +          ); +    return { +      message, +      pass +    }; +  }, + +  toStrictEqual(received, expected) { +    const matcherName = 'toStrictEqual'; +    const options = { +      comment: 'deep equality', +      isNot: this.isNot, +      promise: this.promise +    }; +    const pass = (0, _jasmineUtils.equals)( +      received, +      expected, +      toStrictEqualTesters, +      true +    ); +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          `Expected: not ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + +          ((0, _jestMatcherUtils.stringify)(expected) !== +          (0, _jestMatcherUtils.stringify)(received) +            ? `Received:     ${(0, _jestMatcherUtils.printReceived)(received)}` +            : '') +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ) + +          '\n\n' + +          (0, _jestMatcherUtils.printDiffOrStringify)( +            expected, +            received, +            EXPECTED_LABEL, +            RECEIVED_LABEL, +            isExpand(this.expand) +          ); // Passing 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: matcherName, +      pass +    }; +  } +}; +var _default = matchers; +exports.default = _default; diff --git a/node_modules/expect/build/print.d.ts b/node_modules/expect/build/print.d.ts new file mode 100644 index 0000000..9c19751 --- /dev/null +++ b/node_modules/expect/build/print.d.ts @@ -0,0 +1,15 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +export declare const printReceivedStringContainExpectedSubstring: (received: string, start: number, length: number) => string; +export declare const printReceivedStringContainExpectedResult: (received: string, result: RegExpExecArray | null) => string; +export declare const printReceivedArrayContainExpectedItem: (received: Array<unknown>, index: number) => string; +export declare const printCloseTo: (receivedDiff: number, expectedDiff: number, precision: number, isNot: boolean) => string; +export declare const printExpectedConstructorName: (label: string, expected: Function) => string; +export declare const printExpectedConstructorNameNot: (label: string, expected: Function) => string; +export declare const printReceivedConstructorName: (label: string, received: Function) => string; +export declare const printReceivedConstructorNameNot: (label: string, received: Function, expected: Function) => string; diff --git a/node_modules/expect/build/print.js b/node_modules/expect/build/print.js new file mode 100644 index 0000000..a449256 --- /dev/null +++ b/node_modules/expect/build/print.js @@ -0,0 +1,141 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.printReceivedStringContainExpectedSubstring = +  exports.printReceivedStringContainExpectedResult = +  exports.printReceivedConstructorNameNot = +  exports.printReceivedConstructorName = +  exports.printReceivedArrayContainExpectedItem = +  exports.printExpectedConstructorNameNot = +  exports.printExpectedConstructorName = +  exports.printCloseTo = +    void 0; + +var _jestMatcherUtils = require('jest-matcher-utils'); + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ + +/* eslint-disable local/ban-types-eventually */ +// Format substring but do not enclose in double quote marks. +// The replacement is compatible with pretty-format package. +const printSubstring = val => val.replace(/"|\\/g, '\\$&'); + +const printReceivedStringContainExpectedSubstring = ( +  received, +  start, +  length // not end +) => +  (0, _jestMatcherUtils.RECEIVED_COLOR)( +    '"' + +      printSubstring(received.slice(0, start)) + +      (0, _jestMatcherUtils.INVERTED_COLOR)( +        printSubstring(received.slice(start, start + length)) +      ) + +      printSubstring(received.slice(start + length)) + +      '"' +  ); + +exports.printReceivedStringContainExpectedSubstring = +  printReceivedStringContainExpectedSubstring; + +const printReceivedStringContainExpectedResult = (received, result) => +  result === null +    ? (0, _jestMatcherUtils.printReceived)(received) +    : printReceivedStringContainExpectedSubstring( +        received, +        result.index, +        result[0].length +      ); // The serialized array is compatible with pretty-format package min option. +// However, items have default stringify depth (instead of depth - 1) +// so expected item looks consistent by itself and enclosed in the array. + +exports.printReceivedStringContainExpectedResult = +  printReceivedStringContainExpectedResult; + +const printReceivedArrayContainExpectedItem = (received, index) => +  (0, _jestMatcherUtils.RECEIVED_COLOR)( +    '[' + +      received +        .map((item, i) => { +          const stringified = (0, _jestMatcherUtils.stringify)(item); +          return i === index +            ? (0, _jestMatcherUtils.INVERTED_COLOR)(stringified) +            : stringified; +        }) +        .join(', ') + +      ']' +  ); + +exports.printReceivedArrayContainExpectedItem = +  printReceivedArrayContainExpectedItem; + +const printCloseTo = (receivedDiff, expectedDiff, precision, isNot) => { +  const receivedDiffString = (0, _jestMatcherUtils.stringify)(receivedDiff); +  const expectedDiffString = receivedDiffString.includes('e') // toExponential arg is number of digits after the decimal point. +    ? expectedDiff.toExponential(0) +    : 0 <= precision && precision < 20 // toFixed arg is number of digits after the decimal point. +    ? // It may be a value between 0 and 20 inclusive. +      // Implementations may optionally support a larger range of values. +      expectedDiff.toFixed(precision + 1) +    : (0, _jestMatcherUtils.stringify)(expectedDiff); +  return ( +    `Expected precision:  ${isNot ? '    ' : ''}  ${(0, +    _jestMatcherUtils.stringify)(precision)}\n` + +    `Expected difference: ${isNot ? 'not ' : ''}< ${(0, +    _jestMatcherUtils.EXPECTED_COLOR)(expectedDiffString)}\n` + +    `Received difference: ${isNot ? '    ' : ''}  ${(0, +    _jestMatcherUtils.RECEIVED_COLOR)(receivedDiffString)}` +  ); +}; + +exports.printCloseTo = printCloseTo; + +const printExpectedConstructorName = (label, expected) => +  printConstructorName(label, expected, false, true) + '\n'; + +exports.printExpectedConstructorName = printExpectedConstructorName; + +const printExpectedConstructorNameNot = (label, expected) => +  printConstructorName(label, expected, true, true) + '\n'; + +exports.printExpectedConstructorNameNot = printExpectedConstructorNameNot; + +const printReceivedConstructorName = (label, received) => +  printConstructorName(label, received, false, false) + '\n'; // Do not call function if received is equal to expected. + +exports.printReceivedConstructorName = printReceivedConstructorName; + +const printReceivedConstructorNameNot = (label, received, expected) => +  typeof expected.name === 'string' && +  expected.name.length !== 0 && +  typeof received.name === 'string' && +  received.name.length !== 0 +    ? printConstructorName(label, received, true, false) + +      ` ${ +        Object.getPrototypeOf(received) === expected +          ? 'extends' +          : 'extends … extends' +      } ${(0, _jestMatcherUtils.EXPECTED_COLOR)(expected.name)}` + +      '\n' +    : printConstructorName(label, received, false, false) + '\n'; + +exports.printReceivedConstructorNameNot = printReceivedConstructorNameNot; + +const printConstructorName = (label, constructor, isNot, isExpected) => +  typeof constructor.name !== 'string' +    ? `${label} name is not a string` +    : constructor.name.length === 0 +    ? `${label} name is an empty string` +    : `${label}: ${!isNot ? '' : isExpected ? 'not ' : '    '}${ +        isExpected +          ? (0, _jestMatcherUtils.EXPECTED_COLOR)(constructor.name) +          : (0, _jestMatcherUtils.RECEIVED_COLOR)(constructor.name) +      }`; diff --git a/node_modules/expect/build/spyMatchers.d.ts b/node_modules/expect/build/spyMatchers.d.ts new file mode 100644 index 0000000..433b443 --- /dev/null +++ b/node_modules/expect/build/spyMatchers.d.ts @@ -0,0 +1,9 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { MatchersObject } from './types'; +declare const spyMatchers: MatchersObject; +export default spyMatchers; diff --git a/node_modules/expect/build/spyMatchers.js b/node_modules/expect/build/spyMatchers.js new file mode 100644 index 0000000..3181d08 --- /dev/null +++ b/node_modules/expect/build/spyMatchers.js @@ -0,0 +1,1339 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +var _jestGetType = require('jest-get-type'); + +var _jestMatcherUtils = require('jest-matcher-utils'); + +var _jasmineUtils = require('./jasmineUtils'); + +var _utils = require('./utils'); + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +// The optional property of matcher context is true if undefined. +const isExpand = expand => expand !== false; + +const PRINT_LIMIT = 3; +const NO_ARGUMENTS = 'called with 0 arguments'; + +const printExpectedArgs = expected => +  expected.length === 0 +    ? NO_ARGUMENTS +    : expected.map(arg => (0, _jestMatcherUtils.printExpected)(arg)).join(', '); + +const printReceivedArgs = (received, expected) => +  received.length === 0 +    ? NO_ARGUMENTS +    : received +        .map((arg, i) => +          Array.isArray(expected) && +          i < expected.length && +          isEqualValue(expected[i], arg) +            ? printCommon(arg) +            : (0, _jestMatcherUtils.printReceived)(arg) +        ) +        .join(', '); + +const printCommon = val => +  (0, _jestMatcherUtils.DIM_COLOR)((0, _jestMatcherUtils.stringify)(val)); + +const isEqualValue = (expected, received) => +  (0, _jasmineUtils.equals)(expected, received, [_utils.iterableEquality]); + +const isEqualCall = (expected, received) => isEqualValue(expected, received); + +const isEqualReturn = (expected, result) => +  result.type === 'return' && isEqualValue(expected, result.value); + +const countReturns = results => +  results.reduce((n, result) => (result.type === 'return' ? n + 1 : n), 0); + +const printNumberOfReturns = (countReturns, countCalls) => +  `\nNumber of returns: ${(0, _jestMatcherUtils.printReceived)(countReturns)}` + +  (countCalls !== countReturns +    ? `\nNumber of calls:   ${(0, _jestMatcherUtils.printReceived)(countCalls)}` +    : ''); + +// Given a label, return a function which given a string, +// right-aligns it preceding the colon in the label. +const getRightAlignedPrinter = label => { +  // Assume that the label contains a colon. +  const index = label.indexOf(':'); +  const suffix = label.slice(index); +  return (string, isExpectedCall) => +    (isExpectedCall +      ? '->' + ' '.repeat(Math.max(0, index - 2 - string.length)) +      : ' '.repeat(Math.max(index - string.length))) + +    string + +    suffix; +}; + +const printReceivedCallsNegative = ( +  expected, +  indexedCalls, +  isOnlyCall, +  iExpectedCall +) => { +  if (indexedCalls.length === 0) { +    return ''; +  } + +  const label = 'Received:     '; + +  if (isOnlyCall) { +    return label + printReceivedArgs(indexedCalls[0], expected) + '\n'; +  } + +  const printAligned = getRightAlignedPrinter(label); +  return ( +    'Received\n' + +    indexedCalls.reduce( +      (printed, [i, args]) => +        printed + +        printAligned(String(i + 1), i === iExpectedCall) + +        printReceivedArgs(args, expected) + +        '\n', +      '' +    ) +  ); +}; + +const printExpectedReceivedCallsPositive = ( +  expected, +  indexedCalls, +  expand, +  isOnlyCall, +  iExpectedCall +) => { +  const expectedLine = `Expected: ${printExpectedArgs(expected)}\n`; + +  if (indexedCalls.length === 0) { +    return expectedLine; +  } + +  const label = 'Received: '; + +  if (isOnlyCall && (iExpectedCall === 0 || iExpectedCall === undefined)) { +    const received = indexedCalls[0][1]; + +    if (isLineDiffableCall(expected, received)) { +      // Display diff without indentation. +      const lines = [ +        (0, _jestMatcherUtils.EXPECTED_COLOR)('- Expected'), +        (0, _jestMatcherUtils.RECEIVED_COLOR)('+ Received'), +        '' +      ]; +      const length = Math.max(expected.length, received.length); + +      for (let i = 0; i < length; i += 1) { +        if (i < expected.length && i < received.length) { +          if (isEqualValue(expected[i], received[i])) { +            lines.push(`  ${printCommon(received[i])},`); +            continue; +          } + +          if (isLineDiffableArg(expected[i], received[i])) { +            const difference = (0, _jestMatcherUtils.diff)( +              expected[i], +              received[i], +              { +                expand +              } +            ); + +            if ( +              typeof difference === 'string' && +              difference.includes('- Expected') && +              difference.includes('+ Received') +            ) { +              // Omit annotation in case multiple args have diff. +              lines.push(difference.split('\n').slice(3).join('\n') + ','); +              continue; +            } +          } +        } + +        if (i < expected.length) { +          lines.push( +            (0, _jestMatcherUtils.EXPECTED_COLOR)( +              '- ' + (0, _jestMatcherUtils.stringify)(expected[i]) +            ) + ',' +          ); +        } + +        if (i < received.length) { +          lines.push( +            (0, _jestMatcherUtils.RECEIVED_COLOR)( +              '+ ' + (0, _jestMatcherUtils.stringify)(received[i]) +            ) + ',' +          ); +        } +      } + +      return lines.join('\n') + '\n'; +    } + +    return expectedLine + label + printReceivedArgs(received, expected) + '\n'; +  } + +  const printAligned = getRightAlignedPrinter(label); +  return ( +    expectedLine + +    'Received\n' + +    indexedCalls.reduce((printed, [i, received]) => { +      const aligned = printAligned(String(i + 1), i === iExpectedCall); +      return ( +        printed + +        ((i === iExpectedCall || iExpectedCall === undefined) && +        isLineDiffableCall(expected, received) +          ? aligned.replace(': ', '\n') + +            printDiffCall(expected, received, expand) +          : aligned + printReceivedArgs(received, expected)) + +        '\n' +      ); +    }, '') +  ); +}; + +const indentation = 'Received'.replace(/\w/g, ' '); + +const printDiffCall = (expected, received, expand) => +  received +    .map((arg, i) => { +      if (i < expected.length) { +        if (isEqualValue(expected[i], arg)) { +          return indentation + '  ' + printCommon(arg) + ','; +        } + +        if (isLineDiffableArg(expected[i], arg)) { +          const difference = (0, _jestMatcherUtils.diff)(expected[i], arg, { +            expand +          }); + +          if ( +            typeof difference === 'string' && +            difference.includes('- Expected') && +            difference.includes('+ Received') +          ) { +            // Display diff with indentation. +            // Omit annotation in case multiple args have diff. +            return ( +              difference +                .split('\n') +                .slice(3) +                .map(line => indentation + line) +                .join('\n') + ',' +            ); +          } +        } +      } // Display + only if received arg has no corresponding expected arg. + +      return ( +        indentation + +        (i < expected.length +          ? '  ' + (0, _jestMatcherUtils.printReceived)(arg) +          : (0, _jestMatcherUtils.RECEIVED_COLOR)( +              '+ ' + (0, _jestMatcherUtils.stringify)(arg) +            )) + +        ',' +      ); +    }) +    .join('\n'); + +const isLineDiffableCall = (expected, received) => +  expected.some( +    (arg, i) => i < received.length && isLineDiffableArg(arg, received[i]) +  ); // Almost redundant with function in jest-matcher-utils, +// except no line diff for any strings. + +const isLineDiffableArg = (expected, received) => { +  const expectedType = (0, _jestGetType.getType)(expected); +  const receivedType = (0, _jestGetType.getType)(received); + +  if (expectedType !== receivedType) { +    return false; +  } + +  if ((0, _jestGetType.isPrimitive)(expected)) { +    return false; +  } + +  if ( +    expectedType === 'date' || +    expectedType === 'function' || +    expectedType === 'regexp' +  ) { +    return false; +  } + +  if (expected instanceof Error && received instanceof Error) { +    return false; +  } + +  if ( +    expectedType === 'object' && +    typeof expected.asymmetricMatch === 'function' +  ) { +    return false; +  } + +  if ( +    receivedType === 'object' && +    typeof received.asymmetricMatch === 'function' +  ) { +    return false; +  } + +  return true; +}; + +const printResult = (result, expected) => +  result.type === 'throw' +    ? 'function call threw an error' +    : result.type === 'incomplete' +    ? 'function call has not returned yet' +    : isEqualValue(expected, result.value) +    ? printCommon(result.value) +    : (0, _jestMatcherUtils.printReceived)(result.value); + +// Return either empty string or one line per indexed result, +// so additional empty line can separate from `Number of returns` which follows. +const printReceivedResults = ( +  label, +  expected, +  indexedResults, +  isOnlyCall, +  iExpectedCall +) => { +  if (indexedResults.length === 0) { +    return ''; +  } + +  if (isOnlyCall && (iExpectedCall === 0 || iExpectedCall === undefined)) { +    return label + printResult(indexedResults[0][1], expected) + '\n'; +  } + +  const printAligned = getRightAlignedPrinter(label); +  return ( +    label.replace(':', '').trim() + +    '\n' + +    indexedResults.reduce( +      (printed, [i, result]) => +        printed + +        printAligned(String(i + 1), i === iExpectedCall) + +        printResult(result, expected) + +        '\n', +      '' +    ) +  ); +}; + +const createToBeCalledMatcher = matcherName => +  function (received, expected) { +    const expectedArgument = ''; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    ensureMockOrSpy(received, matcherName, expectedArgument, options); +    const receivedIsSpy = isSpy(received); +    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)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of calls: ${(0, _jestMatcherUtils.printExpected)( +            0 +          )}\n` + +          `Received number of calls: ${(0, _jestMatcherUtils.printReceived)( +            count +          )}\n\n` + +          calls +            .reduce((lines, args, i) => { +              if (lines.length < PRINT_LIMIT) { +                lines.push(`${i + 1}: ${printReceivedArgs(args)}`); +              } + +              return lines; +            }, []) +            .join('\n') +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of calls: >= ${(0, _jestMatcherUtils.printExpected)( +            1 +          )}\n` + +          `Received number of calls:    ${(0, _jestMatcherUtils.printReceived)( +            count +          )}`; +    return { +      message, +      pass +    }; +  }; + +const createToReturnMatcher = matcherName => +  function (received, expected) { +    const expectedArgument = ''; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureNoExpected)(expected, matcherName, options); +    ensureMock(received, matcherName, expectedArgument, options); +    const receivedName = received.getMockName(); // Count return values that correspond only to calls that returned + +    const count = received.mock.results.reduce( +      (n, result) => (result.type === 'return' ? n + 1 : n), +      0 +    ); +    const pass = count > 0; +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of returns: ${(0, _jestMatcherUtils.printExpected)( +            0 +          )}\n` + +          `Received number of returns: ${(0, _jestMatcherUtils.printReceived)( +            count +          )}\n\n` + +          received.mock.results +            .reduce((lines, result, i) => { +              if (result.type === 'return' && lines.length < PRINT_LIMIT) { +                lines.push( +                  `${i + 1}: ${(0, _jestMatcherUtils.printReceived)( +                    result.value +                  )}` +                ); +              } + +              return lines; +            }, []) +            .join('\n') + +          (received.mock.calls.length !== count +            ? `\n\nReceived number of calls:   ${(0, +              _jestMatcherUtils.printReceived)(received.mock.calls.length)}` +            : '') +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of returns: >= ${(0, +          _jestMatcherUtils.printExpected)(1)}\n` + +          `Received number of returns:    ${(0, +          _jestMatcherUtils.printReceived)(count)}` + +          (received.mock.calls.length !== count +            ? `\nReceived number of calls:      ${(0, +              _jestMatcherUtils.printReceived)(received.mock.calls.length)}` +            : ''); +    return { +      message, +      pass +    }; +  }; + +const createToBeCalledTimesMatcher = matcherName => +  function (received, expected) { +    const expectedArgument = 'expected'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureExpectedIsNonNegativeInteger)( +      expected, +      matcherName, +      options +    ); +    ensureMockOrSpy(received, matcherName, expectedArgument, options); +    const receivedIsSpy = isSpy(received); +    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)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of calls: not ${(0, _jestMatcherUtils.printExpected)( +            expected +          )}` +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of calls: ${(0, _jestMatcherUtils.printExpected)( +            expected +          )}\n` + +          `Received number of calls: ${(0, _jestMatcherUtils.printReceived)( +            count +          )}`; +    return { +      message, +      pass +    }; +  }; + +const createToReturnTimesMatcher = matcherName => +  function (received, expected) { +    const expectedArgument = 'expected'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    (0, _jestMatcherUtils.ensureExpectedIsNonNegativeInteger)( +      expected, +      matcherName, +      options +    ); +    ensureMock(received, matcherName, expectedArgument, options); +    const receivedName = received.getMockName(); // Count return values that correspond only to calls that returned + +    const count = received.mock.results.reduce( +      (n, result) => (result.type === 'return' ? n + 1 : n), +      0 +    ); +    const pass = count === expected; +    const message = pass +      ? () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of returns: not ${(0, +          _jestMatcherUtils.printExpected)(expected)}` + +          (received.mock.calls.length !== count +            ? `\n\nReceived number of calls:       ${(0, +              _jestMatcherUtils.printReceived)(received.mock.calls.length)}` +            : '') +      : () => +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            receivedName, +            expectedArgument, +            options +          ) + +          '\n\n' + +          `Expected number of returns: ${(0, _jestMatcherUtils.printExpected)( +            expected +          )}\n` + +          `Received number of returns: ${(0, _jestMatcherUtils.printReceived)( +            count +          )}` + +          (received.mock.calls.length !== count +            ? `\nReceived number of calls:   ${(0, +              _jestMatcherUtils.printReceived)(received.mock.calls.length)}` +            : ''); +    return { +      message, +      pass +    }; +  }; + +const createToBeCalledWithMatcher = matcherName => +  function (received, ...expected) { +    const expectedArgument = '...expected'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    ensureMockOrSpy(received, matcherName, expectedArgument, options); +    const receivedIsSpy = isSpy(received); +    const receivedName = receivedIsSpy ? 'spy' : received.getMockName(); +    const calls = receivedIsSpy +      ? received.calls.all().map(x => x.args) +      : received.mock.calls; +    const pass = calls.some(call => isEqualCall(expected, call)); +    const message = pass +      ? () => { +          // Some examples of calls that are equal to expected value. +          const indexedCalls = []; +          let i = 0; + +          while (i < calls.length && indexedCalls.length < PRINT_LIMIT) { +            if (isEqualCall(expected, calls[i])) { +              indexedCalls.push([i, calls[i]]); +            } + +            i += 1; +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `Expected: not ${printExpectedArgs(expected)}\n` + +            (calls.length === 1 && +            (0, _jestMatcherUtils.stringify)(calls[0]) === +              (0, _jestMatcherUtils.stringify)(expected) +              ? '' +              : printReceivedCallsNegative( +                  expected, +                  indexedCalls, +                  calls.length === 1 +                )) + +            `\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)( +              calls.length +            )}` +          ); +        } +      : () => { +          // Some examples of calls that are not equal to expected value. +          const indexedCalls = []; +          let i = 0; + +          while (i < calls.length && indexedCalls.length < PRINT_LIMIT) { +            indexedCalls.push([i, calls[i]]); +            i += 1; +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            printExpectedReceivedCallsPositive( +              expected, +              indexedCalls, +              isExpand(this.expand), +              calls.length === 1 +            ) + +            `\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)( +              calls.length +            )}` +          ); +        }; +    return { +      message, +      pass +    }; +  }; + +const createToReturnWithMatcher = matcherName => +  function (received, expected) { +    const expectedArgument = 'expected'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    ensureMock(received, matcherName, expectedArgument, options); +    const receivedName = received.getMockName(); +    const {calls, results} = received.mock; +    const pass = results.some(result => isEqualReturn(expected, result)); +    const message = pass +      ? () => { +          // Some examples of results that are equal to expected value. +          const indexedResults = []; +          let i = 0; + +          while (i < results.length && indexedResults.length < PRINT_LIMIT) { +            if (isEqualReturn(expected, results[i])) { +              indexedResults.push([i, results[i]]); +            } + +            i += 1; +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `Expected: not ${(0, _jestMatcherUtils.printExpected)( +              expected +            )}\n` + +            (results.length === 1 && +            results[0].type === 'return' && +            (0, _jestMatcherUtils.stringify)(results[0].value) === +              (0, _jestMatcherUtils.stringify)(expected) +              ? '' +              : printReceivedResults( +                  'Received:     ', +                  expected, +                  indexedResults, +                  results.length === 1 +                )) + +            printNumberOfReturns(countReturns(results), calls.length) +          ); +        } +      : () => { +          // Some examples of results that are not equal to expected value. +          const indexedResults = []; +          let i = 0; + +          while (i < results.length && indexedResults.length < PRINT_LIMIT) { +            indexedResults.push([i, results[i]]); +            i += 1; +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + +            printReceivedResults( +              'Received: ', +              expected, +              indexedResults, +              results.length === 1 +            ) + +            printNumberOfReturns(countReturns(results), calls.length) +          ); +        }; +    return { +      message, +      pass +    }; +  }; + +const createLastCalledWithMatcher = matcherName => +  function (received, ...expected) { +    const expectedArgument = '...expected'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    ensureMockOrSpy(received, matcherName, expectedArgument, options); +    const receivedIsSpy = isSpy(received); +    const receivedName = receivedIsSpy ? 'spy' : received.getMockName(); +    const calls = receivedIsSpy +      ? received.calls.all().map(x => x.args) +      : received.mock.calls; +    const iLast = calls.length - 1; +    const pass = iLast >= 0 && isEqualCall(expected, calls[iLast]); +    const message = pass +      ? () => { +          const indexedCalls = []; + +          if (iLast > 0) { +            // Display preceding call as context. +            indexedCalls.push([iLast - 1, calls[iLast - 1]]); +          } + +          indexedCalls.push([iLast, calls[iLast]]); +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `Expected: not ${printExpectedArgs(expected)}\n` + +            (calls.length === 1 && +            (0, _jestMatcherUtils.stringify)(calls[0]) === +              (0, _jestMatcherUtils.stringify)(expected) +              ? '' +              : printReceivedCallsNegative( +                  expected, +                  indexedCalls, +                  calls.length === 1, +                  iLast +                )) + +            `\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)( +              calls.length +            )}` +          ); +        } +      : () => { +          const indexedCalls = []; + +          if (iLast >= 0) { +            if (iLast > 0) { +              let i = iLast - 1; // Is there a preceding call that is equal to expected args? + +              while (i >= 0 && !isEqualCall(expected, calls[i])) { +                i -= 1; +              } + +              if (i < 0) { +                i = iLast - 1; // otherwise, preceding call +              } + +              indexedCalls.push([i, calls[i]]); +            } + +            indexedCalls.push([iLast, calls[iLast]]); +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            printExpectedReceivedCallsPositive( +              expected, +              indexedCalls, +              isExpand(this.expand), +              calls.length === 1, +              iLast +            ) + +            `\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)( +              calls.length +            )}` +          ); +        }; +    return { +      message, +      pass +    }; +  }; + +const createLastReturnedMatcher = matcherName => +  function (received, expected) { +    const expectedArgument = 'expected'; +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    ensureMock(received, matcherName, expectedArgument, options); +    const receivedName = received.getMockName(); +    const {calls, results} = received.mock; +    const iLast = results.length - 1; +    const pass = iLast >= 0 && isEqualReturn(expected, results[iLast]); +    const message = pass +      ? () => { +          const indexedResults = []; + +          if (iLast > 0) { +            // Display preceding result as context. +            indexedResults.push([iLast - 1, results[iLast - 1]]); +          } + +          indexedResults.push([iLast, results[iLast]]); +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `Expected: not ${(0, _jestMatcherUtils.printExpected)( +              expected +            )}\n` + +            (results.length === 1 && +            results[0].type === 'return' && +            (0, _jestMatcherUtils.stringify)(results[0].value) === +              (0, _jestMatcherUtils.stringify)(expected) +              ? '' +              : printReceivedResults( +                  'Received:     ', +                  expected, +                  indexedResults, +                  results.length === 1, +                  iLast +                )) + +            printNumberOfReturns(countReturns(results), calls.length) +          ); +        } +      : () => { +          const indexedResults = []; + +          if (iLast >= 0) { +            if (iLast > 0) { +              let i = iLast - 1; // Is there a preceding result that is equal to expected value? + +              while (i >= 0 && !isEqualReturn(expected, results[i])) { +                i -= 1; +              } + +              if (i < 0) { +                i = iLast - 1; // otherwise, preceding result +              } + +              indexedResults.push([i, results[i]]); +            } + +            indexedResults.push([iLast, results[iLast]]); +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + +            printReceivedResults( +              'Received: ', +              expected, +              indexedResults, +              results.length === 1, +              iLast +            ) + +            printNumberOfReturns(countReturns(results), calls.length) +          ); +        }; +    return { +      message, +      pass +    }; +  }; + +const createNthCalledWithMatcher = matcherName => +  function (received, nth, ...expected) { +    const expectedArgument = 'n'; +    const options = { +      expectedColor: arg => arg, +      isNot: this.isNot, +      promise: this.promise, +      secondArgument: '...expected' +    }; +    ensureMockOrSpy(received, matcherName, expectedArgument, options); + +    if (!Number.isSafeInteger(nth) || nth < 1) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            expectedArgument, +            options +          ), +          `${expectedArgument} must be a positive integer`, +          (0, _jestMatcherUtils.printWithType)( +            expectedArgument, +            nth, +            _jestMatcherUtils.stringify +          ) +        ) +      ); +    } + +    const receivedIsSpy = isSpy(received); +    const receivedName = receivedIsSpy ? 'spy' : received.getMockName(); +    const calls = receivedIsSpy +      ? received.calls.all().map(x => x.args) +      : received.mock.calls; +    const length = calls.length; +    const iNth = nth - 1; +    const pass = iNth < length && isEqualCall(expected, calls[iNth]); +    const message = pass +      ? () => { +          // Display preceding and following calls, +          // in case assertions fails because index is off by one. +          const indexedCalls = []; + +          if (iNth - 1 >= 0) { +            indexedCalls.push([iNth - 1, calls[iNth - 1]]); +          } + +          indexedCalls.push([iNth, calls[iNth]]); + +          if (iNth + 1 < length) { +            indexedCalls.push([iNth + 1, calls[iNth + 1]]); +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `n: ${nth}\n` + +            `Expected: not ${printExpectedArgs(expected)}\n` + +            (calls.length === 1 && +            (0, _jestMatcherUtils.stringify)(calls[0]) === +              (0, _jestMatcherUtils.stringify)(expected) +              ? '' +              : printReceivedCallsNegative( +                  expected, +                  indexedCalls, +                  calls.length === 1, +                  iNth +                )) + +            `\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)( +              calls.length +            )}` +          ); +        } +      : () => { +          // Display preceding and following calls: +          // * nearest call that is equal to expected args +          // * otherwise, adjacent call +          // in case assertions fails because of index, especially off by one. +          const indexedCalls = []; + +          if (iNth < length) { +            if (iNth - 1 >= 0) { +              let i = iNth - 1; // Is there a preceding call that is equal to expected args? + +              while (i >= 0 && !isEqualCall(expected, calls[i])) { +                i -= 1; +              } + +              if (i < 0) { +                i = iNth - 1; // otherwise, adjacent call +              } + +              indexedCalls.push([i, calls[i]]); +            } + +            indexedCalls.push([iNth, calls[iNth]]); + +            if (iNth + 1 < length) { +              let i = iNth + 1; // Is there a following call that is equal to expected args? + +              while (i < length && !isEqualCall(expected, calls[i])) { +                i += 1; +              } + +              if (i >= length) { +                i = iNth + 1; // otherwise, adjacent call +              } + +              indexedCalls.push([i, calls[i]]); +            } +          } else if (length > 0) { +            // The number of received calls is fewer than the expected number. +            let i = length - 1; // Is there a call that is equal to expected args? + +            while (i >= 0 && !isEqualCall(expected, calls[i])) { +              i -= 1; +            } + +            if (i < 0) { +              i = length - 1; // otherwise, last call +            } + +            indexedCalls.push([i, calls[i]]); +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `n: ${nth}\n` + +            printExpectedReceivedCallsPositive( +              expected, +              indexedCalls, +              isExpand(this.expand), +              calls.length === 1, +              iNth +            ) + +            `\nNumber of calls: ${(0, _jestMatcherUtils.printReceived)( +              calls.length +            )}` +          ); +        }; +    return { +      message, +      pass +    }; +  }; + +const createNthReturnedWithMatcher = matcherName => +  function (received, nth, expected) { +    const expectedArgument = 'n'; +    const options = { +      expectedColor: arg => arg, +      isNot: this.isNot, +      promise: this.promise, +      secondArgument: 'expected' +    }; +    ensureMock(received, matcherName, expectedArgument, options); + +    if (!Number.isSafeInteger(nth) || nth < 1) { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            expectedArgument, +            options +          ), +          `${expectedArgument} must be a positive integer`, +          (0, _jestMatcherUtils.printWithType)( +            expectedArgument, +            nth, +            _jestMatcherUtils.stringify +          ) +        ) +      ); +    } + +    const receivedName = received.getMockName(); +    const {calls, results} = received.mock; +    const length = results.length; +    const iNth = nth - 1; +    const pass = iNth < length && isEqualReturn(expected, results[iNth]); +    const message = pass +      ? () => { +          // Display preceding and following results, +          // in case assertions fails because index is off by one. +          const indexedResults = []; + +          if (iNth - 1 >= 0) { +            indexedResults.push([iNth - 1, results[iNth - 1]]); +          } + +          indexedResults.push([iNth, results[iNth]]); + +          if (iNth + 1 < length) { +            indexedResults.push([iNth + 1, results[iNth + 1]]); +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `n: ${nth}\n` + +            `Expected: not ${(0, _jestMatcherUtils.printExpected)( +              expected +            )}\n` + +            (results.length === 1 && +            results[0].type === 'return' && +            (0, _jestMatcherUtils.stringify)(results[0].value) === +              (0, _jestMatcherUtils.stringify)(expected) +              ? '' +              : printReceivedResults( +                  'Received:     ', +                  expected, +                  indexedResults, +                  results.length === 1, +                  iNth +                )) + +            printNumberOfReturns(countReturns(results), calls.length) +          ); +        } +      : () => { +          // Display preceding and following results: +          // * nearest result that is equal to expected value +          // * otherwise, adjacent result +          // in case assertions fails because of index, especially off by one. +          const indexedResults = []; + +          if (iNth < length) { +            if (iNth - 1 >= 0) { +              let i = iNth - 1; // Is there a preceding result that is equal to expected value? + +              while (i >= 0 && !isEqualReturn(expected, results[i])) { +                i -= 1; +              } + +              if (i < 0) { +                i = iNth - 1; // otherwise, adjacent result +              } + +              indexedResults.push([i, results[i]]); +            } + +            indexedResults.push([iNth, results[iNth]]); + +            if (iNth + 1 < length) { +              let i = iNth + 1; // Is there a following result that is equal to expected value? + +              while (i < length && !isEqualReturn(expected, results[i])) { +                i += 1; +              } + +              if (i >= length) { +                i = iNth + 1; // otherwise, adjacent result +              } + +              indexedResults.push([i, results[i]]); +            } +          } else if (length > 0) { +            // The number of received calls is fewer than the expected number. +            let i = length - 1; // Is there a result that is equal to expected value? + +            while (i >= 0 && !isEqualReturn(expected, results[i])) { +              i -= 1; +            } + +            if (i < 0) { +              i = length - 1; // otherwise, last result +            } + +            indexedResults.push([i, results[i]]); +          } + +          return ( +            (0, _jestMatcherUtils.matcherHint)( +              matcherName, +              receivedName, +              expectedArgument, +              options +            ) + +            '\n\n' + +            `n: ${nth}\n` + +            `Expected: ${(0, _jestMatcherUtils.printExpected)(expected)}\n` + +            printReceivedResults( +              'Received: ', +              expected, +              indexedResults, +              results.length === 1, +              iNth +            ) + +            printNumberOfReturns(countReturns(results), calls.length) +          ); +        }; +    return { +      message, +      pass +    }; +  }; + +const spyMatchers = { +  lastCalledWith: createLastCalledWithMatcher('lastCalledWith'), +  lastReturnedWith: createLastReturnedMatcher('lastReturnedWith'), +  nthCalledWith: createNthCalledWithMatcher('nthCalledWith'), +  nthReturnedWith: createNthReturnedWithMatcher('nthReturnedWith'), +  toBeCalled: createToBeCalledMatcher('toBeCalled'), +  toBeCalledTimes: createToBeCalledTimesMatcher('toBeCalledTimes'), +  toBeCalledWith: createToBeCalledWithMatcher('toBeCalledWith'), +  toHaveBeenCalled: createToBeCalledMatcher('toHaveBeenCalled'), +  toHaveBeenCalledTimes: createToBeCalledTimesMatcher('toHaveBeenCalledTimes'), +  toHaveBeenCalledWith: createToBeCalledWithMatcher('toHaveBeenCalledWith'), +  toHaveBeenLastCalledWith: createLastCalledWithMatcher( +    'toHaveBeenLastCalledWith' +  ), +  toHaveBeenNthCalledWith: createNthCalledWithMatcher( +    'toHaveBeenNthCalledWith' +  ), +  toHaveLastReturnedWith: createLastReturnedMatcher('toHaveLastReturnedWith'), +  toHaveNthReturnedWith: createNthReturnedWithMatcher('toHaveNthReturnedWith'), +  toHaveReturned: createToReturnMatcher('toHaveReturned'), +  toHaveReturnedTimes: createToReturnTimesMatcher('toHaveReturnedTimes'), +  toHaveReturnedWith: createToReturnWithMatcher('toHaveReturnedWith'), +  toReturn: createToReturnMatcher('toReturn'), +  toReturnTimes: createToReturnTimesMatcher('toReturnTimes'), +  toReturnWith: createToReturnWithMatcher('toReturnWith') +}; + +const isMock = received => +  received != null && received._isMockFunction === true; + +const isSpy = received => +  received != null && +  received.calls != null && +  typeof received.calls.all === 'function' && +  typeof received.calls.count === 'function'; + +const ensureMockOrSpy = (received, matcherName, expectedArgument, options) => { +  if (!isMock(received) && !isSpy(received)) { +    throw new Error( +      (0, _jestMatcherUtils.matcherErrorMessage)( +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          expectedArgument, +          options +        ), +        `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +          'received' +        )} value must be a mock or spy function`, +        (0, _jestMatcherUtils.printWithType)( +          'Received', +          received, +          _jestMatcherUtils.printReceived +        ) +      ) +    ); +  } +}; + +const ensureMock = (received, matcherName, expectedArgument, options) => { +  if (!isMock(received)) { +    throw new Error( +      (0, _jestMatcherUtils.matcherErrorMessage)( +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          expectedArgument, +          options +        ), +        `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +          'received' +        )} value must be a mock function`, +        (0, _jestMatcherUtils.printWithType)( +          'Received', +          received, +          _jestMatcherUtils.printReceived +        ) +      ) +    ); +  } +}; + +var _default = spyMatchers; +exports.default = _default; diff --git a/node_modules/expect/build/toThrowMatchers.d.ts b/node_modules/expect/build/toThrowMatchers.d.ts new file mode 100644 index 0000000..d4967c0 --- /dev/null +++ b/node_modules/expect/build/toThrowMatchers.d.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +import type { MatchersObject, RawMatcherFn } from './types'; +export declare const createMatcher: (matcherName: string, fromPromise?: boolean | undefined) => RawMatcherFn; +declare const matchers: MatchersObject; +export default matchers; diff --git a/node_modules/expect/build/toThrowMatchers.js b/node_modules/expect/build/toThrowMatchers.js new file mode 100644 index 0000000..f34f236 --- /dev/null +++ b/node_modules/expect/build/toThrowMatchers.js @@ -0,0 +1,464 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = exports.createMatcher = void 0; + +var _jestMatcherUtils = require('jest-matcher-utils'); + +var _jestMessageUtil = require('jest-message-util'); + +var _print = require('./print'); + +var _utils = require('./utils'); + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ + +/* eslint-disable local/ban-types-eventually */ +const DID_NOT_THROW = 'Received function did not throw'; + +const getThrown = e => { +  const hasMessage = +    e !== null && e !== undefined && typeof e.message === 'string'; + +  if (hasMessage && typeof e.name === 'string' && typeof e.stack === 'string') { +    return { +      hasMessage, +      isError: true, +      message: e.message, +      value: e +    }; +  } + +  return { +    hasMessage, +    isError: false, +    message: hasMessage ? e.message : String(e), +    value: e +  }; +}; + +const createMatcher = (matcherName, fromPromise) => +  function (received, expected) { +    const options = { +      isNot: this.isNot, +      promise: this.promise +    }; +    let thrown = null; + +    if (fromPromise && (0, _utils.isError)(received)) { +      thrown = getThrown(received); +    } else { +      if (typeof received !== 'function') { +        if (!fromPromise) { +          const placeholder = expected === undefined ? '' : 'expected'; +          throw new Error( +            (0, _jestMatcherUtils.matcherErrorMessage)( +              (0, _jestMatcherUtils.matcherHint)( +                matcherName, +                undefined, +                placeholder, +                options +              ), +              `${(0, _jestMatcherUtils.RECEIVED_COLOR)( +                'received' +              )} value must be a function`, +              (0, _jestMatcherUtils.printWithType)( +                'Received', +                received, +                _jestMatcherUtils.printReceived +              ) +            ) +          ); +        } +      } else { +        try { +          received(); +        } catch (e) { +          thrown = getThrown(e); +        } +      } +    } + +    if (expected === undefined) { +      return toThrow(matcherName, options, thrown); +    } else if (typeof expected === 'function') { +      return toThrowExpectedClass(matcherName, options, thrown, expected); +    } else if (typeof expected === 'string') { +      return toThrowExpectedString(matcherName, options, thrown, expected); +    } else if (expected !== null && typeof expected.test === 'function') { +      return toThrowExpectedRegExp(matcherName, options, thrown, expected); +    } else if ( +      expected !== null && +      typeof expected.asymmetricMatch === 'function' +    ) { +      return toThrowExpectedAsymmetric(matcherName, options, thrown, expected); +    } else if (expected !== null && typeof expected === 'object') { +      return toThrowExpectedObject(matcherName, options, thrown, expected); +    } else { +      throw new Error( +        (0, _jestMatcherUtils.matcherErrorMessage)( +          (0, _jestMatcherUtils.matcherHint)( +            matcherName, +            undefined, +            undefined, +            options +          ), +          `${(0, _jestMatcherUtils.EXPECTED_COLOR)( +            'expected' +          )} value must be a string or regular expression or class or error`, +          (0, _jestMatcherUtils.printWithType)( +            'Expected', +            expected, +            _jestMatcherUtils.printExpected +          ) +        ) +      ); +    } +  }; + +exports.createMatcher = createMatcher; +const matchers = { +  toThrow: createMatcher('toThrow'), +  toThrowError: createMatcher('toThrowError') +}; + +const toThrowExpectedRegExp = (matcherName, options, thrown, expected) => { +  const pass = thrown !== null && expected.test(thrown.message); +  const message = pass +    ? () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        formatExpected('Expected pattern: not ', expected) + +        (thrown !== null && thrown.hasMessage +          ? formatReceived( +              'Received message:     ', +              thrown, +              'message', +              expected +            ) + formatStack(thrown) +          : formatReceived('Received value:       ', thrown, 'value')) +    : () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        formatExpected('Expected pattern: ', expected) + +        (thrown === null +          ? '\n' + DID_NOT_THROW +          : thrown.hasMessage +          ? formatReceived('Received message: ', thrown, 'message') + +            formatStack(thrown) +          : formatReceived('Received value:   ', thrown, 'value')); +  return { +    message, +    pass +  }; +}; + +const toThrowExpectedAsymmetric = (matcherName, options, thrown, expected) => { +  const pass = thrown !== null && expected.asymmetricMatch(thrown.value); +  const message = pass +    ? () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        formatExpected('Expected asymmetric matcher: not ', expected) + +        '\n' + +        (thrown !== null && thrown.hasMessage +          ? formatReceived('Received name:    ', thrown, 'name') + +            formatReceived('Received message: ', thrown, 'message') + +            formatStack(thrown) +          : formatReceived('Thrown value: ', thrown, 'value')) +    : () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        formatExpected('Expected asymmetric matcher: ', expected) + +        '\n' + +        (thrown === null +          ? DID_NOT_THROW +          : thrown.hasMessage +          ? formatReceived('Received name:    ', thrown, 'name') + +            formatReceived('Received message: ', thrown, 'message') + +            formatStack(thrown) +          : formatReceived('Thrown value: ', thrown, 'value')); +  return { +    message, +    pass +  }; +}; + +const toThrowExpectedObject = (matcherName, options, thrown, expected) => { +  const pass = thrown !== null && thrown.message === expected.message; +  const message = pass +    ? () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        formatExpected('Expected message: not ', expected.message) + +        (thrown !== null && thrown.hasMessage +          ? formatStack(thrown) +          : formatReceived('Received value:       ', thrown, 'value')) +    : () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        (thrown === null +          ? formatExpected('Expected message: ', expected.message) + +            '\n' + +            DID_NOT_THROW +          : thrown.hasMessage +          ? (0, _jestMatcherUtils.printDiffOrStringify)( +              expected.message, +              thrown.message, +              'Expected message', +              'Received message', +              true +            ) + +            '\n' + +            formatStack(thrown) +          : formatExpected('Expected message: ', expected.message) + +            formatReceived('Received value:   ', thrown, 'value')); +  return { +    message, +    pass +  }; +}; + +const toThrowExpectedClass = (matcherName, options, thrown, expected) => { +  const pass = thrown !== null && thrown.value instanceof expected; +  const message = pass +    ? () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        (0, _print.printExpectedConstructorNameNot)( +          'Expected constructor', +          expected +        ) + +        (thrown !== null && +        thrown.value != null && +        typeof thrown.value.constructor === 'function' && +        thrown.value.constructor !== expected +          ? (0, _print.printReceivedConstructorNameNot)( +              'Received constructor', +              thrown.value.constructor, +              expected +            ) +          : '') + +        '\n' + +        (thrown !== null && thrown.hasMessage +          ? formatReceived('Received message: ', thrown, 'message') + +            formatStack(thrown) +          : formatReceived('Received value: ', thrown, 'value')) +    : () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        (0, _print.printExpectedConstructorName)( +          'Expected constructor', +          expected +        ) + +        (thrown === null +          ? '\n' + DID_NOT_THROW +          : (thrown.value != null && +            typeof thrown.value.constructor === 'function' +              ? (0, _print.printReceivedConstructorName)( +                  'Received constructor', +                  thrown.value.constructor +                ) +              : '') + +            '\n' + +            (thrown.hasMessage +              ? formatReceived('Received message: ', thrown, 'message') + +                formatStack(thrown) +              : formatReceived('Received value: ', thrown, 'value'))); +  return { +    message, +    pass +  }; +}; + +const toThrowExpectedString = (matcherName, options, thrown, expected) => { +  const pass = thrown !== null && thrown.message.includes(expected); +  const message = pass +    ? () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        formatExpected('Expected substring: not ', expected) + +        (thrown !== null && thrown.hasMessage +          ? formatReceived( +              'Received message:       ', +              thrown, +              'message', +              expected +            ) + formatStack(thrown) +          : formatReceived('Received value:         ', thrown, 'value')) +    : () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          undefined, +          options +        ) + +        '\n\n' + +        formatExpected('Expected substring: ', expected) + +        (thrown === null +          ? '\n' + DID_NOT_THROW +          : thrown.hasMessage +          ? formatReceived('Received message:   ', thrown, 'message') + +            formatStack(thrown) +          : formatReceived('Received value:     ', thrown, 'value')); +  return { +    message, +    pass +  }; +}; + +const toThrow = (matcherName, options, thrown) => { +  const pass = thrown !== null; +  const message = pass +    ? () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          '', +          options +        ) + +        '\n\n' + +        (thrown !== null && thrown.hasMessage +          ? formatReceived('Error name:    ', thrown, 'name') + +            formatReceived('Error message: ', thrown, 'message') + +            formatStack(thrown) +          : formatReceived('Thrown value: ', thrown, 'value')) +    : () => +        (0, _jestMatcherUtils.matcherHint)( +          matcherName, +          undefined, +          '', +          options +        ) + +        '\n\n' + +        DID_NOT_THROW; +  return { +    message, +    pass +  }; +}; + +const formatExpected = (label, expected) => +  label + (0, _jestMatcherUtils.printExpected)(expected) + '\n'; + +const formatReceived = (label, thrown, key, expected) => { +  if (thrown === null) { +    return ''; +  } + +  if (key === 'message') { +    const message = thrown.message; + +    if (typeof expected === 'string') { +      const index = message.indexOf(expected); + +      if (index !== -1) { +        return ( +          label + +          (0, _print.printReceivedStringContainExpectedSubstring)( +            message, +            index, +            expected.length +          ) + +          '\n' +        ); +      } +    } else if (expected instanceof RegExp) { +      return ( +        label + +        (0, _print.printReceivedStringContainExpectedResult)( +          message, +          typeof expected.exec === 'function' ? expected.exec(message) : null +        ) + +        '\n' +      ); +    } + +    return label + (0, _jestMatcherUtils.printReceived)(message) + '\n'; +  } + +  if (key === 'name') { +    return thrown.isError +      ? label + (0, _jestMatcherUtils.printReceived)(thrown.value.name) + '\n' +      : ''; +  } + +  if (key === 'value') { +    return thrown.isError +      ? '' +      : label + (0, _jestMatcherUtils.printReceived)(thrown.value) + '\n'; +  } + +  return ''; +}; + +const formatStack = thrown => +  thrown === null || !thrown.isError +    ? '' +    : (0, _jestMessageUtil.formatStackTrace)( +        (0, _jestMessageUtil.separateMessageFromStack)(thrown.value.stack) +          .stack, +        { +          rootDir: process.cwd(), +          testMatch: [] +        }, +        { +          noStackTrace: false +        } +      ); + +var _default = matchers; +exports.default = _default; diff --git a/node_modules/expect/build/types.d.ts b/node_modules/expect/build/types.d.ts new file mode 100644 index 0000000..1cd7631 --- /dev/null +++ b/node_modules/expect/build/types.d.ts @@ -0,0 +1,327 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +import type { Config } from '@jest/types'; +import type * as jestMatcherUtils from 'jest-matcher-utils'; +import { INTERNAL_MATCHER_FLAG } from './jestMatchersObject'; +export declare type SyncExpectationResult = { +    pass: boolean; +    message: () => string; +}; +export declare type AsyncExpectationResult = Promise<SyncExpectationResult>; +export declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult; +export declare type RawMatcherFn<T extends MatcherState = MatcherState> = { +    (this: T, received: any, expected: any, options?: any): ExpectationResult; +    [INTERNAL_MATCHER_FLAG]?: boolean; +}; +export declare type ThrowingMatcherFn = (actual: any) => void; +export declare type PromiseMatcherFn = (actual: any) => Promise<void>; +export declare type Tester = (a: any, b: any) => boolean | undefined; +export declare type MatcherState = { +    assertionCalls: number; +    currentTestName?: string; +    dontThrow?: () => void; +    error?: Error; +    equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean; +    expand?: boolean; +    expectedAssertionsNumber?: number | null; +    expectedAssertionsNumberError?: Error; +    isExpectingAssertions?: boolean; +    isExpectingAssertionsError?: Error; +    isNot: boolean; +    promise: string; +    suppressedErrors: Array<Error>; +    testPath?: Config.Path; +    utils: typeof jestMatcherUtils & { +        iterableEquality: Tester; +        subsetEquality: Tester; +    }; +}; +export interface AsymmetricMatcher { +    asymmetricMatch(other: unknown): boolean; +    toString(): string; +    getExpectedType?(): string; +    toAsymmetricMatcher?(): string; +} +export declare type MatchersObject<T extends MatcherState = MatcherState> = { +    [id: string]: RawMatcherFn<T>; +}; +export declare type ExpectedAssertionsErrors = Array<{ +    actual: string | number; +    error: Error; +    expected: string; +}>; +interface AsymmetricMatchers { +    any(sample: unknown): AsymmetricMatcher; +    anything(): AsymmetricMatcher; +    arrayContaining(sample: Array<unknown>): AsymmetricMatcher; +    closeTo(sample: number, precision?: number): AsymmetricMatcher; +    objectContaining(sample: Record<string, unknown>): AsymmetricMatcher; +    stringContaining(sample: string): AsymmetricMatcher; +    stringMatching(sample: string | RegExp): AsymmetricMatcher; +} +export declare type Expect<State extends MatcherState = MatcherState> = { +    <T = unknown>(actual: T): Matchers<void, T>; +    addSnapshotSerializer(serializer: unknown): void; +    assertions(numberOfAssertions: number): void; +    extend<T extends MatcherState = State>(matchers: MatchersObject<T>): void; +    extractExpectedAssertionsErrors: () => ExpectedAssertionsErrors; +    getState(): State; +    hasAssertions(): void; +    setState(state: Partial<State>): void; +} & AsymmetricMatchers & { +    not: Omit<AsymmetricMatchers, 'any' | 'anything'>; +}; +export interface Matchers<R, T = unknown> { +    /** +     * Ensures the last call to a mock function was provided specific args. +     */ +    lastCalledWith(...expected: [unknown, ...Array<unknown>]): R; +    /** +     * Ensure that the last call to a mock function has returned a specified value. +     */ +    lastReturnedWith(expected: unknown): R; +    /** +     * If you know how to test something, `.not` lets you test its opposite. +     */ +    not: Matchers<R, T>; +    /** +     * Ensure that a mock function is called with specific arguments on an Nth call. +     */ +    nthCalledWith(nth: number, ...expected: [unknown, ...Array<unknown>]): R; +    /** +     * Ensure that the nth call to a mock function has returned a specified value. +     */ +    nthReturnedWith(nth: number, expected: unknown): R; +    /** +     * Use resolves to unwrap the value of a fulfilled promise so any other +     * matcher can be chained. If the promise is rejected the assertion fails. +     */ +    resolves: Matchers<Promise<R>, T>; +    /** +     * Unwraps the reason of a rejected promise so any other matcher can be chained. +     * If the promise is fulfilled the assertion fails. +     */ +    rejects: Matchers<Promise<R>, T>; +    /** +     * Checks that a value is what you expect. It uses `===` to check strict equality. +     * Don't use `toBe` with floating-point numbers. +     */ +    toBe(expected: unknown): R; +    /** +     * Ensures that a mock function is called. +     */ +    toBeCalled(): R; +    /** +     * Ensures that a mock function is called an exact number of times. +     */ +    toBeCalledTimes(expected: number): R; +    /** +     * Ensure that a mock function is called with specific arguments. +     */ +    toBeCalledWith(...expected: [unknown, ...Array<unknown>]): R; +    /** +     * Using exact equality with floating point numbers is a bad idea. +     * Rounding means that intuitive things fail. +     * The default for `precision` is 2. +     */ +    toBeCloseTo(expected: number, precision?: number): R; +    /** +     * Ensure that a variable is not undefined. +     */ +    toBeDefined(): R; +    /** +     * When you don't care what a value is, you just want to +     * ensure a value is false in a boolean context. +     */ +    toBeFalsy(): R; +    /** +     * For comparing floating point numbers. +     */ +    toBeGreaterThan(expected: number | bigint): R; +    /** +     * For comparing floating point numbers. +     */ +    toBeGreaterThanOrEqual(expected: number | bigint): R; +    /** +     * Ensure that an object is an instance of a class. +     * This matcher uses `instanceof` underneath. +     */ +    toBeInstanceOf(expected: unknown): R; +    /** +     * For comparing floating point numbers. +     */ +    toBeLessThan(expected: number | bigint): R; +    /** +     * For comparing floating point numbers. +     */ +    toBeLessThanOrEqual(expected: number | bigint): R; +    /** +     * This is the same as `.toBe(null)` but the error messages are a bit nicer. +     * So use `.toBeNull()` when you want to check that something is null. +     */ +    toBeNull(): R; +    /** +     * Use when you don't care what a value is, you just want to ensure a value +     * is true in a boolean context. In JavaScript, there are six falsy values: +     * `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy. +     */ +    toBeTruthy(): R; +    /** +     * Used to check that a variable is undefined. +     */ +    toBeUndefined(): R; +    /** +     * Used to check that a variable is NaN. +     */ +    toBeNaN(): R; +    /** +     * Used when you want to check that an item is in a list. +     * For testing the items in the list, this uses `===`, a strict equality check. +     */ +    toContain(expected: unknown): R; +    /** +     * Used when you want to check that an item is in a list. +     * For testing the items in the list, this  matcher recursively checks the +     * equality of all fields, rather than checking for object identity. +     */ +    toContainEqual(expected: unknown): R; +    /** +     * Used when you want to check that two objects have the same value. +     * This matcher recursively checks the equality of all fields, rather than checking for object identity. +     */ +    toEqual(expected: unknown): R; +    /** +     * Ensures that a mock function is called. +     */ +    toHaveBeenCalled(): R; +    /** +     * Ensures that a mock function is called an exact number of times. +     */ +    toHaveBeenCalledTimes(expected: number): R; +    /** +     * Ensure that a mock function is called with specific arguments. +     */ +    toHaveBeenCalledWith(...expected: [unknown, ...Array<unknown>]): R; +    /** +     * Ensure that a mock function is called with specific arguments on an Nth call. +     */ +    toHaveBeenNthCalledWith(nth: number, ...expected: [unknown, ...Array<unknown>]): R; +    /** +     * If you have a mock function, you can use `.toHaveBeenLastCalledWith` +     * to test what arguments it was last called with. +     */ +    toHaveBeenLastCalledWith(...expected: [unknown, ...Array<unknown>]): R; +    /** +     * Use to test the specific value that a mock function last returned. +     * If the last call to the mock function threw an error, then this matcher will fail +     * no matter what value you provided as the expected return value. +     */ +    toHaveLastReturnedWith(expected: unknown): R; +    /** +     * Used to check that an object has a `.length` property +     * and it is set to a certain numeric value. +     */ +    toHaveLength(expected: number): R; +    /** +     * Use to test the specific value that a mock function returned for the nth call. +     * If the nth call to the mock function threw an error, then this matcher will fail +     * no matter what value you provided as the expected return value. +     */ +    toHaveNthReturnedWith(nth: number, expected: unknown): R; +    /** +     * Use to check if property at provided reference keyPath exists for an object. +     * For checking deeply nested properties in an object you may use dot notation or an array containing +     * the keyPath for deep references. +     * +     * Optionally, you can provide a value to check if it's equal to the value present at keyPath +     * on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks +     * the equality of all fields. +     * +     * @example +     * +     * expect(houseForSale).toHaveProperty('kitchen.area', 20); +     */ +    toHaveProperty(expectedPath: string | Array<string>, expectedValue?: unknown): R; +    /** +     * Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time +     */ +    toHaveReturned(): R; +    /** +     * Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times. +     * Any calls to the mock function that throw an error are not counted toward the number of times the function returned. +     */ +    toHaveReturnedTimes(expected: number): R; +    /** +     * Use to ensure that a mock function returned a specific value. +     */ +    toHaveReturnedWith(expected: unknown): R; +    /** +     * Check that a string matches a regular expression. +     */ +    toMatch(expected: string | RegExp): R; +    /** +     * Used to check that a JavaScript object matches a subset of the properties of an object +     */ +    toMatchObject(expected: Record<string, unknown> | Array<Record<string, unknown>>): R; +    /** +     * Ensure that a mock function has returned (as opposed to thrown) at least once. +     */ +    toReturn(): R; +    /** +     * Ensure that a mock function has returned (as opposed to thrown) a specified number of times. +     */ +    toReturnTimes(expected: number): R; +    /** +     * Ensure that a mock function has returned a specified value at least once. +     */ +    toReturnWith(expected: unknown): R; +    /** +     * Use to test that objects have the same types as well as structure. +     */ +    toStrictEqual(expected: unknown): R; +    /** +     * Used to test that a function throws when it is called. +     */ +    toThrow(expected?: unknown): R; +    /** +     * If you want to test that a specific error is thrown inside a function. +     */ +    toThrowError(expected?: unknown): R; +    /** +     * This ensures that a value matches the most recent snapshot with property matchers. +     * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. +     */ +    toMatchSnapshot(hint?: string): R; +    /** +     * This ensures that a value matches the most recent snapshot. +     * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. +     */ +    toMatchSnapshot<U extends Record<keyof T, unknown>>(propertyMatchers: Partial<U>, hint?: string): R; +    /** +     * This ensures that a value matches the most recent snapshot with property matchers. +     * Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically. +     * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. +     */ +    toMatchInlineSnapshot(snapshot?: string): R; +    /** +     * This ensures that a value matches the most recent snapshot with property matchers. +     * Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically. +     * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. +     */ +    toMatchInlineSnapshot<U extends Record<keyof T, unknown>>(propertyMatchers: Partial<U>, snapshot?: string): R; +    /** +     * Used to test that a function throws a error matching the most recent snapshot when it is called. +     */ +    toThrowErrorMatchingSnapshot(hint?: string): R; +    /** +     * Used to test that a function throws a error matching the most recent snapshot when it is called. +     * Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically. +     */ +    toThrowErrorMatchingInlineSnapshot(snapshot?: string): R; +} +export {}; diff --git a/node_modules/expect/build/types.js b/node_modules/expect/build/types.js new file mode 100644 index 0000000..7a223e4 --- /dev/null +++ b/node_modules/expect/build/types.js @@ -0,0 +1,3 @@ +'use strict'; + +var _jestMatchersObject = require('./jestMatchersObject'); diff --git a/node_modules/expect/build/utils.d.ts b/node_modules/expect/build/utils.d.ts new file mode 100644 index 0000000..e510748 --- /dev/null +++ b/node_modules/expect/build/utils.d.ts @@ -0,0 +1,26 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + * + */ +declare type GetPath = { +    hasEndProp?: boolean; +    lastTraversedObject: unknown; +    traversedPath: Array<string>; +    value?: unknown; +}; +export declare const getPath: (object: Record<string, any>, propertyPath: string | Array<string>) => GetPath; +export declare const getObjectSubset: (object: any, subset: any, seenReferences?: WeakMap<object, boolean>) => any; +export declare const iterableEquality: (a: any, b: any, aStack?: Array<any>, bStack?: Array<any>) => boolean | undefined; +export declare const subsetEquality: (object: unknown, subset: unknown) => boolean | undefined; +export declare const typeEquality: (a: any, b: any) => boolean | undefined; +export declare const arrayBufferEquality: (a: unknown, b: unknown) => boolean | undefined; +export declare const sparseArrayEquality: (a: unknown, b: unknown) => boolean | undefined; +export declare const partition: <T>(items: T[], predicate: (arg: T) => boolean) => [T[], T[]]; +export declare const pathAsArray: (propertyPath: string) => Array<any>; +export declare const isError: (value: unknown) => value is Error; +export declare function emptyObject(obj: unknown): boolean; +export declare const isOneline: (expected: unknown, received: unknown) => boolean; +export {}; diff --git a/node_modules/expect/build/utils.js b/node_modules/expect/build/utils.js new file mode 100644 index 0000000..66d3144 --- /dev/null +++ b/node_modules/expect/build/utils.js @@ -0,0 +1,458 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.arrayBufferEquality = void 0; +exports.emptyObject = emptyObject; +exports.typeEquality = +  exports.subsetEquality = +  exports.sparseArrayEquality = +  exports.pathAsArray = +  exports.partition = +  exports.iterableEquality = +  exports.isOneline = +  exports.isError = +  exports.getPath = +  exports.getObjectSubset = +    void 0; + +var _jestGetType = require('jest-get-type'); + +var _jasmineUtils = require('./jasmineUtils'); + +var global = (function () { +  if (typeof globalThis !== 'undefined') { +    return globalThis; +  } else if (typeof global !== 'undefined') { +    return global; +  } else if (typeof self !== 'undefined') { +    return self; +  } else if (typeof window !== 'undefined') { +    return window; +  } else { +    return Function('return this')(); +  } +})(); + +var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol; + +/** + * Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`. + */ +const hasPropertyInObject = (object, key) => { +  const shouldTerminate = +    !object || typeof object !== 'object' || object === Object.prototype; + +  if (shouldTerminate) { +    return false; +  } + +  return ( +    Object.prototype.hasOwnProperty.call(object, key) || +    hasPropertyInObject(Object.getPrototypeOf(object), key) +  ); +}; + +const getPath = (object, propertyPath) => { +  if (!Array.isArray(propertyPath)) { +    propertyPath = pathAsArray(propertyPath); +  } + +  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) { +      // Does object have the property with an undefined value? +      // Although primitive values support bracket notation (above) +      // they would throw TypeError for in operator (below). +      result.hasEndProp = +        newObject !== undefined || +        (!(0, _jestGetType.isPrimitive)(object) && prop in object); + +      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. + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ + +exports.getPath = getPath; + +const getObjectSubset = (object, subset, seenReferences = new WeakMap()) => { +  /* eslint-enable @typescript-eslint/explicit-module-boundary-types */ +  if (Array.isArray(object)) { +    if (Array.isArray(subset) && subset.length === object.length) { +      // The map method returns correct subclass of subset. +      return subset.map((sub, i) => getObjectSubset(object[i], sub)); +    } +  } else if (object instanceof Date) { +    return object; +  } else if (isObject(object) && isObject(subset)) { +    if ( +      (0, _jasmineUtils.equals)(object, subset, [ +        iterableEquality, +        subsetEquality +      ]) +    ) { +      // Avoid unnecessary copy which might return Object instead of subclass. +      return subset; +    } + +    const trimmed = {}; +    seenReferences.set(object, trimmed); +    Object.keys(object) +      .filter(key => hasPropertyInObject(subset, key)) +      .forEach(key => { +        trimmed[key] = seenReferences.has(object[key]) +          ? seenReferences.get(object[key]) +          : getObjectSubset(object[key], subset[key], seenReferences); +      }); + +    if (Object.keys(trimmed).length > 0) { +      return trimmed; +    } +  } + +  return object; +}; + +exports.getObjectSubset = getObjectSubset; +const IteratorSymbol = Symbol.iterator; + +const hasIterator = object => !!(object != null && object[IteratorSymbol]); +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ + +const iterableEquality = ( +  a, +  b, +  /* eslint-enable @typescript-eslint/explicit-module-boundary-types */ +  aStack = [], +  bStack = [] +) => { +  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; +  } + +  let length = aStack.length; + +  while (length--) { +    // Linear search. Performance is inversely proportional to the number of +    // unique nested structures. +    // circular references at same depth are equal +    // circular reference is not equal to non-circular one +    if (aStack[length] === a) { +      return bStack[length] === b; +    } +  } + +  aStack.push(a); +  bStack.push(b); + +  const iterableEqualityWithStack = (a, b) => +    iterableEquality(a, b, [...aStack], [...bStack]); + +  if (a.size !== undefined) { +    if (a.size !== b.size) { +      return false; +    } else if ( +      (0, _jasmineUtils.isA)('Set', a) || +      (0, _jasmineUtils.isImmutableUnorderedSet)(a) +    ) { +      let allFound = true; + +      for (const aValue of a) { +        if (!b.has(aValue)) { +          let has = false; + +          for (const bValue of b) { +            const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, [ +              iterableEqualityWithStack +            ]); + +            if (isEqual === true) { +              has = true; +            } +          } + +          if (has === false) { +            allFound = false; +            break; +          } +        } +      } // Remove the first value from the stack of traversed values. + +      aStack.pop(); +      bStack.pop(); +      return allFound; +    } else if ( +      (0, _jasmineUtils.isA)('Map', a) || +      (0, _jasmineUtils.isImmutableUnorderedKeyed)(a) +    ) { +      let allFound = true; + +      for (const aEntry of a) { +        if ( +          !b.has(aEntry[0]) || +          !(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), [ +            iterableEqualityWithStack +          ]) +        ) { +          let has = false; + +          for (const bEntry of b) { +            const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], [ +              iterableEqualityWithStack +            ]); +            let matchedValue = false; + +            if (matchedKey === true) { +              matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], [ +                iterableEqualityWithStack +              ]); +            } + +            if (matchedValue === true) { +              has = true; +            } +          } + +          if (has === false) { +            allFound = false; +            break; +          } +        } +      } // Remove the first value from the stack of traversed values. + +      aStack.pop(); +      bStack.pop(); +      return allFound; +    } +  } + +  const bIterator = b[IteratorSymbol](); + +  for (const aValue of a) { +    const nextB = bIterator.next(); + +    if ( +      nextB.done || +      !(0, _jasmineUtils.equals)(aValue, nextB.value, [ +        iterableEqualityWithStack +      ]) +    ) { +      return false; +    } +  } + +  if (!bIterator.next().done) { +    return false; +  } // Remove the first value from the stack of traversed values. + +  aStack.pop(); +  bStack.pop(); +  return true; +}; + +exports.iterableEquality = iterableEquality; + +const isObject = a => a !== null && typeof a === 'object'; + +const isObjectWithKeys = a => +  isObject(a) && +  !(a instanceof Error) && +  !(a instanceof Array) && +  !(a instanceof Date); + +const subsetEquality = (object, subset) => { +  // subsetEquality needs to keep track of the references +  // it has already visited to avoid infinite loops in case +  // there are circular references in the subset passed to it. +  const subsetEqualityWithContext = +    (seenReferences = new WeakMap()) => +    (object, subset) => { +      if (!isObjectWithKeys(subset)) { +        return undefined; +      } + +      return Object.keys(subset).every(key => { +        if (isObjectWithKeys(subset[key])) { +          if (seenReferences.has(subset[key])) { +            return (0, _jasmineUtils.equals)(object[key], subset[key], [ +              iterableEquality +            ]); +          } + +          seenReferences.set(subset[key], true); +        } + +        const result = +          object != null && +          hasPropertyInObject(object, key) && +          (0, _jasmineUtils.equals)(object[key], subset[key], [ +            iterableEquality, +            subsetEqualityWithContext(seenReferences) +          ]); // The main goal of using seenReference is to avoid circular node on tree. +        // It will only happen within a parent and its child, not a node and nodes next to it (same level) +        // We should keep the reference for a parent and its child only +        // Thus we should delete the reference immediately so that it doesn't interfere +        // other nodes within the same level on tree. + +        seenReferences.delete(subset[key]); +        return result; +      }); +    }; + +  return subsetEqualityWithContext()(object, subset); +}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + +exports.subsetEquality = subsetEquality; + +const typeEquality = (a, b) => { +  if (a == null || b == null || a.constructor === b.constructor) { +    return undefined; +  } + +  return false; +}; + +exports.typeEquality = typeEquality; + +const arrayBufferEquality = (a, b) => { +  if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer)) { +    return undefined; +  } + +  const dataViewA = new DataView(a); +  const dataViewB = new DataView(b); // Buffers are not equal when they do not have the same byte length + +  if (dataViewA.byteLength !== dataViewB.byteLength) { +    return false; +  } // Check if every byte value is equal to each other + +  for (let i = 0; i < dataViewA.byteLength; i++) { +    if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) { +      return false; +    } +  } + +  return true; +}; + +exports.arrayBufferEquality = arrayBufferEquality; + +const sparseArrayEquality = (a, b) => { +  if (!Array.isArray(a) || !Array.isArray(b)) { +    return undefined; +  } // A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"] + +  const aKeys = Object.keys(a); +  const bKeys = Object.keys(b); +  return ( +    (0, _jasmineUtils.equals)(a, b, [iterableEquality, typeEquality], true) && +    (0, _jasmineUtils.equals)(aKeys, bKeys) +  ); +}; + +exports.sparseArrayEquality = sparseArrayEquality; + +const partition = (items, predicate) => { +  const result = [[], []]; +  items.forEach(item => result[predicate(item) ? 0 : 1].push(item)); +  return result; +}; + +exports.partition = partition; + +const pathAsArray = propertyPath => { +  const properties = []; + +  if (propertyPath === '') { +    properties.push(''); +    return properties; +  } // will match everything that's not a dot or a bracket, and "" for consecutive dots. + +  const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g'); // Because the regex won't match a dot in the beginning of the path, if present. + +  if (propertyPath[0] === '.') { +    properties.push(''); +  } + +  propertyPath.replace(pattern, match => { +    properties.push(match); +    return match; +  }); +  return properties; +}; // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693 + +exports.pathAsArray = pathAsArray; + +const isError = value => { +  switch (Object.prototype.toString.call(value)) { +    case '[object Error]': +    case '[object Exception]': +    case '[object DOMException]': +      return true; + +    default: +      return value instanceof Error; +  } +}; + +exports.isError = isError; + +function emptyObject(obj) { +  return obj && typeof obj === 'object' ? !Object.keys(obj).length : false; +} + +const MULTILINE_REGEXP = /[\r\n]/; + +const isOneline = (expected, received) => +  typeof expected === 'string' && +  typeof received === 'string' && +  (!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received)); + +exports.isOneline = isOneline;  | 
