diff options
Diffstat (limited to 'node_modules/jest-jasmine2/build/jasmine')
22 files changed, 2730 insertions, 0 deletions
diff --git a/node_modules/jest-jasmine2/build/jasmine/CallTracker.d.ts b/node_modules/jest-jasmine2/build/jasmine/CallTracker.d.ts new file mode 100644 index 0000000..1692e9c --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/CallTracker.d.ts @@ -0,0 +1,25 @@ +/** + * 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 type Context = { +    object: unknown; +    args: Array<unknown>; +    returnValue?: unknown; +}; +declare class CallTracker { +    track: (context: Context) => void; +    any: () => boolean; +    count: () => number; +    argsFor: (index: number) => Array<unknown>; +    all: () => Array<Context>; +    allArgs: () => Array<unknown>; +    first: () => Context; +    mostRecent: () => Context; +    reset: () => void; +    constructor(); +} +export default CallTracker; diff --git a/node_modules/jest-jasmine2/build/jasmine/CallTracker.js b/node_modules/jest-jasmine2/build/jasmine/CallTracker.js new file mode 100644 index 0000000..c0ce750 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/CallTracker.js @@ -0,0 +1,121 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +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; +} + +/** + * 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. + * + */ +// This file is a heavily modified fork of Jasmine. Original license: + +/* +Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +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. +*/ +class CallTracker { +  constructor() { +    _defineProperty(this, 'track', void 0); + +    _defineProperty(this, 'any', void 0); + +    _defineProperty(this, 'count', void 0); + +    _defineProperty(this, 'argsFor', void 0); + +    _defineProperty(this, 'all', void 0); + +    _defineProperty(this, 'allArgs', void 0); + +    _defineProperty(this, 'first', void 0); + +    _defineProperty(this, 'mostRecent', void 0); + +    _defineProperty(this, 'reset', void 0); + +    let calls = []; + +    this.track = function (context) { +      calls.push(context); +    }; + +    this.any = function () { +      return !!calls.length; +    }; + +    this.count = function () { +      return calls.length; +    }; + +    this.argsFor = function (index) { +      const call = calls[index]; +      return call ? call.args : []; +    }; + +    this.all = function () { +      return calls; +    }; + +    this.allArgs = function () { +      const callArgs = []; + +      for (let i = 0; i < calls.length; i++) { +        callArgs.push(calls[i].args); +      } + +      return callArgs; +    }; + +    this.first = function () { +      return calls[0]; +    }; + +    this.mostRecent = function () { +      return calls[calls.length - 1]; +    }; + +    this.reset = function () { +      calls = []; +    }; +  } +} + +var _default = CallTracker; +exports.default = _default; diff --git a/node_modules/jest-jasmine2/build/jasmine/Env.d.ts b/node_modules/jest-jasmine2/build/jasmine/Env.d.ts new file mode 100644 index 0000000..334cd0d --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Env.d.ts @@ -0,0 +1,43 @@ +/** + * 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 { QueueableFn } from '../queueRunner'; +import type { AssertionErrorWithStack, Jasmine, Reporter, SpecDefinitionsFn, Spy } from '../types'; +import type { default as Spec } from './Spec'; +import type Suite from './Suite'; +export default function jasmineEnv(j$: Jasmine): { +    new (): { +        specFilter: (spec: Spec) => boolean; +        catchExceptions: (value: unknown) => boolean; +        throwOnExpectationFailure: (value: unknown) => void; +        catchingExceptions: () => boolean; +        topSuite: () => Suite; +        fail: (error: Error | AssertionErrorWithStack) => void; +        pending: (message: string) => void; +        afterAll: (afterAllFunction: QueueableFn['fn'], timeout?: number | undefined) => void; +        fit: (description: string, fn: QueueableFn['fn'], timeout?: number | undefined) => Spec; +        throwingExpectationFailures: () => boolean; +        randomizeTests: (value: unknown) => void; +        randomTests: () => boolean; +        seed: (value: unknown) => unknown; +        execute: (runnablesToRun?: string[] | undefined, suiteTree?: Suite | undefined) => Promise<void>; +        fdescribe: (description: string, specDefinitions: SpecDefinitionsFn) => Suite; +        spyOn: (obj: Record<string, Spy>, methodName: string, accessType?: "configurable" | "enumerable" | "value" | "writable" | "get" | "set" | undefined) => Spy; +        beforeEach: (beforeEachFunction: QueueableFn['fn'], timeout?: number | undefined) => void; +        afterEach: (afterEachFunction: QueueableFn['fn'], timeout?: number | undefined) => void; +        clearReporters: () => void; +        addReporter: (reporterToAdd: Reporter) => void; +        it: (description: string, fn: QueueableFn['fn'], timeout?: number | undefined) => Spec; +        xdescribe: (description: string, specDefinitions: SpecDefinitionsFn) => Suite; +        xit: (description: string, fn: QueueableFn['fn'], timeout?: number | undefined) => Spec; +        beforeAll: (beforeAllFunction: QueueableFn['fn'], timeout?: number | undefined) => void; +        todo: () => Spec; +        provideFallbackReporter: (reporterToAdd: Reporter) => void; +        allowRespy: (allow: boolean) => void; +        describe: (description: string, specDefinitions: SpecDefinitionsFn) => Suite; +    }; +}; diff --git a/node_modules/jest-jasmine2/build/jasmine/Env.js b/node_modules/jest-jasmine2/build/jasmine/Env.js new file mode 100644 index 0000000..382c9c2 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Env.js @@ -0,0 +1,716 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = jasmineEnv; + +var _assert = require('assert'); + +var _jestUtil = require('jest-util'); + +var _assertionErrorMessage = _interopRequireDefault( +  require('../assertionErrorMessage') +); + +var _isError = _interopRequireDefault(require('../isError')); + +var _queueRunner = _interopRequireDefault(require('../queueRunner')); + +var _treeProcessor = _interopRequireDefault(require('../treeProcessor')); + +function _interopRequireDefault(obj) { +  return obj && obj.__esModule ? obj : {default: obj}; +} + +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; +} + +function jasmineEnv(j$) { +  return class Env { +    constructor() { +      _defineProperty(this, 'specFilter', void 0); + +      _defineProperty(this, 'catchExceptions', void 0); + +      _defineProperty(this, 'throwOnExpectationFailure', void 0); + +      _defineProperty(this, 'catchingExceptions', void 0); + +      _defineProperty(this, 'topSuite', void 0); + +      _defineProperty(this, 'fail', void 0); + +      _defineProperty(this, 'pending', void 0); + +      _defineProperty(this, 'afterAll', void 0); + +      _defineProperty(this, 'fit', void 0); + +      _defineProperty(this, 'throwingExpectationFailures', void 0); + +      _defineProperty(this, 'randomizeTests', void 0); + +      _defineProperty(this, 'randomTests', void 0); + +      _defineProperty(this, 'seed', void 0); + +      _defineProperty(this, 'execute', void 0); + +      _defineProperty(this, 'fdescribe', void 0); + +      _defineProperty(this, 'spyOn', void 0); + +      _defineProperty(this, 'beforeEach', void 0); + +      _defineProperty(this, 'afterEach', void 0); + +      _defineProperty(this, 'clearReporters', void 0); + +      _defineProperty(this, 'addReporter', void 0); + +      _defineProperty(this, 'it', void 0); + +      _defineProperty(this, 'xdescribe', void 0); + +      _defineProperty(this, 'xit', void 0); + +      _defineProperty(this, 'beforeAll', void 0); + +      _defineProperty(this, 'todo', void 0); + +      _defineProperty(this, 'provideFallbackReporter', void 0); + +      _defineProperty(this, 'allowRespy', void 0); + +      _defineProperty(this, 'describe', void 0); + +      let totalSpecsDefined = 0; +      let catchExceptions = true; +      const realSetTimeout = global.setTimeout; +      const realClearTimeout = global.clearTimeout; +      const runnableResources = {}; +      const currentlyExecutingSuites = []; +      let currentSpec = null; +      let throwOnExpectationFailure = false; +      let random = false; +      let seed = null; +      let nextSpecId = 0; +      let nextSuiteId = 0; + +      const getNextSpecId = function () { +        return 'spec' + nextSpecId++; +      }; + +      const getNextSuiteId = function () { +        return 'suite' + nextSuiteId++; +      }; + +      const topSuite = new j$.Suite({ +        id: getNextSuiteId(), +        description: '', + +        getTestPath() { +          return j$.testPath; +        } +      }); +      let currentDeclarationSuite = topSuite; + +      const currentSuite = function () { +        return currentlyExecutingSuites[currentlyExecutingSuites.length - 1]; +      }; + +      const currentRunnable = function () { +        return currentSpec || currentSuite(); +      }; + +      const reporter = new j$.ReportDispatcher([ +        'jasmineStarted', +        'jasmineDone', +        'suiteStarted', +        'suiteDone', +        'specStarted', +        'specDone' +      ]); + +      this.specFilter = function () { +        return true; +      }; + +      const defaultResourcesForRunnable = function (id, _parentRunnableId) { +        const resources = { +          spies: [] +        }; +        runnableResources[id] = resources; +      }; + +      const clearResourcesForRunnable = function (id) { +        spyRegistry.clearSpies(); +        delete runnableResources[id]; +      }; + +      const beforeAndAfterFns = function (suite) { +        return function () { +          let afters = []; +          let befores = []; + +          while (suite) { +            befores = befores.concat(suite.beforeFns); +            afters = afters.concat(suite.afterFns); +            suite = suite.parentSuite; +          } + +          return { +            befores: befores.reverse(), +            afters +          }; +        }; +      }; + +      const getSpecName = function (spec, suite) { +        const fullName = [spec.description]; +        const suiteFullName = suite.getFullName(); + +        if (suiteFullName !== '') { +          fullName.unshift(suiteFullName); +        } + +        return fullName.join(' '); +      }; + +      this.catchExceptions = function (value) { +        catchExceptions = !!value; +        return catchExceptions; +      }; + +      this.catchingExceptions = function () { +        return catchExceptions; +      }; + +      this.throwOnExpectationFailure = function (value) { +        throwOnExpectationFailure = !!value; +      }; + +      this.throwingExpectationFailures = function () { +        return throwOnExpectationFailure; +      }; + +      this.randomizeTests = function (value) { +        random = !!value; +      }; + +      this.randomTests = function () { +        return random; +      }; + +      this.seed = function (value) { +        if (value) { +          seed = value; +        } + +        return seed; +      }; + +      const queueRunnerFactory = options => { +        options.clearTimeout = realClearTimeout; +        options.fail = this.fail; +        options.setTimeout = realSetTimeout; +        return (0, _queueRunner.default)(options); +      }; + +      this.topSuite = function () { +        return topSuite; +      }; + +      const uncaught = err => { +        if (currentSpec) { +          currentSpec.onException(err); +          currentSpec.cancel(); +        } else { +          console.error('Unhandled error'); +          console.error(err.stack); +        } +      }; + +      let oldListenersException; +      let oldListenersRejection; + +      const executionSetup = function () { +        // Need to ensure we are the only ones handling these exceptions. +        oldListenersException = process.listeners('uncaughtException').slice(); +        oldListenersRejection = process.listeners('unhandledRejection').slice(); +        j$.process.removeAllListeners('uncaughtException'); +        j$.process.removeAllListeners('unhandledRejection'); +        j$.process.on('uncaughtException', uncaught); +        j$.process.on('unhandledRejection', uncaught); +      }; + +      const executionTeardown = function () { +        j$.process.removeListener('uncaughtException', uncaught); +        j$.process.removeListener('unhandledRejection', uncaught); // restore previous exception handlers + +        oldListenersException.forEach(listener => { +          j$.process.on('uncaughtException', listener); +        }); +        oldListenersRejection.forEach(listener => { +          j$.process.on('unhandledRejection', listener); +        }); +      }; + +      this.execute = async function (runnablesToRun, suiteTree = topSuite) { +        if (!runnablesToRun) { +          if (focusedRunnables.length) { +            runnablesToRun = focusedRunnables; +          } else { +            runnablesToRun = [suiteTree.id]; +          } +        } + +        if (currentlyExecutingSuites.length === 0) { +          executionSetup(); +        } + +        const lastDeclarationSuite = currentDeclarationSuite; +        await (0, _treeProcessor.default)({ +          nodeComplete(suite) { +            if (!suite.disabled) { +              clearResourcesForRunnable(suite.id); +            } + +            currentlyExecutingSuites.pop(); + +            if (suite === topSuite) { +              reporter.jasmineDone({ +                failedExpectations: topSuite.result.failedExpectations +              }); +            } else { +              reporter.suiteDone(suite.getResult()); +            } +          }, + +          nodeStart(suite) { +            currentlyExecutingSuites.push(suite); +            defaultResourcesForRunnable( +              suite.id, +              suite.parentSuite && suite.parentSuite.id +            ); + +            if (suite === topSuite) { +              reporter.jasmineStarted({ +                totalSpecsDefined +              }); +            } else { +              reporter.suiteStarted(suite.result); +            } +          }, + +          queueRunnerFactory, +          runnableIds: runnablesToRun, +          tree: suiteTree +        }); +        currentDeclarationSuite = lastDeclarationSuite; + +        if (currentlyExecutingSuites.length === 0) { +          executionTeardown(); +        } +      }; + +      this.addReporter = function (reporterToAdd) { +        reporter.addReporter(reporterToAdd); +      }; + +      this.provideFallbackReporter = function (reporterToAdd) { +        reporter.provideFallbackReporter(reporterToAdd); +      }; + +      this.clearReporters = function () { +        reporter.clearReporters(); +      }; + +      const spyRegistry = new j$.SpyRegistry({ +        currentSpies() { +          if (!currentRunnable()) { +            throw new Error( +              'Spies must be created in a before function or a spec' +            ); +          } + +          return runnableResources[currentRunnable().id].spies; +        } +      }); + +      this.allowRespy = function (allow) { +        spyRegistry.allowRespy(allow); +      }; + +      this.spyOn = function (...args) { +        return spyRegistry.spyOn.apply(spyRegistry, args); +      }; + +      const suiteFactory = function (description) { +        const suite = new j$.Suite({ +          id: getNextSuiteId(), +          description, +          parentSuite: currentDeclarationSuite, +          throwOnExpectationFailure, + +          getTestPath() { +            return j$.testPath; +          } +        }); +        return suite; +      }; + +      this.describe = function (description, specDefinitions) { +        const suite = suiteFactory(description); + +        if (specDefinitions === undefined) { +          throw new Error( +            'Missing second argument. It must be a callback function.' +          ); +        } + +        if (typeof specDefinitions !== 'function') { +          throw new Error( +            `Invalid second argument, ${specDefinitions}. It must be a callback function.` +          ); +        } + +        if (specDefinitions.length > 0) { +          throw new Error('describe does not expect any arguments'); +        } + +        if (currentDeclarationSuite.markedPending) { +          suite.pend(); +        } + +        if (currentDeclarationSuite.markedTodo) { +          // @ts-expect-error TODO Possible error: Suite does not have todo method +          suite.todo(); +        } + +        addSpecsToSuite(suite, specDefinitions); +        return suite; +      }; + +      this.xdescribe = function (description, specDefinitions) { +        const suite = suiteFactory(description); +        suite.pend(); +        addSpecsToSuite(suite, specDefinitions); +        return suite; +      }; + +      const focusedRunnables = []; + +      this.fdescribe = function (description, specDefinitions) { +        const suite = suiteFactory(description); +        suite.isFocused = true; +        focusedRunnables.push(suite.id); +        unfocusAncestor(); +        addSpecsToSuite(suite, specDefinitions); +        return suite; +      }; + +      const addSpecsToSuite = (suite, specDefinitions) => { +        const parentSuite = currentDeclarationSuite; +        parentSuite.addChild(suite); +        currentDeclarationSuite = suite; +        let declarationError = undefined; +        let describeReturnValue; + +        try { +          describeReturnValue = specDefinitions.call(suite); +        } catch (e) { +          declarationError = e; +        } + +        if ((0, _jestUtil.isPromise)(describeReturnValue)) { +          declarationError = new Error( +            'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.' +          ); +        } else if (describeReturnValue !== undefined) { +          declarationError = new Error( +            'A "describe" callback must not return a value.' +          ); +        } + +        if (declarationError) { +          this.it('encountered a declaration exception', () => { +            throw declarationError; +          }); +        } + +        currentDeclarationSuite = parentSuite; +      }; + +      function findFocusedAncestor(suite) { +        while (suite) { +          if (suite.isFocused) { +            return suite.id; +          } + +          suite = suite.parentSuite; +        } + +        return null; +      } + +      function unfocusAncestor() { +        const focusedAncestor = findFocusedAncestor(currentDeclarationSuite); + +        if (focusedAncestor) { +          for (let i = 0; i < focusedRunnables.length; i++) { +            if (focusedRunnables[i] === focusedAncestor) { +              focusedRunnables.splice(i, 1); +              break; +            } +          } +        } +      } + +      const specFactory = (description, fn, suite, timeout) => { +        totalSpecsDefined++; +        const spec = new j$.Spec({ +          id: getNextSpecId(), +          beforeAndAfterFns: beforeAndAfterFns(suite), +          resultCallback: specResultCallback, + +          getSpecName(spec) { +            return getSpecName(spec, suite); +          }, + +          getTestPath() { +            return j$.testPath; +          }, + +          onStart: specStarted, +          description, +          queueRunnerFactory, + +          userContext() { +            return suite.clonedSharedUserContext(); +          }, + +          queueableFn: { +            fn, + +            timeout() { +              return timeout || j$._DEFAULT_TIMEOUT_INTERVAL; +            } +          }, +          throwOnExpectationFailure +        }); + +        if (!this.specFilter(spec)) { +          spec.disable(); +        } + +        return spec; + +        function specResultCallback(result) { +          clearResourcesForRunnable(spec.id); +          currentSpec = null; +          reporter.specDone(result); +        } + +        function specStarted(spec) { +          currentSpec = spec; +          defaultResourcesForRunnable(spec.id, suite.id); +          reporter.specStarted(spec.result); +        } +      }; + +      this.it = function (description, fn, timeout) { +        if (typeof description !== 'string') { +          throw new Error( +            `Invalid first argument, ${description}. It must be a string.` +          ); +        } + +        if (fn === undefined) { +          throw new Error( +            'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.' +          ); +        } + +        if (typeof fn !== 'function') { +          throw new Error( +            `Invalid second argument, ${fn}. It must be a callback function.` +          ); +        } + +        const spec = specFactory( +          description, +          fn, +          currentDeclarationSuite, +          timeout +        ); + +        if (currentDeclarationSuite.markedPending) { +          spec.pend(); +        } // When a test is defined inside another, jasmine will not run it. +        // This check throws an error to warn the user about the edge-case. + +        if (currentSpec !== null) { +          throw new Error( +            `Tests cannot be nested. Test "${spec.description}" cannot run because it is nested within "${currentSpec.description}".` +          ); +        } + +        currentDeclarationSuite.addChild(spec); +        return spec; +      }; + +      this.xit = function (...args) { +        const spec = this.it.apply(this, args); +        spec.pend('Temporarily disabled with xit'); +        return spec; +      }; + +      this.todo = function () { +        const description = arguments[0]; + +        if (arguments.length !== 1 || typeof description !== 'string') { +          throw new _jestUtil.ErrorWithStack( +            'Todo must be called with only a description.', +            this.todo +          ); +        } + +        const spec = specFactory( +          description, +          () => {}, +          currentDeclarationSuite +        ); + +        if (currentDeclarationSuite.markedPending) { +          spec.pend(); +        } else { +          spec.todo(); +        } + +        currentDeclarationSuite.addChild(spec); +        return spec; +      }; + +      this.fit = function (description, fn, timeout) { +        const spec = specFactory( +          description, +          fn, +          currentDeclarationSuite, +          timeout +        ); +        currentDeclarationSuite.addChild(spec); + +        if (currentDeclarationSuite.markedPending) { +          spec.pend(); +        } else { +          focusedRunnables.push(spec.id); +        } + +        unfocusAncestor(); +        return spec; +      }; + +      this.beforeEach = function (beforeEachFunction, timeout) { +        currentDeclarationSuite.beforeEach({ +          fn: beforeEachFunction, + +          timeout() { +            return timeout || j$._DEFAULT_TIMEOUT_INTERVAL; +          } +        }); +      }; + +      this.beforeAll = function (beforeAllFunction, timeout) { +        currentDeclarationSuite.beforeAll({ +          fn: beforeAllFunction, + +          timeout() { +            return timeout || j$._DEFAULT_TIMEOUT_INTERVAL; +          } +        }); +      }; + +      this.afterEach = function (afterEachFunction, timeout) { +        currentDeclarationSuite.afterEach({ +          fn: afterEachFunction, + +          timeout() { +            return timeout || j$._DEFAULT_TIMEOUT_INTERVAL; +          } +        }); +      }; + +      this.afterAll = function (afterAllFunction, timeout) { +        currentDeclarationSuite.afterAll({ +          fn: afterAllFunction, + +          timeout() { +            return timeout || j$._DEFAULT_TIMEOUT_INTERVAL; +          } +        }); +      }; + +      this.pending = function (message) { +        let fullMessage = j$.Spec.pendingSpecExceptionMessage; + +        if (message) { +          fullMessage += message; +        } + +        throw fullMessage; +      }; + +      this.fail = function (error) { +        let checkIsError; +        let message; + +        if ( +          error instanceof _assert.AssertionError || +          (error && error.name === _assert.AssertionError.name) +        ) { +          checkIsError = false; // @ts-expect-error TODO Possible error: j$.Spec does not have expand property + +          message = (0, _assertionErrorMessage.default)(error, { +            expand: j$.Spec.expand +          }); +        } else { +          const check = (0, _isError.default)(error); +          checkIsError = check.isError; +          message = check.message; +        } + +        const errorAsErrorObject = checkIsError ? error : new Error(message); +        const runnable = currentRunnable(); + +        if (!runnable) { +          errorAsErrorObject.message = +            'Caught error after test environment was torn down\n\n' + +            errorAsErrorObject.message; +          throw errorAsErrorObject; +        } + +        runnable.addExpectationResult(false, { +          matcherName: '', +          passed: false, +          expected: '', +          actual: '', +          message, +          error: errorAsErrorObject +        }); +      }; +    } +  }; +} diff --git a/node_modules/jest-jasmine2/build/jasmine/JsApiReporter.d.ts b/node_modules/jest-jasmine2/build/jasmine/JsApiReporter.d.ts new file mode 100644 index 0000000..ece0b73 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/JsApiReporter.d.ts @@ -0,0 +1,31 @@ +/** + * 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 { Reporter, RunDetails } from '../types'; +import type { SpecResult } from './Spec'; +import type { SuiteResult } from './Suite'; +import type Timer from './Timer'; +export default class JsApiReporter implements Reporter { +    started: boolean; +    finished: boolean; +    runDetails: RunDetails; +    jasmineStarted: (runDetails: RunDetails) => void; +    jasmineDone: (runDetails: RunDetails) => void; +    status: () => unknown; +    executionTime: () => unknown; +    suiteStarted: (result: SuiteResult) => void; +    suiteDone: (result: SuiteResult) => void; +    suiteResults: (index: number, length: number) => Array<SuiteResult>; +    suites: () => Record<string, SuiteResult>; +    specResults: (index: number, length: number) => Array<SpecResult>; +    specDone: (result: SpecResult) => void; +    specs: () => Array<SpecResult>; +    specStarted: (spec: SpecResult) => void; +    constructor(options: { +        timer?: Timer; +    }); +} diff --git a/node_modules/jest-jasmine2/build/jasmine/JsApiReporter.js b/node_modules/jest-jasmine2/build/jasmine/JsApiReporter.js new file mode 100644 index 0000000..982f446 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/JsApiReporter.js @@ -0,0 +1,173 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +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; +} + +/** + * 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. + * + */ +// This file is a heavily modified fork of Jasmine. Original license: + +/* +Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +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 sort-keys */ +const noopTimer = { +  start() {}, + +  elapsed() { +    return 0; +  } +}; + +class JsApiReporter { +  constructor(options) { +    _defineProperty(this, 'started', void 0); + +    _defineProperty(this, 'finished', void 0); + +    _defineProperty(this, 'runDetails', void 0); + +    _defineProperty(this, 'jasmineStarted', void 0); + +    _defineProperty(this, 'jasmineDone', void 0); + +    _defineProperty(this, 'status', void 0); + +    _defineProperty(this, 'executionTime', void 0); + +    _defineProperty(this, 'suiteStarted', void 0); + +    _defineProperty(this, 'suiteDone', void 0); + +    _defineProperty(this, 'suiteResults', void 0); + +    _defineProperty(this, 'suites', void 0); + +    _defineProperty(this, 'specResults', void 0); + +    _defineProperty(this, 'specDone', void 0); + +    _defineProperty(this, 'specs', void 0); + +    _defineProperty(this, 'specStarted', void 0); + +    const timer = options.timer || noopTimer; +    let status = 'loaded'; +    this.started = false; +    this.finished = false; +    this.runDetails = {}; + +    this.jasmineStarted = () => { +      this.started = true; +      status = 'started'; +      timer.start(); +    }; + +    let executionTime; + +    function validateAfterAllExceptions({failedExpectations}) { +      if (failedExpectations && failedExpectations.length > 0) { +        throw failedExpectations[0]; +      } +    } + +    this.jasmineDone = function (runDetails) { +      validateAfterAllExceptions(runDetails); +      this.finished = true; +      this.runDetails = runDetails; +      executionTime = timer.elapsed(); +      status = 'done'; +    }; + +    this.status = function () { +      return status; +    }; + +    const suites = []; +    const suites_hash = {}; + +    this.specStarted = function () {}; + +    this.suiteStarted = function (result) { +      suites_hash[result.id] = result; +    }; + +    this.suiteDone = function (result) { +      storeSuite(result); +    }; + +    this.suiteResults = function (index, length) { +      return suites.slice(index, index + length); +    }; + +    function storeSuite(result) { +      suites.push(result); +      suites_hash[result.id] = result; +    } + +    this.suites = function () { +      return suites_hash; +    }; + +    const specs = []; + +    this.specDone = function (result) { +      specs.push(result); +    }; + +    this.specResults = function (index, length) { +      return specs.slice(index, index + length); +    }; + +    this.specs = function () { +      return specs; +    }; + +    this.executionTime = function () { +      return executionTime; +    }; +  } +} + +exports.default = JsApiReporter; diff --git a/node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.d.ts b/node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.d.ts new file mode 100644 index 0000000..9f89d05 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.d.ts @@ -0,0 +1,22 @@ +/** + * 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 { Reporter, RunDetails } from '../types'; +import type { SpecResult } from './Spec'; +import type { SuiteResult } from './Suite'; +export default class ReportDispatcher implements Reporter { +    addReporter: (reporter: Reporter) => void; +    provideFallbackReporter: (reporter: Reporter) => void; +    clearReporters: () => void; +    jasmineDone: (runDetails: RunDetails) => void; +    jasmineStarted: (runDetails: RunDetails) => void; +    specDone: (result: SpecResult) => void; +    specStarted: (spec: SpecResult) => void; +    suiteDone: (result: SuiteResult) => void; +    suiteStarted: (result: SuiteResult) => void; +    constructor(methods: Array<keyof Reporter>); +} diff --git a/node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.js b/node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.js new file mode 100644 index 0000000..3acead9 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.js @@ -0,0 +1,127 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +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; +} + +/** + * 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. + * + */ +// This file is a heavily modified fork of Jasmine. Original license: + +/* +Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +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 local/prefer-spread-eventually, local/prefer-rest-params-eventually */ +class ReportDispatcher { +  // @ts-expect-error +  // @ts-expect-error +  // @ts-expect-error +  // @ts-expect-error +  // @ts-expect-error +  // @ts-expect-error +  constructor(methods) { +    _defineProperty(this, 'addReporter', void 0); + +    _defineProperty(this, 'provideFallbackReporter', void 0); + +    _defineProperty(this, 'clearReporters', void 0); + +    _defineProperty(this, 'jasmineDone', void 0); + +    _defineProperty(this, 'jasmineStarted', void 0); + +    _defineProperty(this, 'specDone', void 0); + +    _defineProperty(this, 'specStarted', void 0); + +    _defineProperty(this, 'suiteDone', void 0); + +    _defineProperty(this, 'suiteStarted', void 0); + +    const dispatchedMethods = methods || []; + +    for (let i = 0; i < dispatchedMethods.length; i++) { +      const method = dispatchedMethods[i]; + +      this[method] = (function (m) { +        return function () { +          dispatch(m, arguments); +        }; +      })(method); +    } + +    let reporters = []; +    let fallbackReporter = null; + +    this.addReporter = function (reporter) { +      reporters.push(reporter); +    }; + +    this.provideFallbackReporter = function (reporter) { +      fallbackReporter = reporter; +    }; + +    this.clearReporters = function () { +      reporters = []; +    }; + +    return this; + +    function dispatch(method, args) { +      if (reporters.length === 0 && fallbackReporter !== null) { +        reporters.push(fallbackReporter); +      } + +      for (let i = 0; i < reporters.length; i++) { +        const reporter = reporters[i]; + +        if (reporter[method]) { +          // @ts-expect-error +          reporter[method].apply(reporter, args); +        } +      } +    } +  } +} + +exports.default = ReportDispatcher; diff --git a/node_modules/jest-jasmine2/build/jasmine/Spec.d.ts b/node_modules/jest-jasmine2/build/jasmine/Spec.d.ts new file mode 100644 index 0000000..e6ba7ce --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Spec.d.ts @@ -0,0 +1,81 @@ +/** + * 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 { FailedAssertion, Milliseconds, Status } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import ExpectationFailed from '../ExpectationFailed'; +import expectationResultFactory, { Options as ExpectationResultFactoryOptions } from '../expectationResultFactory'; +import type { QueueableFn, default as queueRunner } from '../queueRunner'; +import type { AssertionErrorWithStack } from '../types'; +export declare type Attributes = { +    id: string; +    resultCallback: (result: Spec['result']) => void; +    description: string; +    throwOnExpectationFailure: unknown; +    getTestPath: () => Config.Path; +    queueableFn: QueueableFn; +    beforeAndAfterFns: () => { +        befores: Array<QueueableFn>; +        afters: Array<QueueableFn>; +    }; +    userContext: () => unknown; +    onStart: (context: Spec) => void; +    getSpecName: (spec: Spec) => string; +    queueRunnerFactory: typeof queueRunner; +}; +export declare type SpecResult = { +    id: string; +    description: string; +    fullName: string; +    duration?: Milliseconds; +    failedExpectations: Array<FailedAssertion>; +    testPath: Config.Path; +    passedExpectations: Array<ReturnType<typeof expectationResultFactory>>; +    pendingReason: string; +    status: Status; +    __callsite?: { +        getColumnNumber: () => number; +        getLineNumber: () => number; +    }; +}; +export default class Spec { +    id: string; +    description: string; +    resultCallback: (result: SpecResult) => void; +    queueableFn: QueueableFn; +    beforeAndAfterFns: () => { +        befores: Array<QueueableFn>; +        afters: Array<QueueableFn>; +    }; +    userContext: () => unknown; +    onStart: (spec: Spec) => void; +    getSpecName: (spec: Spec) => string; +    queueRunnerFactory: typeof queueRunner; +    throwOnExpectationFailure: boolean; +    initError: Error; +    result: SpecResult; +    disabled?: boolean; +    currentRun?: ReturnType<typeof queueRunner>; +    markedTodo?: boolean; +    markedPending?: boolean; +    expand?: boolean; +    static pendingSpecExceptionMessage: string; +    static isPendingSpecException(e: Error): boolean; +    constructor(attrs: Attributes); +    addExpectationResult(passed: boolean, data: ExpectationResultFactoryOptions, isError?: boolean): void; +    execute(onComplete?: () => void, enabled?: boolean): void; +    cancel(): void; +    onException(error: ExpectationFailed | AssertionErrorWithStack): void; +    disable(): void; +    pend(message?: string): void; +    todo(): void; +    getResult(): SpecResult; +    status(enabled?: boolean): "todo" | "passed" | "failed" | "pending" | "disabled"; +    isExecutable(): boolean; +    getFullName(): string; +    isAssertionError(error: Error): boolean; +} diff --git a/node_modules/jest-jasmine2/build/jasmine/Spec.js b/node_modules/jest-jasmine2/build/jasmine/Spec.js new file mode 100644 index 0000000..32fbc49 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Spec.js @@ -0,0 +1,298 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +var _assert = require('assert'); + +var _ExpectationFailed = _interopRequireDefault( +  require('../ExpectationFailed') +); + +var _assertionErrorMessage = _interopRequireDefault( +  require('../assertionErrorMessage') +); + +var _expectationResultFactory = _interopRequireDefault( +  require('../expectationResultFactory') +); + +function _interopRequireDefault(obj) { +  return obj && obj.__esModule ? obj : {default: obj}; +} + +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 Spec { +  static isPendingSpecException(e) { +    return !!( +      e && +      e.toString && +      e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1 +    ); +  } + +  constructor(attrs) { +    _defineProperty(this, 'id', void 0); + +    _defineProperty(this, 'description', void 0); + +    _defineProperty(this, 'resultCallback', void 0); + +    _defineProperty(this, 'queueableFn', void 0); + +    _defineProperty(this, 'beforeAndAfterFns', void 0); + +    _defineProperty(this, 'userContext', void 0); + +    _defineProperty(this, 'onStart', void 0); + +    _defineProperty(this, 'getSpecName', void 0); + +    _defineProperty(this, 'queueRunnerFactory', void 0); + +    _defineProperty(this, 'throwOnExpectationFailure', void 0); + +    _defineProperty(this, 'initError', void 0); + +    _defineProperty(this, 'result', void 0); + +    _defineProperty(this, 'disabled', void 0); + +    _defineProperty(this, 'currentRun', void 0); + +    _defineProperty(this, 'markedTodo', void 0); + +    _defineProperty(this, 'markedPending', void 0); + +    _defineProperty(this, 'expand', void 0); + +    this.resultCallback = attrs.resultCallback || function () {}; + +    this.id = attrs.id; +    this.description = attrs.description || ''; +    this.queueableFn = attrs.queueableFn; + +    this.beforeAndAfterFns = +      attrs.beforeAndAfterFns || +      function () { +        return { +          befores: [], +          afters: [] +        }; +      }; + +    this.userContext = +      attrs.userContext || +      function () { +        return {}; +      }; + +    this.onStart = attrs.onStart || function () {}; + +    this.getSpecName = +      attrs.getSpecName || +      function () { +        return ''; +      }; + +    this.queueRunnerFactory = attrs.queueRunnerFactory || function () {}; + +    this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure; +    this.initError = new Error(); +    this.initError.name = ''; // Without this line v8 stores references to all closures +    // in the stack in the Error object. This line stringifies the stack +    // property to allow garbage-collecting objects on the stack +    // https://crbug.com/v8/7142 + +    this.initError.stack = this.initError.stack; +    this.queueableFn.initError = this.initError; // @ts-expect-error + +    this.result = { +      id: this.id, +      description: this.description, +      fullName: this.getFullName(), +      failedExpectations: [], +      passedExpectations: [], +      pendingReason: '', +      testPath: attrs.getTestPath() +    }; +  } + +  addExpectationResult(passed, data, isError) { +    const expectationResult = (0, _expectationResultFactory.default)( +      data, +      this.initError +    ); + +    if (passed) { +      this.result.passedExpectations.push(expectationResult); +    } else { +      this.result.failedExpectations.push(expectationResult); + +      if (this.throwOnExpectationFailure && !isError) { +        throw new _ExpectationFailed.default(); +      } +    } +  } + +  execute(onComplete, enabled) { +    const self = this; +    this.onStart(this); + +    if ( +      !this.isExecutable() || +      this.markedPending || +      this.markedTodo || +      enabled === false +    ) { +      complete(enabled); +      return; +    } + +    const fns = this.beforeAndAfterFns(); +    const allFns = fns.befores.concat(this.queueableFn).concat(fns.afters); +    this.currentRun = this.queueRunnerFactory({ +      queueableFns: allFns, + +      onException() { +        // @ts-expect-error +        self.onException.apply(self, arguments); +      }, + +      userContext: this.userContext(), +      setTimeout, +      clearTimeout, +      fail: () => {} +    }); +    this.currentRun.then(() => complete(true)); + +    function complete(enabledAgain) { +      self.result.status = self.status(enabledAgain); +      self.resultCallback(self.result); + +      if (onComplete) { +        onComplete(); +      } +    } +  } + +  cancel() { +    if (this.currentRun) { +      this.currentRun.cancel(); +    } +  } + +  onException(error) { +    if (Spec.isPendingSpecException(error)) { +      this.pend(extractCustomPendingMessage(error)); +      return; +    } + +    if (error instanceof _ExpectationFailed.default) { +      return; +    } + +    this.addExpectationResult( +      false, +      { +        matcherName: '', +        passed: false, +        expected: '', +        actual: '', +        error: this.isAssertionError(error) +          ? (0, _assertionErrorMessage.default)(error, { +              expand: this.expand +            }) +          : error +      }, +      true +    ); +  } + +  disable() { +    this.disabled = true; +  } + +  pend(message) { +    this.markedPending = true; + +    if (message) { +      this.result.pendingReason = message; +    } +  } + +  todo() { +    this.markedTodo = true; +  } + +  getResult() { +    this.result.status = this.status(); +    return this.result; +  } + +  status(enabled) { +    if (this.disabled || enabled === false) { +      return 'disabled'; +    } + +    if (this.markedTodo) { +      return 'todo'; +    } + +    if (this.markedPending) { +      return 'pending'; +    } + +    if (this.result.failedExpectations.length > 0) { +      return 'failed'; +    } else { +      return 'passed'; +    } +  } + +  isExecutable() { +    return !this.disabled; +  } + +  getFullName() { +    return this.getSpecName(this); +  } + +  isAssertionError(error) { +    return ( +      error instanceof _assert.AssertionError || +      (error && error.name === _assert.AssertionError.name) +    ); +  } +} + +exports.default = Spec; + +_defineProperty(Spec, 'pendingSpecExceptionMessage', void 0); + +Spec.pendingSpecExceptionMessage = '=> marked Pending'; + +const extractCustomPendingMessage = function (e) { +  const fullMessage = e.toString(); +  const boilerplateStart = fullMessage.indexOf( +    Spec.pendingSpecExceptionMessage +  ); +  const boilerplateEnd = +    boilerplateStart + Spec.pendingSpecExceptionMessage.length; +  return fullMessage.substr(boilerplateEnd); +}; diff --git a/node_modules/jest-jasmine2/build/jasmine/SpyStrategy.d.ts b/node_modules/jest-jasmine2/build/jasmine/SpyStrategy.d.ts new file mode 100644 index 0000000..a54754d --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/SpyStrategy.d.ts @@ -0,0 +1,22 @@ +/** + * 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 default class SpyStrategy { +    identity: () => string; +    exec: (...args: Array<any>) => unknown; +    callThrough: () => unknown; +    returnValue: (value: unknown) => unknown; +    returnValues: () => unknown; +    throwError: (something: string | Error) => unknown; +    callFake: (fn: Function) => unknown; +    stub: (fn: Function) => unknown; +    constructor({ name, fn, getSpy, }?: { +        name?: string; +        fn?: Function; +        getSpy?: () => unknown; +    }); +} diff --git a/node_modules/jest-jasmine2/build/jasmine/SpyStrategy.js b/node_modules/jest-jasmine2/build/jasmine/SpyStrategy.js new file mode 100644 index 0000000..fc7de39 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/SpyStrategy.js @@ -0,0 +1,143 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +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; +} + +/** + * 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. + * + */ +// This file is a heavily modified fork of Jasmine. Original license: + +/* +Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +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 local/ban-types-eventually, local/prefer-rest-params-eventually */ +class SpyStrategy { +  constructor({ +    name = 'unknown', +    fn = function () {}, +    getSpy = function () {} +  } = {}) { +    _defineProperty(this, 'identity', void 0); + +    _defineProperty(this, 'exec', void 0); + +    _defineProperty(this, 'callThrough', void 0); + +    _defineProperty(this, 'returnValue', void 0); + +    _defineProperty(this, 'returnValues', void 0); + +    _defineProperty(this, 'throwError', void 0); + +    _defineProperty(this, 'callFake', void 0); + +    _defineProperty(this, 'stub', void 0); + +    const identity = name; +    const originalFn = fn; + +    let plan = function () {}; + +    this.identity = function () { +      return identity; +    }; + +    this.exec = function () { +      return plan.apply(this, arguments); +    }; + +    this.callThrough = function () { +      plan = originalFn; +      return getSpy(); +    }; + +    this.returnValue = function (value) { +      plan = function () { +        return value; +      }; + +      return getSpy(); +    }; + +    this.returnValues = function () { +      const values = Array.prototype.slice.call(arguments); + +      plan = function () { +        return values.shift(); +      }; + +      return getSpy(); +    }; + +    this.throwError = function (something) { +      const error = +        something instanceof Error ? something : new Error(something); + +      plan = function () { +        throw error; +      }; + +      return getSpy(); +    }; + +    this.callFake = function (fn) { +      if (typeof fn !== 'function') { +        throw new Error( +          'Argument passed to callFake should be a function, got ' + fn +        ); +      } + +      plan = fn; +      return getSpy(); +    }; + +    this.stub = function (_fn) { +      plan = function () {}; + +      return getSpy(); +    }; +  } +} + +exports.default = SpyStrategy; diff --git a/node_modules/jest-jasmine2/build/jasmine/Suite.d.ts b/node_modules/jest-jasmine2/build/jasmine/Suite.d.ts new file mode 100644 index 0000000..7bfd374 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Suite.d.ts @@ -0,0 +1,61 @@ +/** + * 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 expectationResultFactory from '../expectationResultFactory'; +import type { QueueableFn } from '../queueRunner'; +import type Spec from './Spec'; +export declare type SuiteResult = { +    id: string; +    description: string; +    fullName: string; +    failedExpectations: Array<ReturnType<typeof expectationResultFactory>>; +    testPath: Config.Path; +    status?: string; +}; +export declare type Attributes = { +    id: string; +    parentSuite?: Suite; +    description: string; +    throwOnExpectationFailure?: boolean; +    getTestPath: () => Config.Path; +}; +export default class Suite { +    id: string; +    parentSuite?: Suite; +    description: string; +    throwOnExpectationFailure: boolean; +    beforeFns: Array<QueueableFn>; +    afterFns: Array<QueueableFn>; +    beforeAllFns: Array<QueueableFn>; +    afterAllFns: Array<QueueableFn>; +    disabled: boolean; +    children: Array<Suite | Spec>; +    result: SuiteResult; +    sharedContext?: object; +    markedPending: boolean; +    markedTodo: boolean; +    isFocused: boolean; +    constructor(attrs: Attributes); +    getFullName(): string; +    disable(): void; +    pend(_message?: string): void; +    beforeEach(fn: QueueableFn): void; +    beforeAll(fn: QueueableFn): void; +    afterEach(fn: QueueableFn): void; +    afterAll(fn: QueueableFn): void; +    addChild(child: Suite | Spec): void; +    status(): "failed" | "pending" | "disabled" | "finished"; +    isExecutable(): boolean; +    canBeReentered(): boolean; +    getResult(): SuiteResult; +    sharedUserContext(): object; +    clonedSharedUserContext(): object; +    onException(...args: Parameters<Spec['onException']>): void; +    addExpectationResult(...args: Parameters<Spec['addExpectationResult']>): void; +    execute(..._args: Array<any>): void; +} diff --git a/node_modules/jest-jasmine2/build/jasmine/Suite.js b/node_modules/jest-jasmine2/build/jasmine/Suite.js new file mode 100644 index 0000000..79f9f15 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Suite.js @@ -0,0 +1,235 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +var _jestUtil = require('jest-util'); + +var _ExpectationFailed = _interopRequireDefault( +  require('../ExpectationFailed') +); + +var _expectationResultFactory = _interopRequireDefault( +  require('../expectationResultFactory') +); + +function _interopRequireDefault(obj) { +  return obj && obj.__esModule ? obj : {default: obj}; +} + +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 Suite { +  constructor(attrs) { +    _defineProperty(this, 'id', void 0); + +    _defineProperty(this, 'parentSuite', void 0); + +    _defineProperty(this, 'description', void 0); + +    _defineProperty(this, 'throwOnExpectationFailure', void 0); + +    _defineProperty(this, 'beforeFns', void 0); + +    _defineProperty(this, 'afterFns', void 0); + +    _defineProperty(this, 'beforeAllFns', void 0); + +    _defineProperty(this, 'afterAllFns', void 0); + +    _defineProperty(this, 'disabled', void 0); + +    _defineProperty(this, 'children', void 0); + +    _defineProperty(this, 'result', void 0); + +    _defineProperty(this, 'sharedContext', void 0); + +    _defineProperty(this, 'markedPending', void 0); + +    _defineProperty(this, 'markedTodo', void 0); + +    _defineProperty(this, 'isFocused', void 0); + +    this.markedPending = false; +    this.markedTodo = false; +    this.isFocused = false; +    this.id = attrs.id; +    this.parentSuite = attrs.parentSuite; +    this.description = (0, _jestUtil.convertDescriptorToString)( +      attrs.description +    ); +    this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure; +    this.beforeFns = []; +    this.afterFns = []; +    this.beforeAllFns = []; +    this.afterAllFns = []; +    this.disabled = false; +    this.children = []; +    this.result = { +      id: this.id, +      description: this.description, +      fullName: this.getFullName(), +      failedExpectations: [], +      testPath: attrs.getTestPath() +    }; +  } + +  getFullName() { +    const fullName = []; + +    for ( +      let parentSuite = this; +      parentSuite; +      parentSuite = parentSuite.parentSuite +    ) { +      if (parentSuite.parentSuite) { +        fullName.unshift(parentSuite.description); +      } +    } + +    return fullName.join(' '); +  } + +  disable() { +    this.disabled = true; +  } + +  pend(_message) { +    this.markedPending = true; +  } + +  beforeEach(fn) { +    this.beforeFns.unshift(fn); +  } + +  beforeAll(fn) { +    this.beforeAllFns.push(fn); +  } + +  afterEach(fn) { +    this.afterFns.unshift(fn); +  } + +  afterAll(fn) { +    this.afterAllFns.unshift(fn); +  } + +  addChild(child) { +    this.children.push(child); +  } + +  status() { +    if (this.disabled) { +      return 'disabled'; +    } + +    if (this.markedPending) { +      return 'pending'; +    } + +    if (this.result.failedExpectations.length > 0) { +      return 'failed'; +    } else { +      return 'finished'; +    } +  } + +  isExecutable() { +    return !this.disabled; +  } + +  canBeReentered() { +    return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0; +  } + +  getResult() { +    this.result.status = this.status(); +    return this.result; +  } + +  sharedUserContext() { +    if (!this.sharedContext) { +      this.sharedContext = {}; +    } + +    return this.sharedContext; +  } + +  clonedSharedUserContext() { +    return this.sharedUserContext(); +  } + +  onException(...args) { +    if (args[0] instanceof _ExpectationFailed.default) { +      return; +    } + +    if (isAfterAll(this.children)) { +      const data = { +        matcherName: '', +        passed: false, +        expected: '', +        actual: '', +        error: arguments[0] +      }; +      this.result.failedExpectations.push( +        (0, _expectationResultFactory.default)(data) +      ); +    } else { +      for (let i = 0; i < this.children.length; i++) { +        const child = this.children[i]; +        child.onException.apply(child, args); +      } +    } +  } + +  addExpectationResult(...args) { +    if (isAfterAll(this.children) && isFailure(args)) { +      const data = args[1]; +      this.result.failedExpectations.push( +        (0, _expectationResultFactory.default)(data) +      ); + +      if (this.throwOnExpectationFailure) { +        throw new _ExpectationFailed.default(); +      } +    } else { +      for (let i = 0; i < this.children.length; i++) { +        const child = this.children[i]; + +        try { +          child.addExpectationResult.apply(child, args); +        } catch { +          // keep going +        } +      } +    } +  } + +  execute(..._args) {} +} + +exports.default = Suite; + +function isAfterAll(children) { +  return children && children[0] && children[0].result.status; +} + +function isFailure(args) { +  return !args[0]; +} diff --git a/node_modules/jest-jasmine2/build/jasmine/Timer.d.ts b/node_modules/jest-jasmine2/build/jasmine/Timer.d.ts new file mode 100644 index 0000000..17c97e6 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Timer.d.ts @@ -0,0 +1,14 @@ +/** + * 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 default class Timer { +    start: () => void; +    elapsed: () => number; +    constructor(options?: { +        now?: () => number; +    }); +} diff --git a/node_modules/jest-jasmine2/build/jasmine/Timer.js b/node_modules/jest-jasmine2/build/jasmine/Timer.js new file mode 100644 index 0000000..6183940 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/Timer.js @@ -0,0 +1,79 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +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; +} + +/** + * 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. + * + */ +// This file is a heavily modified fork of Jasmine. Original license: + +/* +Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +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. +*/ +const defaultNow = (function (Date) { +  return function () { +    return new Date().getTime(); +  }; +})(Date); + +class Timer { +  constructor(options) { +    _defineProperty(this, 'start', void 0); + +    _defineProperty(this, 'elapsed', void 0); + +    options = options || {}; +    const now = options.now || defaultNow; +    let startTime; + +    this.start = function () { +      startTime = now(); +    }; + +    this.elapsed = function () { +      return now() - startTime; +    }; +  } +} + +exports.default = Timer; diff --git a/node_modules/jest-jasmine2/build/jasmine/createSpy.d.ts b/node_modules/jest-jasmine2/build/jasmine/createSpy.d.ts new file mode 100644 index 0000000..f1d0173 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/createSpy.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 { Spy } from '../types'; +interface Fn extends Record<string, unknown> { +    (): unknown; +} +declare function createSpy(name: string, originalFn: Fn): Spy; +export default createSpy; diff --git a/node_modules/jest-jasmine2/build/jasmine/createSpy.js b/node_modules/jest-jasmine2/build/jasmine/createSpy.js new file mode 100644 index 0000000..17a6728 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/createSpy.js @@ -0,0 +1,88 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +var _CallTracker = _interopRequireDefault(require('./CallTracker')); + +var _SpyStrategy = _interopRequireDefault(require('./SpyStrategy')); + +function _interopRequireDefault(obj) { +  return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * 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. + * + */ +// This file is a heavily modified fork of Jasmine. Original license: + +/* +Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +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 sort-keys, local/prefer-rest-params-eventually */ +function createSpy(name, originalFn) { +  const spyStrategy = new _SpyStrategy.default({ +    name, +    fn: originalFn, + +    getSpy() { +      return spy; +    } +  }); +  const callTracker = new _CallTracker.default(); + +  const spy = function (...args) { +    const callData = { +      object: this, +      args: Array.prototype.slice.apply(arguments) +    }; +    callTracker.track(callData); +    const returnValue = spyStrategy.exec.apply(this, args); +    callData.returnValue = returnValue; +    return returnValue; +  }; + +  for (const prop in originalFn) { +    if (prop === 'and' || prop === 'calls') { +      throw new Error( +        "Jasmine spies would overwrite the 'and' and 'calls' properties " + +          'on the object being spied upon' +      ); +    } + +    spy[prop] = originalFn[prop]; +  } + +  spy.and = spyStrategy; +  spy.calls = callTracker; +  return spy; +} + +var _default = createSpy; +exports.default = _default; diff --git a/node_modules/jest-jasmine2/build/jasmine/jasmineLight.d.ts b/node_modules/jest-jasmine2/build/jasmine/jasmineLight.d.ts new file mode 100644 index 0000000..ad4fe02 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/jasmineLight.d.ts @@ -0,0 +1,27 @@ +/** + * 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 { Jasmine, SpecDefinitionsFn } from '../types'; +import JsApiReporter from './JsApiReporter'; +export declare const create: (createOptions: Record<string, any>) => Jasmine; +export declare const _interface: (jasmine: Jasmine, env: any) => { +    describe(description: string, specDefinitions: SpecDefinitionsFn): any; +    xdescribe(description: string, specDefinitions: SpecDefinitionsFn): any; +    fdescribe(description: string, specDefinitions: SpecDefinitionsFn): any; +    it(): any; +    xit(): any; +    fit(): any; +    beforeEach(): any; +    afterEach(): any; +    beforeAll(): any; +    afterAll(): any; +    pending(): any; +    fail(): any; +    spyOn(obj: Record<string, any>, methodName: string, accessType?: string | undefined): any; +    jsApiReporter: JsApiReporter; +    jasmine: Jasmine; +}; diff --git a/node_modules/jest-jasmine2/build/jasmine/jasmineLight.js b/node_modules/jest-jasmine2/build/jasmine/jasmineLight.js new file mode 100644 index 0000000..0d921a0 --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/jasmineLight.js @@ -0,0 +1,171 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.create = exports._interface = void 0; + +var _Env = _interopRequireDefault(require('./Env')); + +var _JsApiReporter = _interopRequireDefault(require('./JsApiReporter')); + +var _ReportDispatcher = _interopRequireDefault(require('./ReportDispatcher')); + +var _Spec = _interopRequireDefault(require('./Spec')); + +var _Suite = _interopRequireDefault(require('./Suite')); + +var _Timer = _interopRequireDefault(require('./Timer')); + +var _createSpy = _interopRequireDefault(require('./createSpy')); + +var _spyRegistry = _interopRequireDefault(require('./spyRegistry')); + +function _interopRequireDefault(obj) { +  return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * 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. + * + */ +// This file is a heavily modified fork of Jasmine. Original license: + +/* +Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +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 sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */ +const create = function (createOptions) { +  const j$ = {...createOptions}; +  j$._DEFAULT_TIMEOUT_INTERVAL = createOptions.testTimeout || 5000; + +  j$.getEnv = function () { +    const env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env()); //jasmine. singletons in here (setTimeout blah blah). + +    return env; +  }; + +  j$.createSpy = _createSpy.default; +  j$.Env = (0, _Env.default)(j$); +  j$.JsApiReporter = _JsApiReporter.default; +  j$.ReportDispatcher = _ReportDispatcher.default; +  j$.Spec = _Spec.default; +  j$.SpyRegistry = _spyRegistry.default; +  j$.Suite = _Suite.default; +  j$.Timer = _Timer.default; +  j$.version = '2.5.2-light'; +  return j$; +}; // Interface is a reserved word in strict mode, so can't export it as ESM + +exports.create = create; + +const _interface = function (jasmine, env) { +  const jasmineInterface = { +    describe(description, specDefinitions) { +      return env.describe(description, specDefinitions); +    }, + +    xdescribe(description, specDefinitions) { +      return env.xdescribe(description, specDefinitions); +    }, + +    fdescribe(description, specDefinitions) { +      return env.fdescribe(description, specDefinitions); +    }, + +    it() { +      return env.it.apply(env, arguments); +    }, + +    xit() { +      return env.xit.apply(env, arguments); +    }, + +    fit() { +      return env.fit.apply(env, arguments); +    }, + +    beforeEach() { +      if (typeof arguments[0] !== 'function') { +        throw new Error( +          'Invalid first argument. It must be a callback function.' +        ); +      } + +      return env.beforeEach.apply(env, arguments); +    }, + +    afterEach() { +      if (typeof arguments[0] !== 'function') { +        throw new Error( +          'Invalid first argument. It must be a callback function.' +        ); +      } + +      return env.afterEach.apply(env, arguments); +    }, + +    beforeAll() { +      if (typeof arguments[0] !== 'function') { +        throw new Error( +          'Invalid first argument. It must be a callback function.' +        ); +      } + +      return env.beforeAll.apply(env, arguments); +    }, + +    afterAll() { +      if (typeof arguments[0] !== 'function') { +        throw new Error( +          'Invalid first argument. It must be a callback function.' +        ); +      } + +      return env.afterAll.apply(env, arguments); +    }, + +    pending() { +      return env.pending.apply(env, arguments); +    }, + +    fail() { +      return env.fail.apply(env, arguments); +    }, + +    spyOn(obj, methodName, accessType) { +      return env.spyOn(obj, methodName, accessType); +    }, + +    jsApiReporter: new jasmine.JsApiReporter({ +      timer: new jasmine.Timer() +    }), +    jasmine +  }; +  return jasmineInterface; +}; + +exports._interface = _interface; diff --git a/node_modules/jest-jasmine2/build/jasmine/spyRegistry.d.ts b/node_modules/jest-jasmine2/build/jasmine/spyRegistry.d.ts new file mode 100644 index 0000000..c5f215c --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/spyRegistry.d.ts @@ -0,0 +1,18 @@ +/** + * 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 { Spy } from '../types'; +export default class SpyRegistry { +    allowRespy: (allow: unknown) => void; +    spyOn: (obj: Record<string, Spy>, methodName: string, accessType?: keyof PropertyDescriptor) => Spy; +    clearSpies: () => void; +    respy: unknown; +    private _spyOnProperty; +    constructor({ currentSpies, }?: { +        currentSpies?: () => Array<Spy>; +    }); +} diff --git a/node_modules/jest-jasmine2/build/jasmine/spyRegistry.js b/node_modules/jest-jasmine2/build/jasmine/spyRegistry.js new file mode 100644 index 0000000..ce200ff --- /dev/null +++ b/node_modules/jest-jasmine2/build/jasmine/spyRegistry.js @@ -0,0 +1,222 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { +  value: true +}); +exports.default = void 0; + +var _CallTracker = _interopRequireDefault(require('./CallTracker')); + +var _SpyStrategy = _interopRequireDefault(require('./SpyStrategy')); + +var _createSpy = _interopRequireDefault(require('./createSpy')); + +function _interopRequireDefault(obj) { +  return obj && obj.__esModule ? obj : {default: obj}; +} + +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 formatErrorMsg = (domain, usage) => { +  const usageDefinition = usage ? '\nUsage: ' + usage : ''; +  return msg => domain + ' : ' + msg + usageDefinition; +}; + +function isSpy(putativeSpy) { +  if (!putativeSpy) { +    return false; +  } + +  return ( +    putativeSpy.and instanceof _SpyStrategy.default && +    putativeSpy.calls instanceof _CallTracker.default +  ); +} + +const getErrorMsg = formatErrorMsg('<spyOn>', 'spyOn(<object>, <methodName>)'); + +class SpyRegistry { +  constructor({currentSpies = () => []} = {}) { +    _defineProperty(this, 'allowRespy', void 0); + +    _defineProperty(this, 'spyOn', void 0); + +    _defineProperty(this, 'clearSpies', void 0); + +    _defineProperty(this, 'respy', void 0); + +    _defineProperty(this, '_spyOnProperty', void 0); + +    this.allowRespy = function (allow) { +      this.respy = allow; +    }; + +    this.spyOn = (obj, methodName, accessType) => { +      if (accessType) { +        return this._spyOnProperty(obj, methodName, accessType); +      } + +      if (obj === void 0) { +        throw new Error( +          getErrorMsg( +            'could not find an object to spy upon for ' + methodName + '()' +          ) +        ); +      } + +      if (methodName === void 0) { +        throw new Error(getErrorMsg('No method name supplied')); +      } + +      if (obj[methodName] === void 0) { +        throw new Error(getErrorMsg(methodName + '() method does not exist')); +      } + +      if (obj[methodName] && isSpy(obj[methodName])) { +        if (this.respy) { +          return obj[methodName]; +        } else { +          throw new Error( +            getErrorMsg(methodName + ' has already been spied upon') +          ); +        } +      } + +      let descriptor; + +      try { +        descriptor = Object.getOwnPropertyDescriptor(obj, methodName); +      } catch { +        // IE 8 doesn't support `definePropery` on non-DOM nodes +      } + +      if (descriptor && !(descriptor.writable || descriptor.set)) { +        throw new Error( +          getErrorMsg(methodName + ' is not declared writable or has no setter') +        ); +      } + +      const originalMethod = obj[methodName]; +      const spiedMethod = (0, _createSpy.default)(methodName, originalMethod); +      let restoreStrategy; + +      if (Object.prototype.hasOwnProperty.call(obj, methodName)) { +        restoreStrategy = function () { +          obj[methodName] = originalMethod; +        }; +      } else { +        restoreStrategy = function () { +          if (!delete obj[methodName]) { +            obj[methodName] = originalMethod; +          } +        }; +      } + +      currentSpies().push({ +        restoreObjectToOriginalState: restoreStrategy +      }); +      obj[methodName] = spiedMethod; +      return spiedMethod; +    }; + +    this._spyOnProperty = function (obj, propertyName, accessType = 'get') { +      if (!obj) { +        throw new Error( +          getErrorMsg( +            'could not find an object to spy upon for ' + propertyName +          ) +        ); +      } + +      if (!propertyName) { +        throw new Error(getErrorMsg('No property name supplied')); +      } + +      let descriptor; + +      try { +        descriptor = Object.getOwnPropertyDescriptor(obj, propertyName); +      } catch { +        // IE 8 doesn't support `definePropery` on non-DOM nodes +      } + +      if (!descriptor) { +        throw new Error(getErrorMsg(propertyName + ' property does not exist')); +      } + +      if (!descriptor.configurable) { +        throw new Error( +          getErrorMsg(propertyName + ' is not declared configurable') +        ); +      } + +      if (!descriptor[accessType]) { +        throw new Error( +          getErrorMsg( +            'Property ' + +              propertyName + +              ' does not have access type ' + +              accessType +          ) +        ); +      } + +      if (obj[propertyName] && isSpy(obj[propertyName])) { +        if (this.respy) { +          return obj[propertyName]; +        } else { +          throw new Error( +            getErrorMsg(propertyName + ' has already been spied upon') +          ); +        } +      } + +      const originalDescriptor = descriptor; +      const spiedProperty = (0, _createSpy.default)( +        propertyName, +        descriptor[accessType] +      ); +      let restoreStrategy; + +      if (Object.prototype.hasOwnProperty.call(obj, propertyName)) { +        restoreStrategy = function () { +          Object.defineProperty(obj, propertyName, originalDescriptor); +        }; +      } else { +        restoreStrategy = function () { +          delete obj[propertyName]; +        }; +      } + +      currentSpies().push({ +        restoreObjectToOriginalState: restoreStrategy +      }); +      const spiedDescriptor = {...descriptor, [accessType]: spiedProperty}; +      Object.defineProperty(obj, propertyName, spiedDescriptor); +      return spiedProperty; +    }; + +    this.clearSpies = function () { +      const spies = currentSpies(); + +      for (let i = spies.length - 1; i >= 0; i--) { +        const spyEntry = spies[i]; +        spyEntry.restoreObjectToOriginalState(); +      } +    }; +  } +} + +exports.default = SpyRegistry;  | 
