mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-23 06:14:45 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
26
node_modules/jest-jasmine2/build/jasmine/CallTracker.d.ts
generated
vendored
Normal file
26
node_modules/jest-jasmine2/build/jasmine/CallTracker.d.ts
generated
vendored
Normal file
|
@ -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.
|
||||
*
|
||||
*/
|
||||
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;
|
||||
//# sourceMappingURL=CallTracker.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/CallTracker.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/CallTracker.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"CallTracker.d.ts","sourceRoot":"","sources":["../../src/jasmine/CallTracker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,oBAAY,OAAO,GAAG;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,cAAM,WAAW;IACf,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,GAAG,EAAE,MAAM,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,GAAG,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1B,OAAO,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;;CA+CnB;AAED,eAAe,WAAW,CAAC"}
|
121
node_modules/jest-jasmine2/build/jasmine/CallTracker.js
generated
vendored
Normal file
121
node_modules/jest-jasmine2/build/jasmine/CallTracker.js
generated
vendored
Normal file
|
@ -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;
|
45
node_modules/jest-jasmine2/build/jasmine/Env.d.ts
generated
vendored
Normal file
45
node_modules/jest-jasmine2/build/jasmine/Env.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* 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 { Jasmine, AssertionErrorWithStack, Reporter, Spy } from '../types';
|
||||
import Spec from './Spec';
|
||||
import Suite from './Suite';
|
||||
export default function (j$: Jasmine): {
|
||||
new (_options?: object | undefined): {
|
||||
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: (done: (error?: any) => void) => void, timeout?: number | undefined) => void;
|
||||
fit: (description: string, fn: (done: (error?: any) => void) => void, timeout?: number | undefined) => void;
|
||||
throwingExpectationFailures: () => boolean;
|
||||
randomizeTests: (value: unknown) => void;
|
||||
randomTests: () => boolean;
|
||||
seed: (value: unknown) => unknown;
|
||||
execute: (runnablesToRun: string[], suiteTree?: Suite | undefined) => Promise<void>;
|
||||
fdescribe: (description: string, specDefinitions: Function) => Suite;
|
||||
spyOn: (obj: {
|
||||
[key: string]: any;
|
||||
}, methodName: string, accessType?: "configurable" | "enumerable" | "value" | "writable" | "get" | "set" | undefined) => Spy;
|
||||
beforeEach: (beforeEachFunction: (done: (error?: any) => void) => void, timeout?: number | undefined) => void;
|
||||
afterEach: (afterEachFunction: (done: (error?: any) => void) => void, timeout?: number | undefined) => void;
|
||||
clearReporters: () => void;
|
||||
addReporter: (reporterToAdd: Reporter) => void;
|
||||
it: (description: string, fn: (done: (error?: any) => void) => void, timeout?: number | undefined) => Spec;
|
||||
xdescribe: (description: string, specDefinitions: Function) => Suite;
|
||||
xit: (description: string, fn: (done: (error?: any) => void) => void, timeout?: number | undefined) => any;
|
||||
beforeAll: (beforeAllFunction: (done: (error?: any) => void) => void, timeout?: number | undefined) => void;
|
||||
todo: () => Spec;
|
||||
provideFallbackReporter: (reporterToAdd: Reporter) => void;
|
||||
allowRespy: (allow: boolean) => void;
|
||||
describe: (description: string, specDefinitions: Function) => Suite;
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=Env.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/Env.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/Env.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Env.d.ts","sourceRoot":"","sources":["../../src/jasmine/Env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqCH,OAAO,EAAC,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,UAAU,CAAC;AACzE,OAAO,IAAkB,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,CAAC,OAAO,WAAU,EAAE,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0oBlC"}
|
798
node_modules/jest-jasmine2/build/jasmine/Env.js
generated
vendored
Normal file
798
node_modules/jest-jasmine2/build/jasmine/Env.js
generated
vendored
Normal file
|
@ -0,0 +1,798 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
var _assert = require('assert');
|
||||
|
||||
var _chalk = _interopRequireDefault(require('chalk'));
|
||||
|
||||
var _jestMessageUtil = require('jest-message-util');
|
||||
|
||||
var _jestUtil = require('jest-util');
|
||||
|
||||
var _queueRunner = _interopRequireDefault(require('../queueRunner'));
|
||||
|
||||
var _treeProcessor = _interopRequireDefault(require('../treeProcessor'));
|
||||
|
||||
var _isError = _interopRequireDefault(require('../isError'));
|
||||
|
||||
var _assertionErrorMessage = _interopRequireDefault(
|
||||
require('../assertionErrorMessage')
|
||||
);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
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 _default(j$) {
|
||||
var _temp;
|
||||
|
||||
return (
|
||||
(_temp = class Env {
|
||||
constructor(_options) {
|
||||
_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 getNextSpecId() {
|
||||
return 'spec' + nextSpecId++;
|
||||
};
|
||||
|
||||
const getNextSuiteId = function getNextSuiteId() {
|
||||
return 'suite' + nextSuiteId++;
|
||||
};
|
||||
|
||||
const topSuite = new j$.Suite({
|
||||
id: getNextSuiteId(),
|
||||
description: '',
|
||||
|
||||
getTestPath() {
|
||||
return j$.testPath;
|
||||
}
|
||||
});
|
||||
let currentDeclarationSuite = topSuite;
|
||||
|
||||
const currentSuite = function currentSuite() {
|
||||
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
|
||||
};
|
||||
|
||||
const currentRunnable = function currentRunnable() {
|
||||
return currentSpec || currentSuite();
|
||||
};
|
||||
|
||||
const reporter = new j$.ReportDispatcher([
|
||||
'jasmineStarted',
|
||||
'jasmineDone',
|
||||
'suiteStarted',
|
||||
'suiteDone',
|
||||
'specStarted',
|
||||
'specDone'
|
||||
]);
|
||||
|
||||
this.specFilter = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
const defaultResourcesForRunnable = function defaultResourcesForRunnable(
|
||||
id,
|
||||
_parentRunnableId
|
||||
) {
|
||||
const resources = {
|
||||
spies: []
|
||||
};
|
||||
runnableResources[id] = resources;
|
||||
};
|
||||
|
||||
const clearResourcesForRunnable = function clearResourcesForRunnable(
|
||||
id
|
||||
) {
|
||||
spyRegistry.clearSpies();
|
||||
delete runnableResources[id];
|
||||
};
|
||||
|
||||
const beforeAndAfterFns = function beforeAndAfterFns(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 getSpecName(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 executionSetup() {
|
||||
// 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 executionTeardown() {
|
||||
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 =
|
||||
/*#__PURE__*/
|
||||
(function() {
|
||||
var _ref = _asyncToGenerator(function*(
|
||||
runnablesToRun,
|
||||
suiteTree = topSuite
|
||||
) {
|
||||
if (!runnablesToRun) {
|
||||
if (focusedRunnables.length) {
|
||||
runnablesToRun = focusedRunnables;
|
||||
} else {
|
||||
runnablesToRun = [suiteTree.id];
|
||||
}
|
||||
}
|
||||
|
||||
if (currentlyExecutingSuites.length === 0) {
|
||||
executionSetup();
|
||||
}
|
||||
|
||||
const lastDeclarationSuite = currentDeclarationSuite;
|
||||
yield (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();
|
||||
}
|
||||
});
|
||||
|
||||
return function(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
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 suiteFactory(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-ignore 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 = undefined;
|
||||
|
||||
try {
|
||||
describeReturnValue = specDefinitions.call(suite);
|
||||
} catch (e) {
|
||||
declarationError = e;
|
||||
} // TODO throw in Jest 25: declarationError = new Error
|
||||
|
||||
if ((0, _jestUtil.isPromise)(describeReturnValue)) {
|
||||
console.log(
|
||||
(0, _jestMessageUtil.formatExecError)(
|
||||
new Error(
|
||||
_chalk.default.yellow(
|
||||
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
|
||||
'Returning a value from "describe" will fail the test in a future version of Jest.'
|
||||
)
|
||||
),
|
||||
{
|
||||
rootDir: '',
|
||||
testMatch: []
|
||||
},
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)
|
||||
);
|
||||
} else if (describeReturnValue !== undefined) {
|
||||
console.log(
|
||||
(0, _jestMessageUtil.formatExecError)(
|
||||
new Error(
|
||||
_chalk.default.yellow(
|
||||
'A "describe" callback must not return a value.\n' +
|
||||
'Returning a value from "describe" will fail the test in a future version of Jest.'
|
||||
)
|
||||
),
|
||||
{
|
||||
rootDir: '',
|
||||
testMatch: []
|
||||
},
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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.',
|
||||
test.todo
|
||||
);
|
||||
}
|
||||
|
||||
const spec = specFactory(
|
||||
description,
|
||||
() => {},
|
||||
currentDeclarationSuite
|
||||
);
|
||||
spec.todo();
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
return spec;
|
||||
};
|
||||
|
||||
this.fit = function(description, fn, timeout) {
|
||||
const spec = specFactory(
|
||||
description,
|
||||
fn,
|
||||
currentDeclarationSuite,
|
||||
timeout
|
||||
);
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
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) {
|
||||
checkIsError = false; // @ts-ignore 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
|
||||
});
|
||||
};
|
||||
}
|
||||
}),
|
||||
_temp
|
||||
);
|
||||
}
|
34
node_modules/jest-jasmine2/build/jasmine/JsApiReporter.d.ts
generated
vendored
Normal file
34
node_modules/jest-jasmine2/build/jasmine/JsApiReporter.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* 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 { Reporter, RunDetails } from '../types';
|
||||
import { SpecResult } from './Spec';
|
||||
import { SuiteResult } from './Suite';
|
||||
import 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: () => {
|
||||
[key: string]: SuiteResult;
|
||||
};
|
||||
specResults: (index: number, length: number) => Array<SpecResult>;
|
||||
specDone: (result: SpecResult) => void;
|
||||
specs: () => Array<SpecResult>;
|
||||
specStarted: (spec: SpecResult) => void;
|
||||
constructor(options: {
|
||||
timer?: Timer;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=JsApiReporter.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/JsApiReporter.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/JsApiReporter.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"JsApiReporter.d.ts","sourceRoot":"","sources":["../../src/jasmine/JsApiReporter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,MAAM,SAAS,CAAC;AAS5B,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACjD,WAAW,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9C,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,OAAO,CAAC;IAE7B,YAAY,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,EAAE,MAAM;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAA;KAAC,CAAC;IAE3C,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,UAAU,CAAC,CAAC;IAClE,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B,WAAW,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;gBAE5B,OAAO,EAAE;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAC;CA8ErC"}
|
173
node_modules/jest-jasmine2/build/jasmine/JsApiReporter.js
generated
vendored
Normal file
173
node_modules/jest-jasmine2/build/jasmine/JsApiReporter.js
generated
vendored
Normal file
|
@ -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;
|
23
node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.d.ts
generated
vendored
Normal file
23
node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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 { Reporter, RunDetails } from '../types';
|
||||
import { SpecResult } from './Spec';
|
||||
import { 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>);
|
||||
}
|
||||
//# sourceMappingURL=ReportDispatcher.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"ReportDispatcher.d.ts","sourceRoot":"","sources":["../../src/jasmine/ReportDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IACvD,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC1C,uBAAuB,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACtD,cAAc,EAAE,MAAM,IAAI,CAAC;IAG3B,WAAW,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAE9C,cAAc,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAEjD,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAEvC,WAAW,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IAExC,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAEzC,YAAY,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;gBAEhC,OAAO,EAAE,KAAK,CAAC,MAAM,QAAQ,CAAC;CA0C3C"}
|
125
node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.js
generated
vendored
Normal file
125
node_modules/jest-jasmine2/build/jasmine/ReportDispatcher.js
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
'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 ReportDispatcher {
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
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-ignore
|
||||
reporter[method].apply(reporter, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = ReportDispatcher;
|
81
node_modules/jest-jasmine2/build/jasmine/Spec.d.ts
generated
vendored
Normal file
81
node_modules/jest-jasmine2/build/jasmine/Spec.d.ts
generated
vendored
Normal file
|
@ -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 { Config } from '@jest/types';
|
||||
import { FailedAssertion, Milliseconds, Status } from '@jest/test-result';
|
||||
import ExpectationFailed from '../ExpectationFailed';
|
||||
import expectationResultFactory, { Options as ExpectationResultFactoryOptions } from '../expectationResultFactory';
|
||||
import queueRunner, { QueueableFn } from '../queueRunner';
|
||||
import { 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: Function, enabled: boolean): void;
|
||||
cancel(): void;
|
||||
onException(error: ExpectationFailed | AssertionErrorWithStack): void;
|
||||
disable(): void;
|
||||
pend(message?: string): void;
|
||||
todo(): void;
|
||||
getResult(): SpecResult;
|
||||
status(enabled?: boolean): "disabled" | "pending" | "failed" | "passed" | "todo";
|
||||
isExecutable(): boolean;
|
||||
getFullName(): string;
|
||||
}
|
||||
//# sourceMappingURL=Spec.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/Spec.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/Spec.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Spec.d.ts","sourceRoot":"","sources":["../../src/jasmine/Spec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAExE,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,wBAAwB,EAAE,EAC/B,OAAO,IAAI,+BAA+B,EAC3C,MAAM,6BAA6B,CAAC;AAErC,OAAO,WAAW,EAAE,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAC,MAAM,UAAU,CAAC;AAEjD,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB,EAAE,OAAO,CAAC;IACnC,WAAW,EAAE,MAAM,MAAM,CAAC,IAAI,CAAC;IAC/B,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,MAAM;QACvB,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5B,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;KAC5B,CAAC;IACF,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;IACjC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;IACpC,kBAAkB,EAAE,OAAO,WAAW,CAAC;CACxC,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,kBAAkB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC;IACtB,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE;QACX,eAAe,EAAE,MAAM,MAAM,CAAC;QAC9B,aAAa,EAAE,MAAM,MAAM,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,MAAM;QACvB,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5B,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;KAC5B,CAAC;IACF,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;IACpC,kBAAkB,EAAE,OAAO,WAAW,CAAC;IACvC,yBAAyB,EAAE,OAAO,CAAC;IACnC,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC;IAE3C,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAAE,KAAK;gBAQ1B,KAAK,EAAE,UAAU;IA+C7B,oBAAoB,CAClB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,+BAA+B,EACrC,OAAO,CAAC,EAAE,OAAO;IAcnB,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;IA0C9C,MAAM;IAMN,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,uBAAuB;IA0B9D,OAAO;IAIP,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM;IAOrB,IAAI;IAIJ,SAAS;IAKT,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;IAoBxB,YAAY;IAIZ,WAAW;CAGZ"}
|
292
node_modules/jest-jasmine2/build/jasmine/Spec.js
generated
vendored
Normal file
292
node_modules/jest-jasmine2/build/jasmine/Spec.js
generated
vendored
Normal file
|
@ -0,0 +1,292 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _assert = require('assert');
|
||||
|
||||
var _ExpectationFailed = _interopRequireDefault(
|
||||
require('../ExpectationFailed')
|
||||
);
|
||||
|
||||
var _expectationResultFactory = _interopRequireDefault(
|
||||
require('../expectationResultFactory')
|
||||
);
|
||||
|
||||
var _assertionErrorMessage = _interopRequireDefault(
|
||||
require('../assertionErrorMessage')
|
||||
);
|
||||
|
||||
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-ignore
|
||||
|
||||
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-ignore
|
||||
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:
|
||||
error instanceof _assert.AssertionError
|
||||
? (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);
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = Spec;
|
||||
|
||||
_defineProperty(Spec, 'pendingSpecExceptionMessage', void 0);
|
||||
|
||||
Spec.pendingSpecExceptionMessage = '=> marked Pending';
|
||||
|
||||
const extractCustomPendingMessage = function extractCustomPendingMessage(e) {
|
||||
const fullMessage = e.toString();
|
||||
const boilerplateStart = fullMessage.indexOf(
|
||||
Spec.pendingSpecExceptionMessage
|
||||
);
|
||||
const boilerplateEnd =
|
||||
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
||||
return fullMessage.substr(boilerplateEnd);
|
||||
};
|
23
node_modules/jest-jasmine2/build/jasmine/SpyStrategy.d.ts
generated
vendored
Normal file
23
node_modules/jest-jasmine2/build/jasmine/SpyStrategy.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=SpyStrategy.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/SpyStrategy.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/SpyStrategy.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"SpyStrategy.d.ts","sourceRoot":"","sources":["../../src/jasmine/SpyStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC;IACvC,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IACzC,YAAY,EAAE,MAAM,OAAO,CAAC;IAC5B,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,KAAK,OAAO,CAAC;IACnD,QAAQ,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC;IACpC,IAAI,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC;gBAEpB,EACV,IAAgB,EAChB,EAAkB,EAClB,MAAsB,GACvB,GAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAA;KAAM;CAyD/D"}
|
141
node_modules/jest-jasmine2/build/jasmine/SpyStrategy.js
generated
vendored
Normal file
141
node_modules/jest-jasmine2/build/jasmine/SpyStrategy.js
generated
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
'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 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 plan() {};
|
||||
|
||||
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 plan() {
|
||||
return value;
|
||||
};
|
||||
|
||||
return getSpy();
|
||||
};
|
||||
|
||||
this.returnValues = function() {
|
||||
const values = Array.prototype.slice.call(arguments);
|
||||
|
||||
plan = function plan() {
|
||||
return values.shift();
|
||||
};
|
||||
|
||||
return getSpy();
|
||||
};
|
||||
|
||||
this.throwError = function(something) {
|
||||
const error =
|
||||
something instanceof Error ? something : new Error(something);
|
||||
|
||||
plan = function plan() {
|
||||
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 plan() {};
|
||||
|
||||
return getSpy();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = SpyStrategy;
|
62
node_modules/jest-jasmine2/build/jasmine/Suite.d.ts
generated
vendored
Normal file
62
node_modules/jest-jasmine2/build/jasmine/Suite.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* 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 { Config } from '@jest/types';
|
||||
import expectationResultFactory from '../expectationResultFactory';
|
||||
import { QueueableFn } from '../queueRunner';
|
||||
import 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(): "disabled" | "pending" | "failed" | "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;
|
||||
}
|
||||
//# sourceMappingURL=Suite.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/Suite.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/Suite.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Suite.d.ts","sourceRoot":"","sources":["../../src/jasmine/Suite.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,OAAO,wBAAwB,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,oBAAY,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;IACvE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,WAAW,EAAE,MAAM,MAAM,CAAC,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB,EAAE,OAAO,CAAC;IACnC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC7B,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACjC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,WAAW,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;gBAEP,KAAK,EAAE,UAAU;IAyB7B,WAAW;IAaX,OAAO;IAGP,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM;IAGtB,UAAU,CAAC,EAAE,EAAE,WAAW;IAG1B,SAAS,CAAC,EAAE,EAAE,WAAW;IAGzB,SAAS,CAAC,EAAE,EAAE,WAAW;IAGzB,QAAQ,CAAC,EAAE,EAAE,WAAW;IAIxB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAI5B,MAAM;IAgBN,YAAY;IAIZ,cAAc;IAId,SAAS;IAKT,iBAAiB;IAQjB,uBAAuB;IAIvB,WAAW,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAsBpD,oBAAoB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAmBtE,OAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;CAC7B"}
|
235
node_modules/jest-jasmine2/build/jasmine/Suite.js
generated
vendored
Normal file
235
node_modules/jest-jasmine2/build/jasmine/Suite.js
generated
vendored
Normal file
|
@ -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 (e) {
|
||||
// keep going
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execute(..._args) {}
|
||||
}
|
||||
|
||||
exports.default = Suite;
|
||||
|
||||
function isAfterAll(children) {
|
||||
return children && children[0] && children[0].result.status;
|
||||
}
|
||||
|
||||
function isFailure(args) {
|
||||
return !args[0];
|
||||
}
|
15
node_modules/jest-jasmine2/build/jasmine/Timer.d.ts
generated
vendored
Normal file
15
node_modules/jest-jasmine2/build/jasmine/Timer.d.ts
generated
vendored
Normal file
|
@ -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 default class Timer {
|
||||
start: () => void;
|
||||
elapsed: () => number;
|
||||
constructor(options?: {
|
||||
now?: () => number;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=Timer.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/Timer.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/Timer.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Timer.d.ts","sourceRoot":"","sources":["../../src/jasmine/Timer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+BH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,MAAM,CAAC;gBAEV,OAAO,CAAC,EAAE;QAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;KAAC;CAc3C"}
|
79
node_modules/jest-jasmine2/build/jasmine/Timer.js
generated
vendored
Normal file
79
node_modules/jest-jasmine2/build/jasmine/Timer.js
generated
vendored
Normal file
|
@ -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;
|
15
node_modules/jest-jasmine2/build/jasmine/createSpy.d.ts
generated
vendored
Normal file
15
node_modules/jest-jasmine2/build/jasmine/createSpy.d.ts
generated
vendored
Normal file
|
@ -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 { Spy } from '../types';
|
||||
interface Fn {
|
||||
(): any;
|
||||
[key: string]: any;
|
||||
}
|
||||
declare function createSpy(name: string, originalFn: Fn): Spy;
|
||||
export default createSpy;
|
||||
//# sourceMappingURL=createSpy.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/createSpy.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/createSpy.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"createSpy.d.ts","sourceRoot":"","sources":["../../src/jasmine/createSpy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAI7B,UAAU,EAAE;IACV,IAAI,GAAG,CAAC;IACR,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,GAAG,CAqCpD;AAED,eAAe,SAAS,CAAC"}
|
88
node_modules/jest-jasmine2/build/jasmine/createSpy.js
generated
vendored
Normal file
88
node_modules/jest-jasmine2/build/jasmine/createSpy.js
generated
vendored
Normal file
|
@ -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 */
|
||||
function createSpy(name, originalFn) {
|
||||
const spyStrategy = new _SpyStrategy.default({
|
||||
name,
|
||||
fn: originalFn,
|
||||
|
||||
getSpy() {
|
||||
return spy;
|
||||
}
|
||||
});
|
||||
const callTracker = new _CallTracker.default();
|
||||
|
||||
const spy = function spy(...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;
|
31
node_modules/jest-jasmine2/build/jasmine/jasmineLight.d.ts
generated
vendored
Normal file
31
node_modules/jest-jasmine2/build/jasmine/jasmineLight.d.ts
generated
vendored
Normal file
|
@ -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 { Jasmine } from '../types';
|
||||
import JsApiReporter from './JsApiReporter';
|
||||
declare const _default: {
|
||||
create: (createOptions: Record<string, any>) => Jasmine;
|
||||
interface: (jasmine: Jasmine, env: any) => {
|
||||
describe(description: string, specDefinitions: Function): any;
|
||||
xdescribe(description: string, specDefinitions: Function): any;
|
||||
fdescribe(description: string, specDefinitions: Function): 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;
|
||||
};
|
||||
};
|
||||
export = _default;
|
||||
//# sourceMappingURL=jasmineLight.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/jasmineLight.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/jasmineLight.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"jasmineLight.d.ts","sourceRoot":"","sources":["../../src/jasmine/jasmineLight.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH,OAAO,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AAGjC,OAAO,aAAa,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;AAmH5C,kBAAyC"}
|
167
node_modules/jest-jasmine2/build/jasmine/jasmineLight.js
generated
vendored
Normal file
167
node_modules/jest-jasmine2/build/jasmine/jasmineLight.js
generated
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
'use strict';
|
||||
|
||||
var _createSpy = _interopRequireDefault(require('./createSpy'));
|
||||
|
||||
var _Env = _interopRequireDefault(require('./Env'));
|
||||
|
||||
var _JsApiReporter = _interopRequireDefault(require('./JsApiReporter'));
|
||||
|
||||
var _ReportDispatcher = _interopRequireDefault(require('./ReportDispatcher'));
|
||||
|
||||
var _Spec = _interopRequireDefault(require('./Spec'));
|
||||
|
||||
var _spyRegistry = _interopRequireDefault(require('./spyRegistry'));
|
||||
|
||||
var _Suite = _interopRequireDefault(require('./Suite'));
|
||||
|
||||
var _Timer = _interopRequireDefault(require('./Timer'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
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 create = function create(createOptions) {
|
||||
const j$ = _objectSpread({}, createOptions);
|
||||
|
||||
j$._DEFAULT_TIMEOUT_INTERVAL = 5000;
|
||||
|
||||
j$.getEnv = function(options) {
|
||||
const env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options)); //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$;
|
||||
};
|
||||
|
||||
const _interface = function _interface(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;
|
||||
}; // Interface is a reserved word in strict mode, so can't export it as ESM
|
||||
|
||||
module.exports = {
|
||||
create,
|
||||
interface: _interface
|
||||
};
|
21
node_modules/jest-jasmine2/build/jasmine/spyRegistry.d.ts
generated
vendored
Normal file
21
node_modules/jest-jasmine2/build/jasmine/spyRegistry.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* 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 { Spy } from '../types';
|
||||
export default class SpyRegistry {
|
||||
allowRespy: (allow: unknown) => void;
|
||||
spyOn: (obj: {
|
||||
[key: string]: any;
|
||||
}, methodName: string, accessType?: keyof PropertyDescriptor) => Spy;
|
||||
clearSpies: () => void;
|
||||
respy: unknown;
|
||||
private _spyOnProperty;
|
||||
constructor({ currentSpies, }?: {
|
||||
currentSpies?: () => Array<Spy>;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=spyRegistry.d.ts.map
|
1
node_modules/jest-jasmine2/build/jasmine/spyRegistry.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-jasmine2/build/jasmine/spyRegistry.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"spyRegistry.d.ts","sourceRoot":"","sources":["../../src/jasmine/spyRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAsB7B,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,KAAK,EAAE,CACL,GAAG,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EACzB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,kBAAkB,KAClC,GAAG,CAAC;IACT,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IAEf,OAAO,CAAC,cAAc,CAIb;gBAEG,EACV,YAAuB,GACxB,GAAE;QACD,YAAY,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;KAC5B;CAgKP"}
|
244
node_modules/jest-jasmine2/build/jasmine/spyRegistry.js
generated
vendored
Normal file
244
node_modules/jest-jasmine2/build/jasmine/spyRegistry.js
generated
vendored
Normal file
|
@ -0,0 +1,244 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _CallTracker = _interopRequireDefault(require('./CallTracker'));
|
||||
|
||||
var _createSpy = _interopRequireDefault(require('./createSpy'));
|
||||
|
||||
var _SpyStrategy = _interopRequireDefault(require('./SpyStrategy'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
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 (e) {
|
||||
// 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 restoreStrategy() {
|
||||
obj[methodName] = originalMethod;
|
||||
};
|
||||
} else {
|
||||
restoreStrategy = function restoreStrategy() {
|
||||
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 (e) {
|
||||
// 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 restoreStrategy() {
|
||||
Object.defineProperty(obj, propertyName, originalDescriptor);
|
||||
};
|
||||
} else {
|
||||
restoreStrategy = function restoreStrategy() {
|
||||
delete obj[propertyName];
|
||||
};
|
||||
}
|
||||
|
||||
currentSpies().push({
|
||||
restoreObjectToOriginalState: restoreStrategy
|
||||
});
|
||||
|
||||
const spiedDescriptor = _objectSpread({}, 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;
|
Loading…
Add table
Add a link
Reference in a new issue