From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/tapable/LICENSE | 21 + node_modules/tapable/README.md | 288 +++ node_modules/tapable/lib/AsyncParallelBailHook.js | 80 + node_modules/tapable/lib/AsyncParallelHook.js | 32 + node_modules/tapable/lib/AsyncSeriesBailHook.js | 36 + node_modules/tapable/lib/AsyncSeriesHook.js | 32 + node_modules/tapable/lib/AsyncSeriesLoopHook.js | 32 + .../tapable/lib/AsyncSeriesWaterfallHook.js | 46 + node_modules/tapable/lib/Hook.js | 176 ++ node_modules/tapable/lib/HookCodeFactory.js | 385 ++++ node_modules/tapable/lib/HookMap.js | 56 + node_modules/tapable/lib/MultiHook.js | 50 + node_modules/tapable/lib/SyncBailHook.js | 41 + node_modules/tapable/lib/SyncHook.js | 37 + node_modules/tapable/lib/SyncLoopHook.js | 37 + node_modules/tapable/lib/SyncWaterfallHook.js | 51 + node_modules/tapable/lib/Tapable.js | 81 + .../tapable/lib/__tests__/AsyncParallelHooks.js | 37 + .../tapable/lib/__tests__/AsyncSeriesHooks.js | 51 + node_modules/tapable/lib/__tests__/Hook.js | 70 + .../tapable/lib/__tests__/HookCodeFactory.js | 252 +++ node_modules/tapable/lib/__tests__/HookTester.js | 1203 +++++++++++ node_modules/tapable/lib/__tests__/MultiHook.js | 76 + node_modules/tapable/lib/__tests__/SyncBailHook.js | 73 + node_modules/tapable/lib/__tests__/SyncHook.js | 104 + node_modules/tapable/lib/__tests__/SyncHooks.js | 67 + node_modules/tapable/lib/__tests__/Tapable.js | 63 + .../__snapshots__/AsyncParallelHooks.js.snap | 1469 +++++++++++++ .../__snapshots__/AsyncSeriesHooks.js.snap | 2214 ++++++++++++++++++++ .../__snapshots__/HookCodeFactory.js.snap | 880 ++++++++ .../lib/__tests__/__snapshots__/SyncHooks.js.snap | 876 ++++++++ node_modules/tapable/lib/index.js | 19 + node_modules/tapable/package.json | 38 + 33 files changed, 8973 insertions(+) create mode 100644 node_modules/tapable/LICENSE create mode 100644 node_modules/tapable/README.md create mode 100644 node_modules/tapable/lib/AsyncParallelBailHook.js create mode 100644 node_modules/tapable/lib/AsyncParallelHook.js create mode 100644 node_modules/tapable/lib/AsyncSeriesBailHook.js create mode 100644 node_modules/tapable/lib/AsyncSeriesHook.js create mode 100644 node_modules/tapable/lib/AsyncSeriesLoopHook.js create mode 100644 node_modules/tapable/lib/AsyncSeriesWaterfallHook.js create mode 100644 node_modules/tapable/lib/Hook.js create mode 100644 node_modules/tapable/lib/HookCodeFactory.js create mode 100644 node_modules/tapable/lib/HookMap.js create mode 100644 node_modules/tapable/lib/MultiHook.js create mode 100644 node_modules/tapable/lib/SyncBailHook.js create mode 100644 node_modules/tapable/lib/SyncHook.js create mode 100644 node_modules/tapable/lib/SyncLoopHook.js create mode 100644 node_modules/tapable/lib/SyncWaterfallHook.js create mode 100644 node_modules/tapable/lib/Tapable.js create mode 100644 node_modules/tapable/lib/__tests__/AsyncParallelHooks.js create mode 100644 node_modules/tapable/lib/__tests__/AsyncSeriesHooks.js create mode 100644 node_modules/tapable/lib/__tests__/Hook.js create mode 100644 node_modules/tapable/lib/__tests__/HookCodeFactory.js create mode 100644 node_modules/tapable/lib/__tests__/HookTester.js create mode 100644 node_modules/tapable/lib/__tests__/MultiHook.js create mode 100644 node_modules/tapable/lib/__tests__/SyncBailHook.js create mode 100644 node_modules/tapable/lib/__tests__/SyncHook.js create mode 100644 node_modules/tapable/lib/__tests__/SyncHooks.js create mode 100644 node_modules/tapable/lib/__tests__/Tapable.js create mode 100644 node_modules/tapable/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap create mode 100644 node_modules/tapable/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap create mode 100644 node_modules/tapable/lib/__tests__/__snapshots__/HookCodeFactory.js.snap create mode 100644 node_modules/tapable/lib/__tests__/__snapshots__/SyncHooks.js.snap create mode 100644 node_modules/tapable/lib/index.js create mode 100644 node_modules/tapable/package.json (limited to 'node_modules/tapable') diff --git a/node_modules/tapable/LICENSE b/node_modules/tapable/LICENSE new file mode 100644 index 00000000..084338a5 --- /dev/null +++ b/node_modules/tapable/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) Tobias Koppers @sokra + +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. diff --git a/node_modules/tapable/README.md b/node_modules/tapable/README.md new file mode 100644 index 00000000..c68e7d09 --- /dev/null +++ b/node_modules/tapable/README.md @@ -0,0 +1,288 @@ +# Tapable + +The tapable packages exposes many Hook classes, which can be used to create hooks for plugins. + +``` javascript +const { + SyncHook, + SyncBailHook, + SyncWaterfallHook, + SyncLoopHook, + AsyncParallelHook, + AsyncParallelBailHook, + AsyncSeriesHook, + AsyncSeriesBailHook, + AsyncSeriesWaterfallHook + } = require("tapable"); +``` + +## Usage + +All Hook constructors take one optional argument, which is a list of argument names as strings. + +``` js +const hook = new SyncHook(["arg1", "arg2", "arg3"]); +``` + +The best practice is to expose all hooks of a class in a `hooks` property: + +``` js +class Car { + constructor() { + this.hooks = { + accelerate: new SyncHook(["newSpeed"]), + break: new SyncHook(), + calculateRoutes: new AsyncParallelHook(["source", "target", "routesList"]) + }; + } + + /* ... */ +} +``` + +Other people can now use these hooks: + +``` js +const myCar = new Car(); + +// Use the tap method to add a consument +myCar.hooks.break.tap("WarningLampPlugin", () => warningLamp.on()); +``` + +It's required to pass a name to identify the plugin/reason. + +You may receive arguments: + +``` js +myCar.hooks.accelerate.tap("LoggerPlugin", newSpeed => console.log(`Accelerating to ${newSpeed}`)); +``` + +For sync hooks `tap` is the only valid method to add a plugin. Async hooks also support async plugins: + +``` js +myCar.hooks.calculateRoutes.tapPromise("GoogleMapsPlugin", (source, target, routesList) => { + // return a promise + return google.maps.findRoute(source, target).then(route => { + routesList.add(route); + }); +}); +myCar.hooks.calculateRoutes.tapAsync("BingMapsPlugin", (source, target, routesList, callback) => { + bing.findRoute(source, target, (err, route) => { + if(err) return callback(err); + routesList.add(route); + // call the callback + callback(); + }); +}); + +// You can still use sync plugins +myCar.hooks.calculateRoutes.tap("CachedRoutesPlugin", (source, target, routesList) => { + const cachedRoute = cache.get(source, target); + if(cachedRoute) + routesList.add(cachedRoute); +}) +``` + +The class declaring these hooks need to call them: + +``` js +class Car { + /* ... */ + + setSpeed(newSpeed) { + this.hooks.accelerate.call(newSpeed); + } + + useNavigationSystemPromise(source, target) { + const routesList = new List(); + return this.hooks.calculateRoutes.promise(source, target, routesList).then(() => { + return routesList.getRoutes(); + }); + } + + useNavigationSystemAsync(source, target, callback) { + const routesList = new List(); + this.hooks.calculateRoutes.callAsync(source, target, routesList, err => { + if(err) return callback(err); + callback(null, routesList.getRoutes()); + }); + } +} +``` + +The Hook will compile a method with the most efficient way of running your plugins. It generates code depending on: +* The number of registered plugins (none, one, many) +* The kind of registered plugins (sync, async, promise) +* The used call method (sync, async, promise) +* The number of arguments +* Whether interception is used + +This ensures fastest possible execution. + +## Hook types + +Each hook can be tapped with one or several functions. How they are executed depends on the hook type: + +* Basic hook (without “Waterfall”, “Bail” or “Loop” in its name). This hook simply calls every function it’s tapped with in a row. + +* __Waterfall__. A waterfall hook also calls each tapped function in a row. Unlike the basic hook, it passes a return value from each function to the next function. + +* __Bail__. A bail hook allows exitting early. When any of the tapped function returns anything, the bail hook will stop executing the remaining ones. + +* __Loop__. TODO + +Additionally, hooks can be synchronous or asynchronous. To reflect this, there’re “Sync”, “AsyncSeries” and “AsyncParallel” hook classes: + +* __Sync__. A sync hooks can only be tapped with synchronous functions (using `myHook.tap()`). + +* __AsyncSeries__. Async-series hooks can be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). They call each async method in a row. + +* __AsyncParallel__. Async-parallel hooks can also be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). However, they run each async method in parallel. + +The hook type is reflected in its class name. E.g., `AsyncSeriesWaterfallHook` allows asynchronous functions and runs them in series passing each function’s return value into the next function. + + +## Interception + +All Hooks offer an additional interception API: + +``` js +myCar.hooks.calculateRoutes.intercept({ + call: (source, target, routesList) => { + console.log("Starting to calculate routes"); + }, + register: (tapInfo) => { + // tapInfo = { type: "promise", name: "GoogleMapsPlugin", fn: ... } + console.log(`${tapInfo.name} is doing it's job`); + return tapInfo; // may return a new tapInfo object + } +}) +``` + +**call**: `(...args) => void` Adding `call` to your interceptor will trigger when hooks are triggered. You have access to the hooks arguments. + +**tap**: `(tap: Tap) => void` Adding `tap` to your interceptor will trigger when a plugin taps into a hook. Provided is the `Tap` object. `Tap` object can't be changed. + +**loop**: `(...args) => void` Adding `loop` to your interceptor will trigger for each loop of a looping hook. + +**register**: `(tap: Tap) => Tap | undefined` Adding `register` to your interceptor will trigger for each added `Tap` and allows to modify it. + +## Context + +Plugins and interceptors can opt-in to access an optional `context` object, which can be used to pass arbitrary values to subsequent plugins and interceptors. + +``` js +myCar.hooks.accelerate.intercept({ + context: true, + tap: (context, tapInfo) => { + // tapInfo = { type: "sync", name: "NoisePlugin", fn: ... } + console.log(`${tapInfo.name} is doing it's job`); + + // `context` starts as an empty object if at least one plugin uses `context: true`. + // If no plugins use `context: true`, then `context` is undefined. + if (context) { + // Arbitrary properties can be added to `context`, which plugins can then access. + context.hasMuffler = true; + } + } +}); + +myCar.hooks.accelerate.tap({ + name: "NoisePlugin", + context: true +}, (context, newSpeed) => { + if (context && context.hasMuffler) { + console.log("Silence..."); + } else { + console.log("Vroom!"); + } +}); +``` + +## HookMap + +A HookMap is a helper class for a Map with Hooks + +``` js +const keyedHook = new HookMap(key => new SyncHook(["arg"])) +``` + +``` js +keyedHook.tap("some-key", "MyPlugin", (arg) => { /* ... */ }); +keyedHook.tapAsync("some-key", "MyPlugin", (arg, callback) => { /* ... */ }); +keyedHook.tapPromise("some-key", "MyPlugin", (arg) => { /* ... */ }); +``` + +``` js +const hook = keyedHook.get("some-key"); +if(hook !== undefined) { + hook.callAsync("arg", err => { /* ... */ }); +} +``` + +## Hook/HookMap interface + +Public: + +``` ts +interface Hook { + tap: (name: string | Tap, fn: (context?, ...args) => Result) => void, + tapAsync: (name: string | Tap, fn: (context?, ...args, callback: (err, result: Result) => void) => void) => void, + tapPromise: (name: string | Tap, fn: (context?, ...args) => Promise) => void, + intercept: (interceptor: HookInterceptor) => void +} + +interface HookInterceptor { + call: (context?, ...args) => void, + loop: (context?, ...args) => void, + tap: (context?, tap: Tap) => void, + register: (tap: Tap) => Tap, + context: boolean +} + +interface HookMap { + for: (key: any) => Hook, + tap: (key: any, name: string | Tap, fn: (context?, ...args) => Result) => void, + tapAsync: (key: any, name: string | Tap, fn: (context?, ...args, callback: (err, result: Result) => void) => void) => void, + tapPromise: (key: any, name: string | Tap, fn: (context?, ...args) => Promise) => void, + intercept: (interceptor: HookMapInterceptor) => void +} + +interface HookMapInterceptor { + factory: (key: any, hook: Hook) => Hook +} + +interface Tap { + name: string, + type: string + fn: Function, + stage: number, + context: boolean +} +``` + +Protected (only for the class containing the hook): + +``` ts +interface Hook { + isUsed: () => boolean, + call: (...args) => Result, + promise: (...args) => Promise, + callAsync: (...args, callback: (err, result: Result) => void) => void, +} + +interface HookMap { + get: (key: any) => Hook | undefined, + for: (key: any) => Hook +} +``` + +## MultiHook + +A helper Hook-like class to redirect taps to multiple other hooks: + +``` js +const { MultiHook } = require("tapable"); + +this.hooks.allHooks = new MultiHook([this.hooks.hookA, this.hooks.hookB]); +``` diff --git a/node_modules/tapable/lib/AsyncParallelBailHook.js b/node_modules/tapable/lib/AsyncParallelBailHook.js new file mode 100644 index 00000000..3f4476d0 --- /dev/null +++ b/node_modules/tapable/lib/AsyncParallelBailHook.js @@ -0,0 +1,80 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class AsyncParallelBailHookCodeFactory extends HookCodeFactory { + content({ onError, onResult, onDone }) { + let code = ""; + code += `var _results = new Array(${this.options.taps.length});\n`; + code += "var _checkDone = () => {\n"; + code += "for(var i = 0; i < _results.length; i++) {\n"; + code += "var item = _results[i];\n"; + code += "if(item === undefined) return false;\n"; + code += "if(item.result !== undefined) {\n"; + code += onResult("item.result"); + code += "return true;\n"; + code += "}\n"; + code += "if(item.error) {\n"; + code += onError("item.error"); + code += "return true;\n"; + code += "}\n"; + code += "}\n"; + code += "return false;\n"; + code += "}\n"; + code += this.callTapsParallel({ + onError: (i, err, done, doneBreak) => { + let code = ""; + code += `if(${i} < _results.length && ((_results.length = ${i + + 1}), (_results[${i}] = { error: ${err} }), _checkDone())) {\n`; + code += doneBreak(true); + code += "} else {\n"; + code += done(); + code += "}\n"; + return code; + }, + onResult: (i, result, done, doneBreak) => { + let code = ""; + code += `if(${i} < _results.length && (${result} !== undefined && (_results.length = ${i + + 1}), (_results[${i}] = { result: ${result} }), _checkDone())) {\n`; + code += doneBreak(true); + code += "} else {\n"; + code += done(); + code += "}\n"; + return code; + }, + onTap: (i, run, done, doneBreak) => { + let code = ""; + if (i > 0) { + code += `if(${i} >= _results.length) {\n`; + code += done(); + code += "} else {\n"; + } + code += run(); + if (i > 0) code += "}\n"; + return code; + }, + onDone + }); + return code; + } +} + +const factory = new AsyncParallelBailHookCodeFactory(); + +class AsyncParallelBailHook extends Hook { + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +Object.defineProperties(AsyncParallelBailHook.prototype, { + _call: { value: undefined, configurable: true, writable: true } +}); + +module.exports = AsyncParallelBailHook; diff --git a/node_modules/tapable/lib/AsyncParallelHook.js b/node_modules/tapable/lib/AsyncParallelHook.js new file mode 100644 index 00000000..d1e02370 --- /dev/null +++ b/node_modules/tapable/lib/AsyncParallelHook.js @@ -0,0 +1,32 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class AsyncParallelHookCodeFactory extends HookCodeFactory { + content({ onError, onDone }) { + return this.callTapsParallel({ + onError: (i, err, done, doneBreak) => onError(err) + doneBreak(true), + onDone + }); + } +} + +const factory = new AsyncParallelHookCodeFactory(); + +class AsyncParallelHook extends Hook { + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +Object.defineProperties(AsyncParallelHook.prototype, { + _call: { value: undefined, configurable: true, writable: true } +}); + +module.exports = AsyncParallelHook; diff --git a/node_modules/tapable/lib/AsyncSeriesBailHook.js b/node_modules/tapable/lib/AsyncSeriesBailHook.js new file mode 100644 index 00000000..5bfbdd28 --- /dev/null +++ b/node_modules/tapable/lib/AsyncSeriesBailHook.js @@ -0,0 +1,36 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class AsyncSeriesBailHookCodeFactory extends HookCodeFactory { + content({ onError, onResult, onDone }) { + return this.callTapsSeries({ + onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), + onResult: (i, result, next) => + `if(${result} !== undefined) {\n${onResult( + result + )};\n} else {\n${next()}}\n`, + onDone + }); + } +} + +const factory = new AsyncSeriesBailHookCodeFactory(); + +class AsyncSeriesBailHook extends Hook { + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +Object.defineProperties(AsyncSeriesBailHook.prototype, { + _call: { value: undefined, configurable: true, writable: true } +}); + +module.exports = AsyncSeriesBailHook; diff --git a/node_modules/tapable/lib/AsyncSeriesHook.js b/node_modules/tapable/lib/AsyncSeriesHook.js new file mode 100644 index 00000000..f021c448 --- /dev/null +++ b/node_modules/tapable/lib/AsyncSeriesHook.js @@ -0,0 +1,32 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class AsyncSeriesHookCodeFactory extends HookCodeFactory { + content({ onError, onDone }) { + return this.callTapsSeries({ + onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), + onDone + }); + } +} + +const factory = new AsyncSeriesHookCodeFactory(); + +class AsyncSeriesHook extends Hook { + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +Object.defineProperties(AsyncSeriesHook.prototype, { + _call: { value: undefined, configurable: true, writable: true } +}); + +module.exports = AsyncSeriesHook; diff --git a/node_modules/tapable/lib/AsyncSeriesLoopHook.js b/node_modules/tapable/lib/AsyncSeriesLoopHook.js new file mode 100644 index 00000000..f5002884 --- /dev/null +++ b/node_modules/tapable/lib/AsyncSeriesLoopHook.js @@ -0,0 +1,32 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class AsyncSeriesLoopHookCodeFactory extends HookCodeFactory { + content({ onError, onDone }) { + return this.callTapsLooping({ + onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), + onDone + }); + } +} + +const factory = new AsyncSeriesLoopHookCodeFactory(); + +class AsyncSeriesLoopHook extends Hook { + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +Object.defineProperties(AsyncSeriesLoopHook.prototype, { + _call: { value: undefined, configurable: true, writable: true } +}); + +module.exports = AsyncSeriesLoopHook; diff --git a/node_modules/tapable/lib/AsyncSeriesWaterfallHook.js b/node_modules/tapable/lib/AsyncSeriesWaterfallHook.js new file mode 100644 index 00000000..d5532bf5 --- /dev/null +++ b/node_modules/tapable/lib/AsyncSeriesWaterfallHook.js @@ -0,0 +1,46 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class AsyncSeriesWaterfallHookCodeFactory extends HookCodeFactory { + content({ onError, onResult, onDone }) { + return this.callTapsSeries({ + onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), + onResult: (i, result, next) => { + let code = ""; + code += `if(${result} !== undefined) {\n`; + code += `${this._args[0]} = ${result};\n`; + code += `}\n`; + code += next(); + return code; + }, + onDone: () => onResult(this._args[0]) + }); + } +} + +const factory = new AsyncSeriesWaterfallHookCodeFactory(); + +class AsyncSeriesWaterfallHook extends Hook { + constructor(args) { + super(args); + if (args.length < 1) + throw new Error("Waterfall hooks must have at least one argument"); + } + + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +Object.defineProperties(AsyncSeriesWaterfallHook.prototype, { + _call: { value: undefined, configurable: true, writable: true } +}); + +module.exports = AsyncSeriesWaterfallHook; diff --git a/node_modules/tapable/lib/Hook.js b/node_modules/tapable/lib/Hook.js new file mode 100644 index 00000000..6a976e9e --- /dev/null +++ b/node_modules/tapable/lib/Hook.js @@ -0,0 +1,176 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +class Hook { + constructor(args) { + if (!Array.isArray(args)) args = []; + this._args = args; + this.taps = []; + this.interceptors = []; + this.call = this._call; + this.promise = this._promise; + this.callAsync = this._callAsync; + this._x = undefined; + } + + compile(options) { + throw new Error("Abstract: should be overriden"); + } + + _createCall(type) { + return this.compile({ + taps: this.taps, + interceptors: this.interceptors, + args: this._args, + type: type + }); + } + + tap(options, fn) { + if (typeof options === "string") options = { name: options }; + if (typeof options !== "object" || options === null) + throw new Error( + "Invalid arguments to tap(options: Object, fn: function)" + ); + options = Object.assign({ type: "sync", fn: fn }, options); + if (typeof options.name !== "string" || options.name === "") + throw new Error("Missing name for tap"); + options = this._runRegisterInterceptors(options); + this._insert(options); + } + + tapAsync(options, fn) { + if (typeof options === "string") options = { name: options }; + if (typeof options !== "object" || options === null) + throw new Error( + "Invalid arguments to tapAsync(options: Object, fn: function)" + ); + options = Object.assign({ type: "async", fn: fn }, options); + if (typeof options.name !== "string" || options.name === "") + throw new Error("Missing name for tapAsync"); + options = this._runRegisterInterceptors(options); + this._insert(options); + } + + tapPromise(options, fn) { + if (typeof options === "string") options = { name: options }; + if (typeof options !== "object" || options === null) + throw new Error( + "Invalid arguments to tapPromise(options: Object, fn: function)" + ); + options = Object.assign({ type: "promise", fn: fn }, options); + if (typeof options.name !== "string" || options.name === "") + throw new Error("Missing name for tapPromise"); + options = this._runRegisterInterceptors(options); + this._insert(options); + } + + _runRegisterInterceptors(options) { + for (const interceptor of this.interceptors) { + if (interceptor.register) { + const newOptions = interceptor.register(options); + if (newOptions !== undefined) options = newOptions; + } + } + return options; + } + + withOptions(options) { + const mergeOptions = opt => + Object.assign({}, options, typeof opt === "string" ? { name: opt } : opt); + + // Prevent creating endless prototype chains + options = Object.assign({}, options, this._withOptions); + const base = this._withOptionsBase || this; + const newHook = Object.create(base); + + (newHook.tapAsync = (opt, fn) => base.tapAsync(mergeOptions(opt), fn)), + (newHook.tap = (opt, fn) => base.tap(mergeOptions(opt), fn)); + newHook.tapPromise = (opt, fn) => base.tapPromise(mergeOptions(opt), fn); + newHook._withOptions = options; + newHook._withOptionsBase = base; + return newHook; + } + + isUsed() { + return this.taps.length > 0 || this.interceptors.length > 0; + } + + intercept(interceptor) { + this._resetCompilation(); + this.interceptors.push(Object.assign({}, interceptor)); + if (interceptor.register) { + for (let i = 0; i < this.taps.length; i++) + this.taps[i] = interceptor.register(this.taps[i]); + } + } + + _resetCompilation() { + this.call = this._call; + this.callAsync = this._callAsync; + this.promise = this._promise; + } + + _insert(item) { + this._resetCompilation(); + let before; + if (typeof item.before === "string") before = new Set([item.before]); + else if (Array.isArray(item.before)) { + before = new Set(item.before); + } + let stage = 0; + if (typeof item.stage === "number") stage = item.stage; + let i = this.taps.length; + while (i > 0) { + i--; + const x = this.taps[i]; + this.taps[i + 1] = x; + const xStage = x.stage || 0; + if (before) { + if (before.has(x.name)) { + before.delete(x.name); + continue; + } + if (before.size > 0) { + continue; + } + } + if (xStage > stage) { + continue; + } + i++; + break; + } + this.taps[i] = item; + } +} + +function createCompileDelegate(name, type) { + return function lazyCompileHook(...args) { + this[name] = this._createCall(type); + return this[name](...args); + }; +} + +Object.defineProperties(Hook.prototype, { + _call: { + value: createCompileDelegate("call", "sync"), + configurable: true, + writable: true + }, + _promise: { + value: createCompileDelegate("promise", "promise"), + configurable: true, + writable: true + }, + _callAsync: { + value: createCompileDelegate("callAsync", "async"), + configurable: true, + writable: true + } +}); + +module.exports = Hook; diff --git a/node_modules/tapable/lib/HookCodeFactory.js b/node_modules/tapable/lib/HookCodeFactory.js new file mode 100644 index 00000000..c167188b --- /dev/null +++ b/node_modules/tapable/lib/HookCodeFactory.js @@ -0,0 +1,385 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +class HookCodeFactory { + constructor(config) { + this.config = config; + this.options = undefined; + this._args = undefined; + } + + create(options) { + this.init(options); + let fn; + switch (this.options.type) { + case "sync": + fn = new Function( + this.args(), + '"use strict";\n' + + this.header() + + this.content({ + onError: err => `throw ${err};\n`, + onResult: result => `return ${result};\n`, + onDone: () => "", + rethrowIfPossible: true + }) + ); + break; + case "async": + fn = new Function( + this.args({ + after: "_callback" + }), + '"use strict";\n' + + this.header() + + this.content({ + onError: err => `_callback(${err});\n`, + onResult: result => `_callback(null, ${result});\n`, + onDone: () => "_callback();\n" + }) + ); + break; + case "promise": + let code = ""; + code += '"use strict";\n'; + code += "return new Promise((_resolve, _reject) => {\n"; + code += "var _sync = true;\n"; + code += this.header(); + code += this.content({ + onError: err => { + let code = ""; + code += "if(_sync)\n"; + code += `_resolve(Promise.resolve().then(() => { throw ${err}; }));\n`; + code += "else\n"; + code += `_reject(${err});\n`; + return code; + }, + onResult: result => `_resolve(${result});\n`, + onDone: () => "_resolve();\n" + }); + code += "_sync = false;\n"; + code += "});\n"; + fn = new Function(this.args(), code); + break; + } + this.deinit(); + return fn; + } + + setup(instance, options) { + instance._x = options.taps.map(t => t.fn); + } + + /** + * @param {{ type: "sync" | "promise" | "async", taps: Array, interceptors: Array }} options + */ + init(options) { + this.options = options; + this._args = options.args.slice(); + } + + deinit() { + this.options = undefined; + this._args = undefined; + } + + header() { + let code = ""; + if (this.needContext()) { + code += "var _context = {};\n"; + } else { + code += "var _context;\n"; + } + code += "var _x = this._x;\n"; + if (this.options.interceptors.length > 0) { + code += "var _taps = this.taps;\n"; + code += "var _interceptors = this.interceptors;\n"; + } + for (let i = 0; i < this.options.interceptors.length; i++) { + const interceptor = this.options.interceptors[i]; + if (interceptor.call) { + code += `${this.getInterceptor(i)}.call(${this.args({ + before: interceptor.context ? "_context" : undefined + })});\n`; + } + } + return code; + } + + needContext() { + for (const tap of this.options.taps) if (tap.context) return true; + return false; + } + + callTap(tapIndex, { onError, onResult, onDone, rethrowIfPossible }) { + let code = ""; + let hasTapCached = false; + for (let i = 0; i < this.options.interceptors.length; i++) { + const interceptor = this.options.interceptors[i]; + if (interceptor.tap) { + if (!hasTapCached) { + code += `var _tap${tapIndex} = ${this.getTap(tapIndex)};\n`; + hasTapCached = true; + } + code += `${this.getInterceptor(i)}.tap(${ + interceptor.context ? "_context, " : "" + }_tap${tapIndex});\n`; + } + } + code += `var _fn${tapIndex} = ${this.getTapFn(tapIndex)};\n`; + const tap = this.options.taps[tapIndex]; + switch (tap.type) { + case "sync": + if (!rethrowIfPossible) { + code += `var _hasError${tapIndex} = false;\n`; + code += "try {\n"; + } + if (onResult) { + code += `var _result${tapIndex} = _fn${tapIndex}(${this.args({ + before: tap.context ? "_context" : undefined + })});\n`; + } else { + code += `_fn${tapIndex}(${this.args({ + before: tap.context ? "_context" : undefined + })});\n`; + } + if (!rethrowIfPossible) { + code += "} catch(_err) {\n"; + code += `_hasError${tapIndex} = true;\n`; + code += onError("_err"); + code += "}\n"; + code += `if(!_hasError${tapIndex}) {\n`; + } + if (onResult) { + code += onResult(`_result${tapIndex}`); + } + if (onDone) { + code += onDone(); + } + if (!rethrowIfPossible) { + code += "}\n"; + } + break; + case "async": + let cbCode = ""; + if (onResult) cbCode += `(_err${tapIndex}, _result${tapIndex}) => {\n`; + else cbCode += `_err${tapIndex} => {\n`; + cbCode += `if(_err${tapIndex}) {\n`; + cbCode += onError(`_err${tapIndex}`); + cbCode += "} else {\n"; + if (onResult) { + cbCode += onResult(`_result${tapIndex}`); + } + if (onDone) { + cbCode += onDone(); + } + cbCode += "}\n"; + cbCode += "}"; + code += `_fn${tapIndex}(${this.args({ + before: tap.context ? "_context" : undefined, + after: cbCode + })});\n`; + break; + case "promise": + code += `var _hasResult${tapIndex} = false;\n`; + code += `var _promise${tapIndex} = _fn${tapIndex}(${this.args({ + before: tap.context ? "_context" : undefined + })});\n`; + code += `if (!_promise${tapIndex} || !_promise${tapIndex}.then)\n`; + code += ` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${tapIndex} + ')');\n`; + code += `_promise${tapIndex}.then(_result${tapIndex} => {\n`; + code += `_hasResult${tapIndex} = true;\n`; + if (onResult) { + code += onResult(`_result${tapIndex}`); + } + if (onDone) { + code += onDone(); + } + code += `}, _err${tapIndex} => {\n`; + code += `if(_hasResult${tapIndex}) throw _err${tapIndex};\n`; + code += onError(`_err${tapIndex}`); + code += "});\n"; + break; + } + return code; + } + + callTapsSeries({ onError, onResult, onDone, rethrowIfPossible }) { + if (this.options.taps.length === 0) return onDone(); + const firstAsync = this.options.taps.findIndex(t => t.type !== "sync"); + const next = i => { + if (i >= this.options.taps.length) { + return onDone(); + } + const done = () => next(i + 1); + const doneBreak = skipDone => { + if (skipDone) return ""; + return onDone(); + }; + return this.callTap(i, { + onError: error => onError(i, error, done, doneBreak), + onResult: + onResult && + (result => { + return onResult(i, result, done, doneBreak); + }), + onDone: + !onResult && + (() => { + return done(); + }), + rethrowIfPossible: + rethrowIfPossible && (firstAsync < 0 || i < firstAsync) + }); + }; + return next(0); + } + + callTapsLooping({ onError, onDone, rethrowIfPossible }) { + if (this.options.taps.length === 0) return onDone(); + const syncOnly = this.options.taps.every(t => t.type === "sync"); + let code = ""; + if (!syncOnly) { + code += "var _looper = () => {\n"; + code += "var _loopAsync = false;\n"; + } + code += "var _loop;\n"; + code += "do {\n"; + code += "_loop = false;\n"; + for (let i = 0; i < this.options.interceptors.length; i++) { + const interceptor = this.options.interceptors[i]; + if (interceptor.loop) { + code += `${this.getInterceptor(i)}.loop(${this.args({ + before: interceptor.context ? "_context" : undefined + })});\n`; + } + } + code += this.callTapsSeries({ + onError, + onResult: (i, result, next, doneBreak) => { + let code = ""; + code += `if(${result} !== undefined) {\n`; + code += "_loop = true;\n"; + if (!syncOnly) code += "if(_loopAsync) _looper();\n"; + code += doneBreak(true); + code += `} else {\n`; + code += next(); + code += `}\n`; + return code; + }, + onDone: + onDone && + (() => { + let code = ""; + code += "if(!_loop) {\n"; + code += onDone(); + code += "}\n"; + return code; + }), + rethrowIfPossible: rethrowIfPossible && syncOnly + }); + code += "} while(_loop);\n"; + if (!syncOnly) { + code += "_loopAsync = true;\n"; + code += "};\n"; + code += "_looper();\n"; + } + return code; + } + + callTapsParallel({ + onError, + onResult, + onDone, + rethrowIfPossible, + onTap = (i, run) => run() + }) { + if (this.options.taps.length <= 1) { + return this.callTapsSeries({ + onError, + onResult, + onDone, + rethrowIfPossible + }); + } + let code = ""; + code += "do {\n"; + code += `var _counter = ${this.options.taps.length};\n`; + if (onDone) { + code += "var _done = () => {\n"; + code += onDone(); + code += "};\n"; + } + for (let i = 0; i < this.options.taps.length; i++) { + const done = () => { + if (onDone) return "if(--_counter === 0) _done();\n"; + else return "--_counter;"; + }; + const doneBreak = skipDone => { + if (skipDone || !onDone) return "_counter = 0;\n"; + else return "_counter = 0;\n_done();\n"; + }; + code += "if(_counter <= 0) break;\n"; + code += onTap( + i, + () => + this.callTap(i, { + onError: error => { + let code = ""; + code += "if(_counter > 0) {\n"; + code += onError(i, error, done, doneBreak); + code += "}\n"; + return code; + }, + onResult: + onResult && + (result => { + let code = ""; + code += "if(_counter > 0) {\n"; + code += onResult(i, result, done, doneBreak); + code += "}\n"; + return code; + }), + onDone: + !onResult && + (() => { + return done(); + }), + rethrowIfPossible + }), + done, + doneBreak + ); + } + code += "} while(false);\n"; + return code; + } + + args({ before, after } = {}) { + let allArgs = this._args; + if (before) allArgs = [before].concat(allArgs); + if (after) allArgs = allArgs.concat(after); + if (allArgs.length === 0) { + return ""; + } else { + return allArgs.join(", "); + } + } + + getTapFn(idx) { + return `_x[${idx}]`; + } + + getTap(idx) { + return `_taps[${idx}]`; + } + + getInterceptor(idx) { + return `_interceptors[${idx}]`; + } +} + +module.exports = HookCodeFactory; diff --git a/node_modules/tapable/lib/HookMap.js b/node_modules/tapable/lib/HookMap.js new file mode 100644 index 00000000..0397d8e3 --- /dev/null +++ b/node_modules/tapable/lib/HookMap.js @@ -0,0 +1,56 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +class HookMap { + constructor(factory) { + this._map = new Map(); + this._factory = factory; + this._interceptors = []; + } + + get(key) { + return this._map.get(key); + } + + for(key) { + const hook = this.get(key); + if (hook !== undefined) { + return hook; + } + let newHook = this._factory(key); + const interceptors = this._interceptors; + for (let i = 0; i < interceptors.length; i++) { + newHook = interceptors[i].factory(key, newHook); + } + this._map.set(key, newHook); + return newHook; + } + + intercept(interceptor) { + this._interceptors.push( + Object.assign( + { + factory: (key, hook) => hook + }, + interceptor + ) + ); + } + + tap(key, options, fn) { + return this.for(key).tap(options, fn); + } + + tapAsync(key, options, fn) { + return this.for(key).tapAsync(options, fn); + } + + tapPromise(key, options, fn) { + return this.for(key).tapPromise(options, fn); + } +} + +module.exports = HookMap; diff --git a/node_modules/tapable/lib/MultiHook.js b/node_modules/tapable/lib/MultiHook.js new file mode 100644 index 00000000..cddd9177 --- /dev/null +++ b/node_modules/tapable/lib/MultiHook.js @@ -0,0 +1,50 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); + +class MultiHook { + constructor(hooks) { + this.hooks = hooks; + } + + tap(options, fn) { + for (const hook of this.hooks) { + hook.tap(options, fn); + } + } + + tapAsync(options, fn) { + for (const hook of this.hooks) { + hook.tapAsync(options, fn); + } + } + + tapPromise(options, fn) { + for (const hook of this.hooks) { + hook.tapPromise(options, fn); + } + } + + isUsed() { + for (const hook of this.hooks) { + if (hook.isUsed()) return true; + } + return false; + } + + intercept(interceptor) { + for (const hook of this.hooks) { + hook.intercept(interceptor); + } + } + + withOptions(options) { + return new MultiHook(this.hooks.map(h => h.withOptions(options))); + } +} + +module.exports = MultiHook; diff --git a/node_modules/tapable/lib/SyncBailHook.js b/node_modules/tapable/lib/SyncBailHook.js new file mode 100644 index 00000000..06339925 --- /dev/null +++ b/node_modules/tapable/lib/SyncBailHook.js @@ -0,0 +1,41 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class SyncBailHookCodeFactory extends HookCodeFactory { + content({ onError, onResult, onDone, rethrowIfPossible }) { + return this.callTapsSeries({ + onError: (i, err) => onError(err), + onResult: (i, result, next) => + `if(${result} !== undefined) {\n${onResult( + result + )};\n} else {\n${next()}}\n`, + onDone, + rethrowIfPossible + }); + } +} + +const factory = new SyncBailHookCodeFactory(); + +class SyncBailHook extends Hook { + tapAsync() { + throw new Error("tapAsync is not supported on a SyncBailHook"); + } + + tapPromise() { + throw new Error("tapPromise is not supported on a SyncBailHook"); + } + + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +module.exports = SyncBailHook; diff --git a/node_modules/tapable/lib/SyncHook.js b/node_modules/tapable/lib/SyncHook.js new file mode 100644 index 00000000..e13ac8c3 --- /dev/null +++ b/node_modules/tapable/lib/SyncHook.js @@ -0,0 +1,37 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class SyncHookCodeFactory extends HookCodeFactory { + content({ onError, onResult, onDone, rethrowIfPossible }) { + return this.callTapsSeries({ + onError: (i, err) => onError(err), + onDone, + rethrowIfPossible + }); + } +} + +const factory = new SyncHookCodeFactory(); + +class SyncHook extends Hook { + tapAsync() { + throw new Error("tapAsync is not supported on a SyncHook"); + } + + tapPromise() { + throw new Error("tapPromise is not supported on a SyncHook"); + } + + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +module.exports = SyncHook; diff --git a/node_modules/tapable/lib/SyncLoopHook.js b/node_modules/tapable/lib/SyncLoopHook.js new file mode 100644 index 00000000..cd7578d4 --- /dev/null +++ b/node_modules/tapable/lib/SyncLoopHook.js @@ -0,0 +1,37 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class SyncLoopHookCodeFactory extends HookCodeFactory { + content({ onError, onResult, onDone, rethrowIfPossible }) { + return this.callTapsLooping({ + onError: (i, err) => onError(err), + onDone, + rethrowIfPossible + }); + } +} + +const factory = new SyncLoopHookCodeFactory(); + +class SyncLoopHook extends Hook { + tapAsync() { + throw new Error("tapAsync is not supported on a SyncLoopHook"); + } + + tapPromise() { + throw new Error("tapPromise is not supported on a SyncLoopHook"); + } + + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +module.exports = SyncLoopHook; diff --git a/node_modules/tapable/lib/SyncWaterfallHook.js b/node_modules/tapable/lib/SyncWaterfallHook.js new file mode 100644 index 00000000..64b615e5 --- /dev/null +++ b/node_modules/tapable/lib/SyncWaterfallHook.js @@ -0,0 +1,51 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Hook = require("./Hook"); +const HookCodeFactory = require("./HookCodeFactory"); + +class SyncWaterfallHookCodeFactory extends HookCodeFactory { + content({ onError, onResult, onDone, rethrowIfPossible }) { + return this.callTapsSeries({ + onError: (i, err) => onError(err), + onResult: (i, result, next) => { + let code = ""; + code += `if(${result} !== undefined) {\n`; + code += `${this._args[0]} = ${result};\n`; + code += `}\n`; + code += next(); + return code; + }, + onDone: () => onResult(this._args[0]), + rethrowIfPossible + }); + } +} + +const factory = new SyncWaterfallHookCodeFactory(); + +class SyncWaterfallHook extends Hook { + constructor(args) { + super(args); + if (args.length < 1) + throw new Error("Waterfall hooks must have at least one argument"); + } + + tapAsync() { + throw new Error("tapAsync is not supported on a SyncWaterfallHook"); + } + + tapPromise() { + throw new Error("tapPromise is not supported on a SyncWaterfallHook"); + } + + compile(options) { + factory.setup(this, options); + return factory.create(options); + } +} + +module.exports = SyncWaterfallHook; diff --git a/node_modules/tapable/lib/Tapable.js b/node_modules/tapable/lib/Tapable.js new file mode 100644 index 00000000..530fea35 --- /dev/null +++ b/node_modules/tapable/lib/Tapable.js @@ -0,0 +1,81 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const util = require("util"); +const SyncBailHook = require("./SyncBailHook"); + +function Tapable() { + this._pluginCompat = new SyncBailHook(["options"]); + this._pluginCompat.tap( + { + name: "Tapable camelCase", + stage: 100 + }, + options => { + options.names.add( + options.name.replace(/[- ]([a-z])/g, (str, ch) => ch.toUpperCase()) + ); + } + ); + this._pluginCompat.tap( + { + name: "Tapable this.hooks", + stage: 200 + }, + options => { + let hook; + for (const name of options.names) { + hook = this.hooks[name]; + if (hook !== undefined) { + break; + } + } + if (hook !== undefined) { + const tapOpt = { + name: options.fn.name || "unnamed compat plugin", + stage: options.stage || 0 + }; + if (options.async) hook.tapAsync(tapOpt, options.fn); + else hook.tap(tapOpt, options.fn); + return true; + } + } + ); +} +module.exports = Tapable; + +Tapable.addCompatLayer = function addCompatLayer(instance) { + Tapable.call(instance); + instance.plugin = Tapable.prototype.plugin; + instance.apply = Tapable.prototype.apply; +}; + +Tapable.prototype.plugin = util.deprecate(function plugin(name, fn) { + if (Array.isArray(name)) { + name.forEach(function(name) { + this.plugin(name, fn); + }, this); + return; + } + const result = this._pluginCompat.call({ + name: name, + fn: fn, + names: new Set([name]) + }); + if (!result) { + throw new Error( + `Plugin could not be registered at '${name}'. Hook was not found.\n` + + "BREAKING CHANGE: There need to exist a hook at 'this.hooks'. " + + "To create a compatibility layer for this hook, hook into 'this._pluginCompat'." + ); + } +}, "Tapable.plugin is deprecated. Use new API on `.hooks` instead"); + +Tapable.prototype.apply = util.deprecate(function apply() { + for (var i = 0; i < arguments.length; i++) { + arguments[i].apply(this); + } +}, "Tapable.apply is deprecated. Call apply on the plugin directly instead"); diff --git a/node_modules/tapable/lib/__tests__/AsyncParallelHooks.js b/node_modules/tapable/lib/__tests__/AsyncParallelHooks.js new file mode 100644 index 00000000..c762fad3 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/AsyncParallelHooks.js @@ -0,0 +1,37 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const HookTester = require("./HookTester"); +const AsyncParallelHook = require("../AsyncParallelHook"); +const AsyncParallelBailHook = require("../AsyncParallelBailHook"); + +describe("AsyncParallelHook", () => { + it( + "should have to correct behavior", + async () => { + const tester = new HookTester(args => new AsyncParallelHook(args)); + + const result = await tester.run(); + + expect(result).toMatchSnapshot(); + }, + 15000 + ); +}); + +describe("AsyncParallelBailHook", () => { + it( + "should have to correct behavior", + async () => { + const tester = new HookTester(args => new AsyncParallelBailHook(args)); + + const result = await tester.run(); + + expect(result).toMatchSnapshot(); + }, + 15000 + ); +}); diff --git a/node_modules/tapable/lib/__tests__/AsyncSeriesHooks.js b/node_modules/tapable/lib/__tests__/AsyncSeriesHooks.js new file mode 100644 index 00000000..6fa3ed72 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/AsyncSeriesHooks.js @@ -0,0 +1,51 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const HookTester = require("./HookTester"); +const AsyncSeriesHook = require("../AsyncSeriesHook"); +const AsyncSeriesBailHook = require("../AsyncSeriesBailHook"); +const AsyncSeriesWaterfallHook = require("../AsyncSeriesWaterfallHook"); +const AsyncSeriesLoopHook = require("../AsyncSeriesLoopHook"); + +describe("AsyncSeriesHook", () => { + it("should have to correct behavior", async () => { + const tester = new HookTester(args => new AsyncSeriesHook(args)); + + const result = await tester.run(); + + expect(result).toMatchSnapshot(); + }); +}); + +describe("AsyncSeriesBailHook", () => { + it("should have to correct behavior", async () => { + const tester = new HookTester(args => new AsyncSeriesBailHook(args)); + + const result = await tester.run(); + + expect(result).toMatchSnapshot(); + }); +}); + +describe("AsyncSeriesWaterfallHook", () => { + it("should have to correct behavior", async () => { + const tester = new HookTester(args => new AsyncSeriesWaterfallHook(args)); + + const result = await tester.run(); + + expect(result).toMatchSnapshot(); + }); +}); + +describe("AsyncSeriesLoopHook", () => { + it("should have to correct behavior", async () => { + const tester = new HookTester(args => new AsyncSeriesLoopHook(args)); + + const result = await tester.runForLoop(); + + expect(result).toMatchSnapshot(); + }); +}); diff --git a/node_modules/tapable/lib/__tests__/Hook.js b/node_modules/tapable/lib/__tests__/Hook.js new file mode 100644 index 00000000..71a73d5d --- /dev/null +++ b/node_modules/tapable/lib/__tests__/Hook.js @@ -0,0 +1,70 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const SyncHook = require("../SyncHook"); + +describe("Hook", () => { + it("should allow to insert hooks before others and in stages", () => { + const hook = new SyncHook(); + + const calls = []; + hook.tap("A", () => calls.push("A")); + hook.tap( + { + name: "B", + before: "A" + }, + () => calls.push("B") + ); + + calls.length = 0; + hook.call(); + expect(calls).toEqual(["B", "A"]); + + hook.tap( + { + name: "C", + before: ["A", "B"] + }, + () => calls.push("C") + ); + + calls.length = 0; + hook.call(); + expect(calls).toEqual(["C", "B", "A"]); + + hook.tap( + { + name: "D", + before: "B" + }, + () => calls.push("D") + ); + + calls.length = 0; + hook.call(); + expect(calls).toEqual(["C", "D", "B", "A"]); + + hook.tap( + { + name: "E", + stage: -5 + }, + () => calls.push("E") + ); + hook.tap( + { + name: "F", + stage: -3 + }, + () => calls.push("F") + ); + + calls.length = 0; + hook.call(); + expect(calls).toEqual(["E", "F", "C", "D", "B", "A"]); + }); +}); diff --git a/node_modules/tapable/lib/__tests__/HookCodeFactory.js b/node_modules/tapable/lib/__tests__/HookCodeFactory.js new file mode 100644 index 00000000..759d1511 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/HookCodeFactory.js @@ -0,0 +1,252 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const HookCodeFactory = require("../HookCodeFactory"); + +const expectNoSyntaxError = code => { + new Function("a, b, c", code); +}; + +describe("HookCodeFactory", () => { + describe("callTap", () => { + const factoryConfigurations = { + "no args, no intercept": { + args: [], + taps: [ + { + type: "sync" + }, + { + type: "async" + }, + { + type: "promise" + } + ], + interceptors: [] + }, + "with args, no intercept": { + args: ["a", "b", "c"], + taps: [ + { + type: "sync" + }, + { + type: "async" + }, + { + type: "promise" + } + ], + interceptors: [] + }, + "with args, with intercept": { + args: ["a", "b", "c"], + taps: [ + { + type: "sync" + }, + { + type: "async" + }, + { + type: "promise" + } + ], + interceptors: [ + { + call: () => {}, + tap: () => {} + }, + { + tap: () => {} + }, + { + call: () => {} + } + ] + } + }; + for (const configurationName in factoryConfigurations) { + describe(`(${configurationName})`, () => { + let factory; + beforeEach(() => { + factory = new HookCodeFactory(); + factory.init(factoryConfigurations[configurationName]); + }); + it("sync without onResult", () => { + const code = factory.callTap(0, { + onError: err => `onError(${err});\n`, + onDone: () => "onDone();\n" + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + it("sync with onResult", () => { + const code = factory.callTap(0, { + onError: err => `onError(${err});\n`, + onResult: result => `onResult(${result});\n` + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + it("async without onResult", () => { + const code = factory.callTap(1, { + onError: err => `onError(${err});\n`, + onDone: () => "onDone();\n" + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + it("async with onResult", () => { + const code = factory.callTap(1, { + onError: err => `onError(${err});\n`, + onResult: result => `onResult(${result});\n` + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + it("promise without onResult", () => { + const code = factory.callTap(2, { + onError: err => `onError(${err});\n`, + onDone: () => "onDone();\n" + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + it("promise with onResult", () => { + const code = factory.callTap(2, { + onError: err => `onError(${err});\n`, + onResult: result => `onResult(${result});\n` + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + }); + } + }); + describe("taps", () => { + const factoryConfigurations = { + none: { + args: ["a", "b", "c"], + taps: [], + interceptors: [] + }, + "single sync": { + args: ["a", "b", "c"], + taps: [ + { + type: "sync" + } + ], + interceptors: [] + }, + "multiple sync": { + args: ["a", "b", "c"], + taps: [ + { + type: "sync" + }, + { + type: "sync" + }, + { + type: "sync" + } + ], + interceptors: [] + }, + "single async": { + args: ["a", "b", "c"], + taps: [ + { + type: "async" + } + ], + interceptors: [] + }, + "single promise": { + args: ["a", "b", "c"], + taps: [ + { + type: "promise" + } + ], + interceptors: [] + }, + mixed: { + args: ["a", "b", "c"], + taps: [ + { + type: "sync" + }, + { + type: "async" + }, + { + type: "promise" + } + ], + interceptors: [] + }, + mixed2: { + args: ["a", "b", "c"], + taps: [ + { + type: "async" + }, + { + type: "promise" + }, + { + type: "sync" + } + ], + interceptors: [] + } + }; + for (const configurationName in factoryConfigurations) { + describe(`(${configurationName})`, () => { + let factory; + beforeEach(() => { + factory = new HookCodeFactory(); + factory.init(factoryConfigurations[configurationName]); + }); + it("callTapsSeries", () => { + const code = factory.callTapsSeries({ + onError: (i, err) => `onError(${i}, ${err});\n`, + onResult: (i, result, next, doneBreak) => + `onResult(${i}, ${result}, () => {\n${next()}}, () => {\n${doneBreak()}});\n`, + onDone: () => "onDone();\n", + rethrowIfPossible: true + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + it("callTapsParallel", () => { + const code = factory.callTapsParallel({ + onError: (i, err) => `onError(${i}, ${err});\n`, + onResult: (i, result, done, doneBreak) => + `onResult(${i}, ${result}, () => {\n${done()}}, () => {\n${doneBreak()}});\n`, + onDone: () => "onDone();\n", + rethrowIfPossible: true + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + it("callTapsLooping", () => { + const code = factory.callTapsLooping({ + onError: (i, err) => `onError(${i}, ${err});\n`, + onDone: () => "onDone();\n", + rethrowIfPossible: true + }); + expect(code).toMatchSnapshot(); + expectNoSyntaxError(code); + }); + }); + } + }); +}); diff --git a/node_modules/tapable/lib/__tests__/HookTester.js b/node_modules/tapable/lib/__tests__/HookTester.js new file mode 100644 index 00000000..ae5659f7 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/HookTester.js @@ -0,0 +1,1203 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +require("babel-polyfill"); + +describe("HookTester", () => { + it("should run", () => {}); +}); + +process.on("unhandledRejection", err => console.error(err.stack)); + +class HookTester { + constructor(hookCreator, sync) { + this.hookCreator = hookCreator; + this.sync = sync; + } + + async run(syncOnly) { + const result = { + sync: {}, + async: {}, + intercept: {} + }; + + if (syncOnly) { + await this.runSync(result.sync, "call"); + } else { + await this.runAsync(result.async, "callAsync"); + await this.runAsync(result.async, "promise"); + + await this.runIntercept(result.intercept, "callAsync"); + await this.runIntercept(result.intercept, "promise"); + } + + await this.runSync(result.sync, "callAsync"); + await this.runSync(result.sync, "promise"); + + return result; + } + + async runForLoop(syncOnly) { + const result = { + sync: {}, + async: {} + }; + + if (syncOnly) { + await this.runForLoopSync(result.sync, "call"); + } else { + await this.runForLoopAsync(result.async, "callAsync"); + await this.runForLoopAsync(result.async, "promise"); + } + + await this.runForLoopSync(result.sync, "callAsync"); + await this.runForLoopSync(result.sync, "promise"); + + return result; + } + + async runForLoopAsync(result, method) { + { + const hook = this.createHook([], `${method}BrokenPromise`); + hook.tapPromise("promise", () => "this is not a promise"); + result[`${method}BrokenPromise`] = await this.gainResult(cb => + hook[method](cb) + ); + } + { + const hook = this.createHook([], `${method}SinglePromise`); + hook.tapPromise("promise", () => { + result[`${method}SinglePromiseCalled`] = + (result[`${method}SinglePromiseCalled`] || 0) + 1; + if (result[`${method}SinglePromiseCalled`] < 42) + return Promise.resolve().then(() => true); + return Promise.resolve().then(() => {}); + }); + result[`${method}SinglePromise`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook([], `${method}MultiplePromise`); + hook.tapPromise("promise1", () => { + result[`${method}MultiplePromiseCalled1`] = + (result[`${method}MultiplePromiseCalled1`] || 0) + 1; + if (result[`${method}MultiplePromiseCalled1`] < 42) + return Promise.resolve().then(() => true); + return Promise.resolve().then(() => {}); + }); + hook.tapPromise("promise2", () => { + result[`${method}MultiplePromiseCalled2`] = + (result[`${method}MultiplePromiseCalled2`] || 0) + 1; + if (result[`${method}MultiplePromiseCalled2`] < 42) + return Promise.resolve().then(() => true); + return Promise.resolve().then(() => {}); + }); + result[`${method}MultiplePromise`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook([], `${method}SingleAsync`); + hook.tapAsync("async", callback => { + result[`${method}SingleAsyncCalled`] = + (result[`${method}SingleAsyncCalled`] || 0) + 1; + if (result[`${method}SingleAsyncCalled`] < 42) + return Promise.resolve().then(() => callback(null, true)); + return Promise.resolve().then(() => callback()); + }); + result[`${method}SingleAsync`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook([], `${method}MultipleAsync`); + hook.tapAsync("async1", callback => { + result[`${method}MultipleAsyncCalled1`] = + (result[`${method}MultipleAsyncCalled1`] || 0) + 1; + if (result[`${method}MultipleAsyncCalled1`] < 42) + return Promise.resolve().then(() => callback(null, true)); + return Promise.resolve().then(() => callback()); + }); + hook.tapAsync("async2", callback => { + result[`${method}MultipleAsyncCalled2`] = + (result[`${method}MultipleAsyncCalled2`] || 0) + 1; + if (result[`${method}MultipleAsyncCalled2`] < 42) + return Promise.resolve().then(() => callback(null, true)); + return Promise.resolve().then(() => callback()); + }); + result[`${method}MultipleAsync`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook([], `${method}Mixed`); + hook.tapAsync("async1", callback => { + result[`${method}MixedCalled1`] = + (result[`${method}MixedCalled1`] || 0) + 1; + if (result[`${method}MixedCalled1`] < 42) + return Promise.resolve().then(() => callback(null, true)); + return Promise.resolve().then(() => callback()); + }); + hook.tap("sync2", () => { + result[`${method}MixedCalled2`] = + (result[`${method}MixedCalled2`] || 0) + 1; + if (result[`${method}MixedCalled2`] < 42) return true; + }); + hook.tapPromise("promise3", () => { + result[`${method}MixedCalled3`] = + (result[`${method}MixedCalled3`] || 0) + 1; + if (result[`${method}MixedCalled3`] < 42) + return Promise.resolve().then(() => true); + return Promise.resolve().then(() => {}); + }); + result[`${method}Mixed`] = await this.gainResult(cb => hook[method](cb)); + } + } + + async runForLoopSync(result, method) { + { + const hook = this.createHook([], `${method}None`); + result[`${method}None`] = await this.gainResult(cb => hook[method](cb)); + } + + { + const hook = this.createHook(["arg"], `${method}NoneWithArg`); + result[`${method}NoneWithArg`] = await this.gainResult(cb => + hook[method](42, cb) + ); + } + + { + const hook = this.createHook([], `${method}SingleSync`); + hook.tap("sync", () => { + result[`${method}SingleSyncCalled`] = + (result[`${method}SingleSyncCalled`] || 0) + 1; + if (result[`${method}SingleSyncCalled`] < 42) return true; + }); + result[`${method}SingleSync`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook([], `${method}MultipleSync`); + hook.tap("sync1", () => { + result[`${method}MultipleSyncCalled1`] = + (result[`${method}MultipleSyncCalled1`] || 0) + 1; + if (result[`${method}MultipleSyncCalled1`] < 42) return true; + }); + hook.tap("sync2", () => { + result[`${method}MultipleSyncCalled2`] = + (result[`${method}MultipleSyncCalled2`] || 0) + 1; + if (result[`${method}MultipleSyncCalled2`] < 42) return true; + }); + result[`${method}MultipleSync`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook([], `${method}InterceptedSync`); + hook.tap("sync1", () => { + result[`${method}InterceptedSyncCalled1`] = + (result[`${method}InterceptedSyncCalled1`] || 0) + 1; + if (result[`${method}InterceptedSyncCalled1`] < 42) return true; + }); + hook.tap("sync2", () => { + result[`${method}InterceptedSyncCalled2`] = + (result[`${method}InterceptedSyncCalled2`] || 0) + 1; + if (result[`${method}InterceptedSyncCalled2`] < 42) return true; + }); + hook.intercept({ + call: a => + (result[`${method}InterceptedSyncCalledCall`] = + (result[`${method}InterceptedSyncCalledCall`] || 0) + 1), + loop: a => + (result[`${method}InterceptedSyncCalledLoop`] = + (result[`${method}InterceptedSyncCalledLoop`] || 0) + 1), + tap: tap => { + result[`${method}InterceptedSyncCalledTap`] = + (result[`${method}InterceptedSyncCalledTap`] || 0) + 1; + } + }); + result[`${method}InterceptedSync`] = await this.gainResult(cb => + hook[method](cb) + ); + } + } + + async runSync(result, method) { + { + const hook = this.createHook([], `${method}None`); + result[`${method}None`] = await this.gainResult(cb => hook[method](cb)); + } + + { + const hook = this.createHook(["arg"], `${method}NoneWithArg`); + result[`${method}NoneWithArg`] = await this.gainResult(cb => + hook[method](42, cb) + ); + } + + { + const hook = this.createHook([], `${method}SingleSync`); + hook.tap("sync", () => { + result[`${method}SingleSyncCalled`] = true; + return 42; + }); + result[`${method}SingleSync`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook(["myArg"], `${method}SingleSyncWithArg`); + hook.tap("sync", nr => { + result[`${method}SingleSyncWithArgCalled`] = nr; + return nr; + }); + result[`${method}SingleSyncWithArg`] = await this.gainResult(cb => + hook[method](42, cb) + ); + } + + { + const hook = this.createHook([], `${method}MultipleSync`); + hook.tap("sync1", () => { + result[`${method}MultipleSyncCalled1`] = true; + return 42; + }); + hook.tap("sync2", () => { + result[`${method}MultipleSyncCalled2`] = true; + return 43; + }); + result[`${method}MultipleSync`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook(["a"], `${method}MultipleSyncWithArg`); + hook.tap("sync1", a => { + result[`${method}MultipleSyncWithArgCalled1`] = a; + return 42 + a; + }); + hook.tap("sync2", a => { + result[`${method}MultipleSyncWithArgCalled2`] = a; + return 43 + a; + }); + result[`${method}MultipleSyncWithArg`] = await this.gainResult(cb => + hook[method](42, cb) + ); + } + + { + const hook = this.createHook( + ["a"], + `${method}MultipleSyncWithArgNoReturn` + ); + hook.tap("sync1", a => { + result[`${method}MultipleSyncWithArgNoReturnCalled1`] = a; + }); + hook.tap("sync2", a => { + result[`${method}MultipleSyncWithArgNoReturnCalled2`] = a; + }); + result[`${method}MultipleSyncWithArgNoReturn`] = await this.gainResult( + cb => hook[method](42, cb) + ); + } + + { + const hook = this.createHook( + ["a"], + `${method}MultipleSyncWithArgFirstReturn` + ); + hook.tap("sync1", a => { + result[`${method}MultipleSyncWithArgFirstReturnCalled1`] = a; + return 42 + a; + }); + hook.tap("sync2", a => { + result[`${method}MultipleSyncWithArgFirstReturnCalled2`] = a; + }); + result[`${method}MultipleSyncWithArgFirstReturn`] = await this.gainResult( + cb => hook[method](42, cb) + ); + } + + { + const hook = this.createHook( + ["a"], + `${method}MultipleSyncWithArgLastReturn` + ); + hook.tap("sync1", a => { + result[`${method}MultipleSyncWithArgLastReturnCalled1`] = a; + }); + hook.tap("sync2", a => { + result[`${method}MultipleSyncWithArgLastReturnCalled2`] = a; + return 43 + a; + }); + result[`${method}MultipleSyncWithArgLastReturn`] = await this.gainResult( + cb => hook[method](42, cb) + ); + } + + { + const hook = this.createHook( + ["a", "b", "c"], + `${method}MultipleSyncWithArgs` + ); + hook.tap("sync1", (a, b, c) => { + result[`${method}MultipleSyncWithArgsCalled1`] = [a, b, c]; + return a + b + c; + }); + hook.tap("sync2", (a, b, c) => { + result[`${method}MultipleSyncWithArgsCalled2`] = [a, b, c]; + return a + b + c + 1; + }); + result[`${method}MultipleSyncWithArgs`] = await this.gainResult(cb => + hook[method](42, 43, 44, cb) + ); + } + + { + const hook = this.createHook([], `${method}MultipleSyncError`); + hook.tap("sync1", () => { + result[`${method}MultipleSyncErrorCalled1`] = true; + }); + hook.tap("sync2", () => { + result[`${method}MultipleSyncErrorCalled2`] = true; + throw new Error("Error in sync2"); + }); + hook.tap("sync3", () => { + result[`${method}MultipleSyncErrorCalled3`] = true; + }); + result[`${method}MultipleSyncError`] = await this.gainResult(cb => + hook[method](cb) + ); + } + + { + const hook = this.createHook(["a", "b", "c"], `${method}Intercepted`); + hook.intercept({ + call: (a, b, c) => { + result[`${method}InterceptedCall1`] = [a, b, c]; + }, + tap: tap => { + result[`${method}InterceptedTap1`] = Object.assign({}, tap, { + fn: tap.fn.length + }); + } + }); + hook.intercept({ + call: (a, b, c) => { + result[`${method}InterceptedCall2`] = [a, b, c]; + }, + tap: tap => { + if (!result[`${method}InterceptedTap2`]) + result[`${method}InterceptedTap2`] = Object.assign({}, tap, { + fn: tap.fn.length + }); + } + }); + hook.tap("sync1", (a, b, c) => a + b + c); + hook.tap("sync2", (a, b) => a + b + 1); + result[`${method}Intercepted`] = await this.gainResult(cb => + hook[method](1, 2, 3, cb) + ); + } + } + + async runAsync(result, type) { + { + const hook = this.createHook([], `${type}None`); + result[`${type}None`] = await this.gainResult(cb => hook[type](cb)); + } + + { + const hook = this.createHook(["arg"], `${type}NoneWithArg`); + result[`${type}NoneWithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook([], `${type}SingleSync`); + hook.tap("sync", () => { + result[`${type}SingleSyncCalled1`] = true; + return 42; + }); + result[`${type}SingleSync`] = await this.gainResult(cb => hook[type](cb)); + } + + { + const hook = this.createHook(["x"], `${type}SingleSyncWithArg`); + hook.tap("sync", arg => { + result[`${type}SingleSyncWithArgCalled1`] = arg; + return arg + 1; + }); + result[`${type}SingleSyncWithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}SingleSyncWithArgNoReturn`); + hook.tap("sync", arg => { + result[`${type}SingleSyncWithArgNoReturnCalled1`] = arg; + }); + result[`${type}SingleSyncWithArgNoReturn`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook([], `${type}MultipleSync`); + hook.tap("sync1", () => { + result[`${type}MultipleSyncCalled1`] = true; + return 42; + }); + hook.tap("sync2", () => { + result[`${type}MultipleSyncCalled2`] = true; + return 43; + }); + result[`${type}MultipleSync`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook([], `${type}MultipleSyncLastReturn`); + hook.tap("sync1", () => { + result[`${type}MultipleSyncLastReturnCalled1`] = true; + }); + hook.tap("sync2", () => { + result[`${type}MultipleSyncLastReturnCalled2`] = true; + return 43; + }); + result[`${type}MultipleSyncLastReturn`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook([], `${type}MultipleSyncNoReturn`); + hook.tap("sync1", () => { + result[`${type}MultipleSyncNoReturnCalled1`] = true; + }); + hook.tap("sync2", () => { + result[`${type}MultipleSyncNoReturnCalled2`] = true; + }); + result[`${type}MultipleSyncNoReturn`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook(["arg"], `${type}MultipleSyncWithArg`); + hook.tap("sync1", arg => { + result[`${type}MultipleSyncWithArgCalled1`] = arg; + return arg + 1; + }); + hook.tap("sync2", arg => { + result[`${type}MultipleSyncWithArgCalled2`] = arg; + return arg + 2; + }); + result[`${type}MultipleSyncWithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["arg"], + `${type}MultipleSyncWithArgNoReturn` + ); + hook.tap("sync1", arg => { + result[`${type}MultipleSyncWithArgNoReturnCalled1`] = arg; + }); + hook.tap("sync2", arg => { + result[`${type}MultipleSyncWithArgNoReturnCalled2`] = arg; + }); + result[`${type}MultipleSyncWithArgNoReturn`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["arg"], + `${type}MultipleSyncWithArgLastReturn` + ); + hook.tap("sync1", arg => { + result[`${type}MultipleSyncWithArgLastReturnCalled1`] = arg; + }); + hook.tap("sync2", arg => { + result[`${type}MultipleSyncWithArgLastReturnCalled2`] = arg; + return arg + 2; + }); + result[`${type}MultipleSyncWithArgLastReturn`] = await this.gainResult( + cb => hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["arg"], + `${type}MultipleSyncWithArgFirstReturn` + ); + hook.tap("sync1", arg => { + result[`${type}MultipleSyncWithArgFirstReturnCalled1`] = arg; + return arg + 1; + }); + hook.tap("sync2", arg => { + result[`${type}MultipleSyncWithArgFirstReturnCalled2`] = arg; + }); + result[`${type}MultipleSyncWithArgFirstReturn`] = await this.gainResult( + cb => hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}SingleAsyncWithArg`); + hook.tapAsync("async", (arg, callback) => { + result[`${type}SingleAsyncWithArgCalled1`] = arg; + callback(null, arg); + }); + result[`${type}SingleAsyncWithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultipleAsyncWithArg`); + hook.tapAsync("async1", (arg, callback) => { + result[`${type}MultipleAsyncWithArgCalled1`] = arg; + callback(null, arg + 1); + }); + hook.tapAsync("async2", (arg, callback) => { + result[`${type}MultipleAsyncWithArgCalled2`] = arg; + callback(null, arg + 2); + }); + result[`${type}MultipleAsyncWithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["x"], + `${type}MultipleAsyncWithArgNoReturn` + ); + hook.tapAsync("async1", (arg, callback) => { + result[`${type}MultipleAsyncWithArgNoReturnCalled1`] = arg; + callback(); + }); + hook.tapAsync("async2", (arg, callback) => { + result[`${type}MultipleAsyncWithArgNoReturnCalled2`] = arg; + callback(); + }); + result[`${type}MultipleAsyncWithArgNoReturn`] = await this.gainResult( + cb => hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["x"], + `${type}MultipleAsyncWithArgFirstReturn` + ); + hook.tapAsync("async1", (arg, callback) => { + result[`${type}MultipleAsyncWithArgFirstReturnCalled1`] = arg; + callback(null, arg + 1); + }); + hook.tapAsync("async2", (arg, callback) => { + result[`${type}MultipleAsyncWithArgFirstReturnCalled2`] = arg; + callback(); + }); + result[`${type}MultipleAsyncWithArgFirstReturn`] = await this.gainResult( + cb => hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["x"], + `${type}MultipleAsyncWithArgLastReturn` + ); + hook.tapAsync("async1", (arg, callback) => { + result[`${type}MultipleAsyncWithArgLastReturnCalled1`] = arg; + callback(); + }); + hook.tapAsync("async2", (arg, callback) => { + result[`${type}MultipleAsyncWithArgLastReturnCalled2`] = arg; + callback(null, arg + 2); + }); + result[`${type}MultipleAsyncWithArgLastReturn`] = await this.gainResult( + cb => hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}SinglePromiseWithArg`); + hook.tapPromise("promise", arg => { + result[`${type}SinglePromiseWithArgCalled1`] = arg; + return Promise.resolve(arg + 1); + }); + result[`${type}SinglePromiseWithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultiplePromiseWithArg`); + hook.tapPromise("promise1", arg => { + result[`${type}MultiplePromiseWithArgCalled1`] = arg; + return Promise.resolve(arg + 1); + }); + hook.tapPromise("promise2", arg => { + result[`${type}MultiplePromiseWithArgCalled2`] = arg; + return Promise.resolve(arg + 2); + }); + result[`${type}MultiplePromiseWithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["x"], + `${type}MultiplePromiseWithArgNoReturn` + ); + hook.tapPromise("promise1", arg => { + result[`${type}MultiplePromiseWithArgNoReturnCalled1`] = arg; + return Promise.resolve(); + }); + hook.tapPromise("promise2", arg => { + result[`${type}MultiplePromiseWithArgNoReturnCalled2`] = arg; + return Promise.resolve(); + }); + result[`${type}MultiplePromiseWithArgNoReturn`] = await this.gainResult( + cb => hook[type](42, cb) + ); + } + + { + const hook = this.createHook( + ["x"], + `${type}MultiplePromiseWithArgFirstReturn` + ); + hook.tapPromise("promise1", arg => { + result[`${type}MultiplePromiseWithArgFirstReturnCalled1`] = arg; + return Promise.resolve(arg + 1); + }); + hook.tapPromise("promise2", arg => { + result[`${type}MultiplePromiseWithArgFirstReturnCalled2`] = arg; + return Promise.resolve(); + }); + result[ + `${type}MultiplePromiseWithArgFirstReturn` + ] = await this.gainResult(cb => hook[type](42, cb)); + } + + { + const hook = this.createHook( + ["x"], + `${type}MultiplePromiseWithArgLastReturn` + ); + hook.tapPromise("promise1", arg => { + result[`${type}MultiplePromiseWithArgLastReturnCalled1`] = arg; + return Promise.resolve(); + }); + hook.tapPromise("promise2", arg => { + result[`${type}MultiplePromiseWithArgLastReturnCalled2`] = arg; + return Promise.resolve(arg + 2); + }); + result[`${type}MultiplePromiseWithArgLastReturn`] = await this.gainResult( + cb => hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultipleMixed1WithArg`); + hook.tapAsync("async", (arg, callback) => { + result[`${type}MultipleMixed1WithArgCalled1`] = arg; + callback(null, arg + 1); + }); + hook.tapPromise("promise", arg => { + result[`${type}MultipleMixed1WithArgCalled2`] = arg; + return Promise.resolve(arg + 2); + }); + hook.tap("sync", arg => { + result[`${type}MultipleMixed1WithArgCalled3`] = arg; + return arg + 3; + }); + result[`${type}MultipleMixed1WithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultipleMixed2WithArg`); + hook.tapAsync("async", (arg, callback) => { + result[`${type}MultipleMixed2WithArgCalled1`] = arg; + setTimeout(() => callback(null, arg + 1), 100); + }); + hook.tapPromise("promise", arg => { + result[`${type}MultipleMixed2WithArgCalled2`] = arg; + return Promise.resolve(arg + 2); + }); + result[`${type}MultipleMixed2WithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultipleMixed3WithArg`); + hook.tapAsync("async1", (arg, callback) => { + result[`${type}MultipleMixed3WithArgCalled1`] = arg; + callback(null, arg + 1); + }); + hook.tapPromise("promise", arg => { + result[`${type}MultipleMixed3WithArgCalled2`] = arg; + return Promise.resolve(arg + 2); + }); + hook.tapAsync("async2", (arg, callback) => { + result[`${type}MultipleMixed3WithArgCalled3`] = arg; + setTimeout(() => callback(null, arg + 3), 100); + }); + result[`${type}MultipleMixed3WithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook([], `${type}MultipleSyncError`); + hook.tap("sync1", () => { + result[`${type}MultipleSyncErrorCalled1`] = true; + }); + hook.tap("sync2", () => { + throw new Error("Error in sync2"); + }); + hook.tap("sync3", () => { + result[`${type}MultipleSyncErrorCalled3`] = true; + }); + result[`${type}MultipleSyncError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook([], `${type}MultipleAsyncError`); + hook.tapAsync("async1", callback => { + result[`${type}MultipleAsyncErrorCalled1`] = true; + callback(); + }); + hook.tapAsync("async2", callback => { + callback(new Error("Error in async2")); + }); + hook.tapAsync("async3", callback => { + result[`${type}MultipleAsyncErrorCalled3`] = true; + callback(); + }); + result[`${type}MultipleAsyncError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook([], `${type}MultipleAsyncLateError`); + hook.tapAsync("async1", callback => { + result[`${type}MultipleAsyncLateErrorCalled1`] = true; + callback(); + }); + hook.tapAsync("async2", callback => { + setTimeout(() => callback(new Error("Error in async2")), 100); + }); + hook.tapAsync("async3", callback => { + result[`${type}MultipleAsyncLateErrorCalled3`] = true; + callback(); + }); + result[`${type}MultipleAsyncLateError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook( + [], + `${type}MultipleAsyncLateErrorEarlyResult1` + ); + hook.tapAsync("async1", callback => { + result[`${type}MultipleAsyncLateErrorEarlyResult1Called1`] = true; + callback(); + }); + hook.tapAsync("async2", callback => { + setTimeout(() => callback(new Error("Error in async2")), 100); + }); + hook.tapAsync("async3", callback => { + result[`${type}MultipleAsyncLateErrorEarlyResult1Called3`] = true; + callback(null, 7); + }); + result[ + `${type}MultipleAsyncLateErrorEarlyResult1` + ] = await this.gainResult(cb => hook[type](cb)); + } + + { + const hook = this.createHook( + [], + `${type}MultipleAsyncLateErrorEarlyResult2` + ); + hook.tapAsync("async1", callback => { + result[`${type}MultipleAsyncLateErrorEarlyResult2Called1`] = true; + setTimeout(() => callback(null, 42), 200); + }); + hook.tapAsync("async2", callback => { + setTimeout(() => callback(new Error("Error in async2")), 100); + }); + hook.tapAsync("async3", callback => { + result[`${type}MultipleAsyncLateErrorEarlyResult2Called3`] = true; + callback(null, 7); + }); + result[ + `${type}MultipleAsyncLateErrorEarlyResult2` + ] = await this.gainResult(cb => hook[type](cb)); + } + + { + const hook = this.createHook([], `${type}MultipleAsyncEarlyError`); + hook.tapAsync("async1", callback => { + result[`${type}MultipleAsyncEarlyErrorCalled1`] = true; + setTimeout(() => callback(), 100); + }); + hook.tapAsync("async2", callback => { + callback(new Error("Error in async2")); + }); + hook.tapAsync("async3", callback => { + result[`${type}MultipleAsyncEarlyErrorCalled3`] = true; + setTimeout(() => callback(), 100); + }); + result[`${type}MultipleAsyncEarlyError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook([], `${type}MultiplePromiseError`); + hook.tapPromise("promise1", () => { + result[`${type}MultiplePromiseErrorCalled1`] = true; + return Promise.resolve(); + }); + hook.tapPromise("promise2", () => { + return Promise.resolve().then(() => { + throw new Error("Error in async2"); + }); + }); + hook.tapPromise("promise3", () => { + result[`${type}MultiplePromiseErrorCalled3`] = true; + return Promise.resolve(); + }); + result[`${type}MultiplePromiseError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook([], `${type}MultiplePromiseLateError`); + hook.tapPromise("promise1", () => { + result[`${type}MultiplePromiseLateErrorCalled1`] = true; + return Promise.resolve(); + }); + hook.tapPromise("promise2", () => { + return new Promise((resolve, reject) => { + setTimeout(() => reject(new Error("Error in async2")), 100); + }); + }); + hook.tapPromise("promise3", () => { + result[`${type}MultiplePromiseLateErrorCalled3`] = true; + return Promise.resolve(); + }); + result[`${type}MultiplePromiseLateError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook([], `${type}MultiplePromiseEarlyError`); + hook.tapPromise("promise1", () => { + result[`${type}MultiplePromiseEarlyErrorCalled1`] = true; + return new Promise(resolve => setTimeout(() => resolve(), 100)); + }); + hook.tapPromise("promise2", () => { + return Promise.resolve().then(() => { + throw new Error("Error in async2"); + }); + }); + hook.tapPromise("promise3", () => { + result[`${type}MultiplePromiseEarlyErrorCalled3`] = true; + return new Promise(resolve => setTimeout(() => resolve(), 100)); + }); + result[`${type}MultiplePromiseEarlyError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultipleMixedError1WithArg`); + hook.tapAsync("async", (arg, callback) => { + result[`${type}MultipleMixedError1WithArgCalled1`] = arg; + callback(null, arg); + }); + hook.tapPromise("promise", arg => { + result[`${type}MultipleMixedError1WithArgCalled2`] = arg; + return Promise.resolve(arg + 1); + }); + hook.tap("sync", arg => { + result[`${type}MultipleMixedError1WithArgCalled3`] = arg; + throw new Error("Error in sync"); + }); + result[`${type}MultipleMixedError1WithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultipleMixedError2WithArg`); + hook.tapAsync("async", (arg, callback) => { + result[`${type}MultipleMixedError2WithArgCalled1`] = arg; + callback(null, arg); + }); + hook.tapPromise("promise", arg => { + result[`${type}MultipleMixedError2WithArgCalled2`] = arg; + return Promise.resolve().then(() => { + throw new Error("Error in promise"); + }); + }); + hook.tap("sync", arg => { + result[`${type}MultipleMixedError2WithArgCalled3`] = arg; + return arg + 2; + }); + result[`${type}MultipleMixedError2WithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook(["x"], `${type}MultipleMixedError3WithArg`); + hook.tapAsync("async", (arg, callback) => { + result[`${type}MultipleMixedError3WithArgCalled1`] = arg; + callback(new Error("Error in async")); + }); + hook.tapPromise("promise", arg => { + result[`${type}MultipleMixedError3WithArgCalled2`] = arg; + return Promise.resolve(arg + 1); + }); + hook.tap("sync", arg => { + result[`${type}MultipleMixedError3WithArgCalled3`] = arg; + return arg + 2; + }); + result[`${type}MultipleMixedError3WithArg`] = await this.gainResult(cb => + hook[type](42, cb) + ); + } + + { + const hook = this.createHook([], `${type}MultipleMixedLateError`); + hook.tapAsync("async", callback => { + result[`${type}MultipleMixedLateErrorCalled1`] = true; + setTimeout(() => callback(new Error("Error in async")), 100); + }); + hook.tapPromise("promise", () => { + result[`${type}MultipleMixedLateErrorCalled2`] = true; + return Promise.resolve(42); + }); + hook.tap("sync", () => { + result[`${type}MultipleMixedLateErrorCalled3`] = true; + return 43; + }); + result[`${type}MultipleMixedLateError`] = await this.gainResult(cb => + hook[type](cb) + ); + } + } + + async runIntercept(result, type) { + { + const hook = this.createHook(["a", "b", "c"], `${type}Intercepted`); + hook.intercept({ + call: (a, b, c) => { + result[`${type}InterceptedCall1`] = [a, b, c]; + }, + tap: tap => { + result[`${type}InterceptedTap1`] = Object.assign({}, tap, { + fn: tap.fn.length + }); + } + }); + hook.intercept({ + call: (a, b, c) => { + result[`${type}InterceptedCall2`] = [a, b, c]; + }, + tap: tap => { + if (!result[`${type}InterceptedTap2`]) + result[`${type}InterceptedTap2`] = Object.assign({}, tap, { + fn: tap.fn.length + }); + } + }); + hook.tap("sync", (a, b, c) => a + b + c); + hook.tapPromise("promise", (a, b) => Promise.resolve(a + b + 1)); + result[`${type}Intercepted`] = await this.gainResult(cb => + hook[type](1, 2, 3, cb) + ); + } + + { + const hook = this.createHook( + ["a", "b", "c"], + `${type}ContextIntercepted` + ); + hook.intercept({ + call: (context, a, b, c) => { + context.number = 42; + result[`${type}ContextInterceptedCall1`] = [context, a, b, c]; + }, + loop: (context, a, b, c) => { + context.number2 = 88; + result[`${type}ContextInterceptedLoop1`] = [context, a, b, c]; + }, + tap: (context, tap) => { + result[`${type}ContextInterceptedTap1`] = context; + }, + context: true + }); + hook.intercept({ + call: (a, b, c) => { + result[`${type}ContextInterceptedCall2`] = [a, b, c]; + } + }); + hook.tap( + { + name: "sync", + context: true + }, + (context, a, b, c) => context.number + a + b + c + ); + result[`${type}ContextIntercepted`] = await this.gainResult(cb => + hook[type](1, 2, 3, cb) + ); + } + + { + const hook = this.createHook( + ["a", "b", "c"], + `${type}UnusedContextIntercepted` + ); + hook.intercept({ + call: (context, a, b, c) => { + result[`${type}UnusedContextInterceptedCall1`] = [context, a, b, c]; + }, + tap: (context, tap) => { + result[`${type}UnusedContextInterceptedTap1`] = context; + }, + context: true + }); + hook.intercept({ + call: (a, b, c) => { + result[`${type}UnusedContextInterceptedCall2`] = [a, b, c]; + } + }); + hook.tap("sync", (a, b, c) => a + b + c); + result[`${type}UnusedContextIntercepted`] = await this.gainResult(cb => + hook[type](1, 2, 3, cb) + ); + } + } + + gainResult(fn) { + return Promise.race([ + new Promise(resolve => { + try { + const ret = fn((err, result) => { + if (err) { + resolve({ + type: "async", + error: err.message + }); + } else { + resolve({ + type: "async", + value: result + }); + } + }); + if (ret instanceof Promise) { + resolve( + ret.then( + res => ({ + type: "promise", + value: res + }), + err => ({ + type: "promise", + error: err.message + }) + ) + ); + } else if (ret !== undefined) { + resolve({ + type: "return", + value: ret + }); + } + } catch (e) { + resolve({ + error: e.message + }); + } + }), + new Promise(resolve => { + setTimeout( + () => + resolve({ + type: "no result" + }), + 1000 + ); + }) + ]); + } + + createHook(args, name) { + try { + return this.hookCreator(args, name); + } catch (err) { + return { + tap: () => {}, + tapPromise: () => {}, + tapAsync: () => {}, + intercept: () => {}, + call: () => { + throw err; + }, + callAsync: () => { + throw err; + }, + promise: () => { + throw err; + } + }; + } + } +} + +module.exports = HookTester; diff --git a/node_modules/tapable/lib/__tests__/MultiHook.js b/node_modules/tapable/lib/__tests__/MultiHook.js new file mode 100644 index 00000000..e23f2e46 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/MultiHook.js @@ -0,0 +1,76 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +require("babel-polyfill"); + +const MultiHook = require("../MultiHook"); + +describe("MultiHook", () => { + const redirectedMethods = ["tap", "tapAsync", "tapPromise"]; + for (const name of redirectedMethods) { + it(`should redirect ${name}`, () => { + const calls = []; + const fakeHook = { + [name]: (options, fn) => { + calls.push({ options, fn }); + } + }; + new MultiHook([fakeHook, fakeHook])[name]("options", "fn"); + expect(calls).toEqual([ + { options: "options", fn: "fn" }, + { options: "options", fn: "fn" } + ]); + }); + } + it("should redirect intercept", () => { + const calls = []; + const fakeHook = { + intercept: interceptor => { + calls.push(interceptor); + } + }; + new MultiHook([fakeHook, fakeHook]).intercept("interceptor"); + expect(calls).toEqual(["interceptor", "interceptor"]); + }); + it("should redirect withOptions", () => { + const calls = []; + const fakeHook = { + withOptions: options => { + calls.push(options); + return { + tap: (options, fn) => { + calls.push({ options, fn }); + } + }; + } + }; + const newHook = new MultiHook([fakeHook, fakeHook]).withOptions("options"); + newHook.tap("options", "fn"); + expect(calls).toEqual([ + "options", + "options", + { options: "options", fn: "fn" }, + { options: "options", fn: "fn" } + ]); + }); + it("should redirect isUsed", () => { + const calls = []; + const fakeHook1 = { + isUsed: () => { + return true; + } + }; + const fakeHook2 = { + isUsed: () => { + return false; + } + }; + expect(new MultiHook([fakeHook1, fakeHook1]).isUsed()).toEqual(true); + expect(new MultiHook([fakeHook1, fakeHook2]).isUsed()).toEqual(true); + expect(new MultiHook([fakeHook2, fakeHook1]).isUsed()).toEqual(true); + expect(new MultiHook([fakeHook2, fakeHook2]).isUsed()).toEqual(false); + }); +}); diff --git a/node_modules/tapable/lib/__tests__/SyncBailHook.js b/node_modules/tapable/lib/__tests__/SyncBailHook.js new file mode 100644 index 00000000..420b0102 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/SyncBailHook.js @@ -0,0 +1,73 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +require("babel-polyfill"); + +const SyncBailHook = require("../SyncBailHook"); + +describe("SyncBailHook", () => { + it("should allow to create sync bail hooks", async () => { + const h1 = new SyncBailHook(["a"]); + const h2 = new SyncBailHook(["a", "b"]); + const h3 = new SyncBailHook(["a"]); + + let r = h1.call(1); + expect(r).toEqual(undefined); + + h1.tap("A", a => undefined); + h2.tap("A", (a, b) => [a, b]); + + expect(h1.call(1)).toEqual(undefined); + expect(await h1.promise(1)).toEqual(undefined); + expect(await pify(cb => h1.callAsync(1, cb))).toEqual(undefined); + expect(h2.call(1, 2)).toEqual([1, 2]); + expect(await h2.promise(1, 2)).toEqual([1, 2]); + expect(await pify(cb => h2.callAsync(1, 2, cb))).toEqual([1, 2]); + + h1.tap("B", a => "ok" + a); + h2.tap("B", (a, b) => "wrong"); + + expect(h1.call(10)).toEqual("ok10"); + expect(await h1.promise(10)).toEqual("ok10"); + expect(await pify(cb => h1.callAsync(10, cb))).toEqual("ok10"); + expect(h2.call(10, 20)).toEqual([10, 20]); + expect(await h2.promise(10, 20)).toEqual([10, 20]); + expect(await pify(cb => h2.callAsync(10, 20, cb))).toEqual([10, 20]); + }); + + it("should allow to intercept calls", () => { + const hook = new SyncBailHook(["x"]); + + const mockCall = jest.fn(); + const mockTap = jest.fn(x => x); + + hook.intercept({ + call: mockCall, + tap: mockTap + }); + + hook.call(5); + + expect(mockCall).toHaveBeenLastCalledWith(5); + expect(mockTap).not.toHaveBeenCalled(); + + hook.tap("test", () => 10); + + hook.call(7); + + expect(mockCall).toHaveBeenLastCalledWith(7); + expect(mockTap).toHaveBeenCalled(); + }); +}); + +function pify(fn) { + return new Promise((resolve, reject) => { + fn((err, result) => { + if (err) reject(err); + else resolve(result); + }); + }); +} diff --git a/node_modules/tapable/lib/__tests__/SyncHook.js b/node_modules/tapable/lib/__tests__/SyncHook.js new file mode 100644 index 00000000..99b2f2c8 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/SyncHook.js @@ -0,0 +1,104 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +require("babel-polyfill"); + +const SyncHook = require("../SyncHook"); + +describe("SyncHook", () => { + it("should allow to create sync hooks", async () => { + const h0 = new SyncHook(); + const h1 = new SyncHook(["test"]); + const h2 = new SyncHook(["test", "arg2"]); + const h3 = new SyncHook(["test", "arg2", "arg3"]); + + h0.call(); + await h0.promise(); + await new Promise(resolve => h0.callAsync(resolve)); + + const mock0 = jest.fn(); + h0.tap("A", mock0); + + h0.call(); + + expect(mock0).toHaveBeenLastCalledWith(); + + const mock1 = jest.fn(); + h0.tap("B", mock1); + + h0.call(); + + expect(mock1).toHaveBeenLastCalledWith(); + + const mock2 = jest.fn(); + const mock3 = jest.fn(); + const mock4 = jest.fn(); + const mock5 = jest.fn(); + + h1.tap("C", mock2); + h2.tap("D", mock3); + h3.tap("E", mock4); + h3.tap("F", mock5); + + h1.call("1"); + h2.call("1", 2); + h3.call("1", 2, 3); + + expect(mock2).toHaveBeenLastCalledWith("1"); + expect(mock3).toHaveBeenLastCalledWith("1", 2); + expect(mock4).toHaveBeenLastCalledWith("1", 2, 3); + expect(mock5).toHaveBeenLastCalledWith("1", 2, 3); + + await new Promise(resolve => h1.callAsync("a", resolve)); + await h2.promise("a", "b"); + await new Promise(resolve => h3.callAsync("a", "b", "c", resolve)); + + expect(mock2).toHaveBeenLastCalledWith("a"); + expect(mock3).toHaveBeenLastCalledWith("a", "b"); + expect(mock4).toHaveBeenLastCalledWith("a", "b", "c"); + expect(mock5).toHaveBeenLastCalledWith("a", "b", "c"); + + await h3.promise("x", "y"); + + expect(mock4).toHaveBeenLastCalledWith("x", "y", undefined); + expect(mock5).toHaveBeenLastCalledWith("x", "y", undefined); + }); + + it("should allow to intercept calls", () => { + const hook = new SyncHook(["arg1", "arg2"]); + + const mockCall = jest.fn(); + const mock0 = jest.fn(); + const mockRegister = jest.fn(x => ({ + name: "huh", + type: "sync", + fn: mock0 + })); + + const mock1 = jest.fn(); + hook.tap("Test1", mock1); + + hook.intercept({ + call: mockCall, + register: mockRegister + }); + + const mock2 = jest.fn(); + hook.tap("Test2", mock2); + + hook.call(1, 2); + + expect(mockCall).toHaveBeenLastCalledWith(1, 2); + expect(mockRegister).toHaveBeenLastCalledWith({ + type: "sync", + name: "Test2", + fn: mock2 + }); + expect(mock1).not.toHaveBeenLastCalledWith(1, 2); + expect(mock2).not.toHaveBeenLastCalledWith(1, 2); + expect(mock0).toHaveBeenLastCalledWith(1, 2); + }); +}); diff --git a/node_modules/tapable/lib/__tests__/SyncHooks.js b/node_modules/tapable/lib/__tests__/SyncHooks.js new file mode 100644 index 00000000..a5d04b4e --- /dev/null +++ b/node_modules/tapable/lib/__tests__/SyncHooks.js @@ -0,0 +1,67 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const HookTester = require("./HookTester"); +const SyncHook = require("../SyncHook"); +const SyncBailHook = require("../SyncBailHook"); +const SyncWaterfallHook = require("../SyncWaterfallHook"); +const SyncLoopHook = require("../SyncLoopHook"); + +describe("SyncHook", () => { + it( + "should have to correct behavior", + async () => { + const tester = new HookTester(args => new SyncHook(args)); + + const result = await tester.run(true); + + expect(result).toMatchSnapshot(); + }, + 15000 + ); +}); + +describe("SyncBailHook", () => { + it( + "should have to correct behavior", + async () => { + const tester = new HookTester(args => new SyncBailHook(args)); + + const result = await tester.run(true); + + expect(result).toMatchSnapshot(); + }, + 15000 + ); +}); + +describe("SyncWaterfallHook", () => { + it( + "should have to correct behavior", + async () => { + const tester = new HookTester(args => new SyncWaterfallHook(args)); + + const result = await tester.run(true); + + expect(result).toMatchSnapshot(); + }, + 15000 + ); +}); + +describe("SyncLoopHook", () => { + it( + "should have to correct behavior", + async () => { + const tester = new HookTester(args => new SyncLoopHook(args)); + + const result = await tester.runForLoop(true); + + expect(result).toMatchSnapshot(); + }, + 15000 + ); +}); diff --git a/node_modules/tapable/lib/__tests__/Tapable.js b/node_modules/tapable/lib/__tests__/Tapable.js new file mode 100644 index 00000000..65f61f9a --- /dev/null +++ b/node_modules/tapable/lib/__tests__/Tapable.js @@ -0,0 +1,63 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Tapable = require("../Tapable"); +const SyncHook = require("../SyncHook"); +const HookMap = require("../HookMap"); + +describe("Tapable", () => { + it("should use same name or camelCase hook by default", () => { + const t = new Tapable(); + t.hooks = { + myHook: new SyncHook() + }; + let called = 0; + t.plugin("my-hook", () => called++); + t.hooks.myHook.call(); + t.plugin("myHook", () => (called += 10)); + t.hooks.myHook.call(); + expect(called).toEqual(12); + }); + + it("should throw on unknown hook", () => { + const t = new Tapable(); + t.hooks = { + myHook: new SyncHook() + }; + expect(() => { + t.plugin("some-hook", () => {}); + }).toThrow(/some-hook/); + t.hooks.myHook.call(); + }); + + it("should use custom mapping", () => { + const t = new Tapable(); + t.hooks = { + myHook: new SyncHook(), + hookMap: new HookMap(name => new SyncHook()) + }; + let called = 0; + t._pluginCompat.tap("hookMap custom mapping", options => { + const match = /^hookMap (.+)$/.exec(options.name); + if (match) { + t.hooks.hookMap.tap( + match[1], + options.fn.name || "unnamed compat plugin", + options.fn + ); + return true; + } + }); + t.plugin("my-hook", () => called++); + t.plugin("hookMap test", () => (called += 10)); + t.hooks.myHook.call(); + expect(called).toEqual(1); + t.hooks.hookMap.for("test").call(); + expect(called).toEqual(11); + t.hooks.hookMap.for("other").call(); + expect(called).toEqual(11); + }); +}); diff --git a/node_modules/tapable/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap b/node_modules/tapable/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap new file mode 100644 index 00000000..94a88b19 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap @@ -0,0 +1,1469 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AsyncParallelBailHook should have to correct behavior 1`] = ` +Object { + "async": Object { + "callAsyncMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncEarlyErrorCalled1": true, + "callAsyncMultipleAsyncError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncErrorCalled1": true, + "callAsyncMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorCalled1": true, + "callAsyncMultipleAsyncLateErrorCalled3": true, + "callAsyncMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult1Called1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult1Called3": true, + "callAsyncMultipleAsyncLateErrorEarlyResult2": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleAsyncLateErrorEarlyResult2Called1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult2Called3": true, + "callAsyncMultipleAsyncWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleAsyncWithArgCalled1": 42, + "callAsyncMultipleAsyncWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleAsyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultipleAsyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleAsyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleMixed1WithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleMixed1WithArgCalled1": 42, + "callAsyncMultipleMixed2WithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleMixed2WithArgCalled1": 42, + "callAsyncMultipleMixed2WithArgCalled2": 42, + "callAsyncMultipleMixed3WithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleMixed3WithArgCalled1": 42, + "callAsyncMultipleMixedError1WithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleMixedError1WithArgCalled1": 42, + "callAsyncMultipleMixedError2WithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleMixedError2WithArgCalled1": 42, + "callAsyncMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedError3WithArgCalled1": 42, + "callAsyncMultipleMixedLateError": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedLateErrorCalled1": true, + "callAsyncMultipleMixedLateErrorCalled2": true, + "callAsyncMultipleMixedLateErrorCalled3": true, + "callAsyncMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseEarlyErrorCalled1": true, + "callAsyncMultiplePromiseEarlyErrorCalled3": true, + "callAsyncMultiplePromiseError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseErrorCalled1": true, + "callAsyncMultiplePromiseErrorCalled3": true, + "callAsyncMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseLateErrorCalled1": true, + "callAsyncMultiplePromiseLateErrorCalled3": true, + "callAsyncMultiplePromiseWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultiplePromiseWithArgCalled1": 42, + "callAsyncMultiplePromiseWithArgCalled2": 42, + "callAsyncMultiplePromiseWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultiplePromiseWithArgFirstReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgFirstReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultiplePromiseWithArgLastReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgLastReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgNoReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgNoReturnCalled2": 42, + "callAsyncMultipleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncLastReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleSyncLastReturnCalled1": true, + "callAsyncMultipleSyncLastReturnCalled2": true, + "callAsyncMultipleSyncNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncNoReturnCalled1": true, + "callAsyncMultipleSyncNoReturnCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleAsyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleAsyncWithArgCalled1": 42, + "callAsyncSinglePromiseWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncSinglePromiseWithArgCalled1": 42, + "callAsyncSingleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncCalled1": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncSingleSyncWithArgCalled1": 42, + "callAsyncSingleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncEarlyErrorCalled1": true, + "promiseMultipleAsyncError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncErrorCalled1": true, + "promiseMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorCalled1": true, + "promiseMultipleAsyncLateErrorCalled3": true, + "promiseMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorEarlyResult1Called1": true, + "promiseMultipleAsyncLateErrorEarlyResult1Called3": true, + "promiseMultipleAsyncLateErrorEarlyResult2": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleAsyncLateErrorEarlyResult2Called1": true, + "promiseMultipleAsyncLateErrorEarlyResult2Called3": true, + "promiseMultipleAsyncWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleAsyncWithArgCalled1": 42, + "promiseMultipleAsyncWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleAsyncWithArgFirstReturnCalled1": 42, + "promiseMultipleAsyncWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultipleAsyncWithArgLastReturnCalled1": 42, + "promiseMultipleAsyncWithArgLastReturnCalled2": 42, + "promiseMultipleAsyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncWithArgNoReturnCalled2": 42, + "promiseMultipleMixed1WithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleMixed1WithArgCalled1": 42, + "promiseMultipleMixed2WithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleMixed2WithArgCalled1": 42, + "promiseMultipleMixed2WithArgCalled2": 42, + "promiseMultipleMixed3WithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleMixed3WithArgCalled1": 42, + "promiseMultipleMixedError1WithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleMixedError1WithArgCalled1": 42, + "promiseMultipleMixedError2WithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleMixedError2WithArgCalled1": 42, + "promiseMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedError3WithArgCalled1": 42, + "promiseMultipleMixedLateError": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedLateErrorCalled1": true, + "promiseMultipleMixedLateErrorCalled2": true, + "promiseMultipleMixedLateErrorCalled3": true, + "promiseMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseEarlyErrorCalled1": true, + "promiseMultiplePromiseEarlyErrorCalled3": true, + "promiseMultiplePromiseError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseErrorCalled1": true, + "promiseMultiplePromiseErrorCalled3": true, + "promiseMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseLateErrorCalled1": true, + "promiseMultiplePromiseLateErrorCalled3": true, + "promiseMultiplePromiseWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultiplePromiseWithArgCalled1": 42, + "promiseMultiplePromiseWithArgCalled2": 42, + "promiseMultiplePromiseWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultiplePromiseWithArgFirstReturnCalled1": 42, + "promiseMultiplePromiseWithArgFirstReturnCalled2": 42, + "promiseMultiplePromiseWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultiplePromiseWithArgLastReturnCalled1": 42, + "promiseMultiplePromiseWithArgLastReturnCalled2": 42, + "promiseMultiplePromiseWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgNoReturnCalled1": 42, + "promiseMultiplePromiseWithArgNoReturnCalled2": 42, + "promiseMultipleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncLastReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleSyncLastReturnCalled1": true, + "promiseMultipleSyncLastReturnCalled2": true, + "promiseMultipleSyncNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncNoReturnCalled1": true, + "promiseMultipleSyncNoReturnCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleAsyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleAsyncWithArgCalled1": 42, + "promiseSinglePromiseWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseSinglePromiseWithArgCalled1": 42, + "promiseSingleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncCalled1": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseSingleSyncWithArgCalled1": 42, + "promiseSingleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgNoReturnCalled1": 42, + }, + "intercept": Object { + "callAsyncContextIntercepted": Object { + "type": "async", + "value": 48, + }, + "callAsyncContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "callAsyncContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncContextInterceptedTap1": Object { + "number": 42, + }, + "callAsyncIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "callAsyncUnusedContextIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedTap1": undefined, + "promiseContextIntercepted": Object { + "type": "promise", + "value": 48, + }, + "promiseContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "promiseContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseContextInterceptedTap1": Object { + "number": 42, + }, + "promiseIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "promiseUnusedContextIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedTap1": undefined, + }, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncErrorCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 85, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": 129, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncCalled": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncErrorCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 85, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": 129, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncCalled": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; + +exports[`AsyncParallelHook should have to correct behavior 1`] = ` +Object { + "async": Object { + "callAsyncMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncEarlyErrorCalled1": true, + "callAsyncMultipleAsyncError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncErrorCalled1": true, + "callAsyncMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorCalled1": true, + "callAsyncMultipleAsyncLateErrorCalled3": true, + "callAsyncMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult1Called1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult1Called3": true, + "callAsyncMultipleAsyncLateErrorEarlyResult2": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult2Called1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult2Called3": true, + "callAsyncMultipleAsyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgCalled1": 42, + "callAsyncMultipleAsyncWithArgCalled2": 42, + "callAsyncMultipleAsyncWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgFirstReturnCalled2": 42, + "callAsyncMultipleAsyncWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleAsyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleMixed1WithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleMixed1WithArgCalled1": 42, + "callAsyncMultipleMixed1WithArgCalled2": 42, + "callAsyncMultipleMixed1WithArgCalled3": 42, + "callAsyncMultipleMixed2WithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleMixed2WithArgCalled1": 42, + "callAsyncMultipleMixed2WithArgCalled2": 42, + "callAsyncMultipleMixed3WithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleMixed3WithArgCalled1": 42, + "callAsyncMultipleMixed3WithArgCalled2": 42, + "callAsyncMultipleMixed3WithArgCalled3": 42, + "callAsyncMultipleMixedError1WithArg": Object { + "error": "Error in sync", + "type": "async", + }, + "callAsyncMultipleMixedError1WithArgCalled1": 42, + "callAsyncMultipleMixedError1WithArgCalled2": 42, + "callAsyncMultipleMixedError1WithArgCalled3": 42, + "callAsyncMultipleMixedError2WithArg": Object { + "error": "Error in promise", + "type": "async", + }, + "callAsyncMultipleMixedError2WithArgCalled1": 42, + "callAsyncMultipleMixedError2WithArgCalled2": 42, + "callAsyncMultipleMixedError2WithArgCalled3": 42, + "callAsyncMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedError3WithArgCalled1": 42, + "callAsyncMultipleMixedLateError": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedLateErrorCalled1": true, + "callAsyncMultipleMixedLateErrorCalled2": true, + "callAsyncMultipleMixedLateErrorCalled3": true, + "callAsyncMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseEarlyErrorCalled1": true, + "callAsyncMultiplePromiseEarlyErrorCalled3": true, + "callAsyncMultiplePromiseError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseErrorCalled1": true, + "callAsyncMultiplePromiseErrorCalled3": true, + "callAsyncMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseLateErrorCalled1": true, + "callAsyncMultiplePromiseLateErrorCalled3": true, + "callAsyncMultiplePromiseWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgCalled1": 42, + "callAsyncMultiplePromiseWithArgCalled2": 42, + "callAsyncMultiplePromiseWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgFirstReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgFirstReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgLastReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgLastReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgNoReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgNoReturnCalled2": 42, + "callAsyncMultipleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncCalled2": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncLastReturnCalled1": true, + "callAsyncMultipleSyncLastReturnCalled2": true, + "callAsyncMultipleSyncNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncNoReturnCalled1": true, + "callAsyncMultipleSyncNoReturnCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleAsyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleAsyncWithArgCalled1": 42, + "callAsyncSinglePromiseWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSinglePromiseWithArgCalled1": 42, + "callAsyncSingleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncCalled1": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgCalled1": 42, + "callAsyncSingleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncEarlyErrorCalled1": true, + "promiseMultipleAsyncError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncErrorCalled1": true, + "promiseMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorCalled1": true, + "promiseMultipleAsyncLateErrorCalled3": true, + "promiseMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorEarlyResult1Called1": true, + "promiseMultipleAsyncLateErrorEarlyResult1Called3": true, + "promiseMultipleAsyncLateErrorEarlyResult2": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorEarlyResult2Called1": true, + "promiseMultipleAsyncLateErrorEarlyResult2Called3": true, + "promiseMultipleAsyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgCalled1": 42, + "promiseMultipleAsyncWithArgCalled2": 42, + "promiseMultipleAsyncWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgFirstReturnCalled1": 42, + "promiseMultipleAsyncWithArgFirstReturnCalled2": 42, + "promiseMultipleAsyncWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgLastReturnCalled1": 42, + "promiseMultipleAsyncWithArgLastReturnCalled2": 42, + "promiseMultipleAsyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncWithArgNoReturnCalled2": 42, + "promiseMultipleMixed1WithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleMixed1WithArgCalled1": 42, + "promiseMultipleMixed1WithArgCalled2": 42, + "promiseMultipleMixed1WithArgCalled3": 42, + "promiseMultipleMixed2WithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleMixed2WithArgCalled1": 42, + "promiseMultipleMixed2WithArgCalled2": 42, + "promiseMultipleMixed3WithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleMixed3WithArgCalled1": 42, + "promiseMultipleMixed3WithArgCalled2": 42, + "promiseMultipleMixed3WithArgCalled3": 42, + "promiseMultipleMixedError1WithArg": Object { + "error": "Error in sync", + "type": "promise", + }, + "promiseMultipleMixedError1WithArgCalled1": 42, + "promiseMultipleMixedError1WithArgCalled2": 42, + "promiseMultipleMixedError1WithArgCalled3": 42, + "promiseMultipleMixedError2WithArg": Object { + "error": "Error in promise", + "type": "promise", + }, + "promiseMultipleMixedError2WithArgCalled1": 42, + "promiseMultipleMixedError2WithArgCalled2": 42, + "promiseMultipleMixedError2WithArgCalled3": 42, + "promiseMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedError3WithArgCalled1": 42, + "promiseMultipleMixedLateError": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedLateErrorCalled1": true, + "promiseMultipleMixedLateErrorCalled2": true, + "promiseMultipleMixedLateErrorCalled3": true, + "promiseMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseEarlyErrorCalled1": true, + "promiseMultiplePromiseEarlyErrorCalled3": true, + "promiseMultiplePromiseError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseErrorCalled1": true, + "promiseMultiplePromiseErrorCalled3": true, + "promiseMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseLateErrorCalled1": true, + "promiseMultiplePromiseLateErrorCalled3": true, + "promiseMultiplePromiseWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgCalled1": 42, + "promiseMultiplePromiseWithArgCalled2": 42, + "promiseMultiplePromiseWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgFirstReturnCalled1": 42, + "promiseMultiplePromiseWithArgFirstReturnCalled2": 42, + "promiseMultiplePromiseWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgLastReturnCalled1": 42, + "promiseMultiplePromiseWithArgLastReturnCalled2": 42, + "promiseMultiplePromiseWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgNoReturnCalled1": 42, + "promiseMultiplePromiseWithArgNoReturnCalled2": 42, + "promiseMultipleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncCalled2": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncLastReturnCalled1": true, + "promiseMultipleSyncLastReturnCalled2": true, + "promiseMultipleSyncNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncNoReturnCalled1": true, + "promiseMultipleSyncNoReturnCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleAsyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleAsyncWithArgCalled1": 42, + "promiseSinglePromiseWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSinglePromiseWithArgCalled1": 42, + "promiseSingleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncCalled1": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgCalled1": 42, + "promiseSingleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgNoReturnCalled1": 42, + }, + "intercept": Object { + "callAsyncContextIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "callAsyncContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncContextInterceptedTap1": Object { + "number": 42, + }, + "callAsyncIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "promise", + "type": "promise", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "callAsyncUnusedContextIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedTap1": undefined, + "promiseContextIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "promiseContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseContextInterceptedTap1": Object { + "number": 42, + }, + "promiseIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "promise", + "type": "promise", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "promiseUnusedContextIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedTap1": undefined, + }, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncCalled2": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncErrorCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncMultipleSyncWithArgsCalled2": Array [ + 42, + 43, + 44, + ], + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncCalled": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncCalled2": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncErrorCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseMultipleSyncWithArgsCalled2": Array [ + 42, + 43, + 44, + ], + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncCalled": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; diff --git a/node_modules/tapable/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap b/node_modules/tapable/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap new file mode 100644 index 00000000..5004020e --- /dev/null +++ b/node_modules/tapable/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap @@ -0,0 +1,2214 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AsyncSeriesBailHook should have to correct behavior 1`] = ` +Object { + "async": Object { + "callAsyncMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncEarlyErrorCalled1": true, + "callAsyncMultipleAsyncError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncErrorCalled1": true, + "callAsyncMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorCalled1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult1Called1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult2": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleAsyncLateErrorEarlyResult2Called1": true, + "callAsyncMultipleAsyncWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleAsyncWithArgCalled1": 42, + "callAsyncMultipleAsyncWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleAsyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultipleAsyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleAsyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleMixed1WithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleMixed1WithArgCalled1": 42, + "callAsyncMultipleMixed2WithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleMixed2WithArgCalled1": 42, + "callAsyncMultipleMixed3WithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleMixed3WithArgCalled1": 42, + "callAsyncMultipleMixedError1WithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleMixedError1WithArgCalled1": 42, + "callAsyncMultipleMixedError2WithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleMixedError2WithArgCalled1": 42, + "callAsyncMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedError3WithArgCalled1": 42, + "callAsyncMultipleMixedLateError": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedLateErrorCalled1": true, + "callAsyncMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseEarlyErrorCalled1": true, + "callAsyncMultiplePromiseError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseErrorCalled1": true, + "callAsyncMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseLateErrorCalled1": true, + "callAsyncMultiplePromiseWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultiplePromiseWithArgCalled1": 42, + "callAsyncMultiplePromiseWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultiplePromiseWithArgFirstReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultiplePromiseWithArgLastReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgLastReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgNoReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgNoReturnCalled2": 42, + "callAsyncMultipleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncLastReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleSyncLastReturnCalled1": true, + "callAsyncMultipleSyncLastReturnCalled2": true, + "callAsyncMultipleSyncNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncNoReturnCalled1": true, + "callAsyncMultipleSyncNoReturnCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleAsyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleAsyncWithArgCalled1": 42, + "callAsyncSinglePromiseWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncSinglePromiseWithArgCalled1": 42, + "callAsyncSingleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncCalled1": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncSingleSyncWithArgCalled1": 42, + "callAsyncSingleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncEarlyErrorCalled1": true, + "promiseMultipleAsyncError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncErrorCalled1": true, + "promiseMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorCalled1": true, + "promiseMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorEarlyResult1Called1": true, + "promiseMultipleAsyncLateErrorEarlyResult2": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleAsyncLateErrorEarlyResult2Called1": true, + "promiseMultipleAsyncWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleAsyncWithArgCalled1": 42, + "promiseMultipleAsyncWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleAsyncWithArgFirstReturnCalled1": 42, + "promiseMultipleAsyncWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultipleAsyncWithArgLastReturnCalled1": 42, + "promiseMultipleAsyncWithArgLastReturnCalled2": 42, + "promiseMultipleAsyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncWithArgNoReturnCalled2": 42, + "promiseMultipleMixed1WithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleMixed1WithArgCalled1": 42, + "promiseMultipleMixed2WithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleMixed2WithArgCalled1": 42, + "promiseMultipleMixed3WithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleMixed3WithArgCalled1": 42, + "promiseMultipleMixedError1WithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleMixedError1WithArgCalled1": 42, + "promiseMultipleMixedError2WithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleMixedError2WithArgCalled1": 42, + "promiseMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedError3WithArgCalled1": 42, + "promiseMultipleMixedLateError": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedLateErrorCalled1": true, + "promiseMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseEarlyErrorCalled1": true, + "promiseMultiplePromiseError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseErrorCalled1": true, + "promiseMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseLateErrorCalled1": true, + "promiseMultiplePromiseWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultiplePromiseWithArgCalled1": 42, + "promiseMultiplePromiseWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultiplePromiseWithArgFirstReturnCalled1": 42, + "promiseMultiplePromiseWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultiplePromiseWithArgLastReturnCalled1": 42, + "promiseMultiplePromiseWithArgLastReturnCalled2": 42, + "promiseMultiplePromiseWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgNoReturnCalled1": 42, + "promiseMultiplePromiseWithArgNoReturnCalled2": 42, + "promiseMultipleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncLastReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleSyncLastReturnCalled1": true, + "promiseMultipleSyncLastReturnCalled2": true, + "promiseMultipleSyncNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncNoReturnCalled1": true, + "promiseMultipleSyncNoReturnCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleAsyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleAsyncWithArgCalled1": 42, + "promiseSinglePromiseWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseSinglePromiseWithArgCalled1": 42, + "promiseSingleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncCalled1": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseSingleSyncWithArgCalled1": 42, + "promiseSingleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgNoReturnCalled1": 42, + }, + "intercept": Object { + "callAsyncContextIntercepted": Object { + "type": "async", + "value": 48, + }, + "callAsyncContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "callAsyncContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncContextInterceptedTap1": Object { + "number": 42, + }, + "callAsyncIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "callAsyncUnusedContextIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedTap1": undefined, + "promiseContextIntercepted": Object { + "type": "promise", + "value": 48, + }, + "promiseContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "promiseContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseContextInterceptedTap1": Object { + "number": 42, + }, + "promiseIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "promiseUnusedContextIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedTap1": undefined, + }, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncErrorCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 85, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": 129, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncCalled": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncErrorCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 85, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": 129, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncCalled": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; + +exports[`AsyncSeriesHook should have to correct behavior 1`] = ` +Object { + "async": Object { + "callAsyncMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncEarlyErrorCalled1": true, + "callAsyncMultipleAsyncError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncErrorCalled1": true, + "callAsyncMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorCalled1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult1Called1": true, + "callAsyncMultipleAsyncLateErrorEarlyResult2": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult2Called1": true, + "callAsyncMultipleAsyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgCalled1": 42, + "callAsyncMultipleAsyncWithArgCalled2": 42, + "callAsyncMultipleAsyncWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgFirstReturnCalled2": 42, + "callAsyncMultipleAsyncWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleAsyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleMixed1WithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleMixed1WithArgCalled1": 42, + "callAsyncMultipleMixed1WithArgCalled2": 42, + "callAsyncMultipleMixed1WithArgCalled3": 42, + "callAsyncMultipleMixed2WithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleMixed2WithArgCalled1": 42, + "callAsyncMultipleMixed2WithArgCalled2": 42, + "callAsyncMultipleMixed3WithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleMixed3WithArgCalled1": 42, + "callAsyncMultipleMixed3WithArgCalled2": 42, + "callAsyncMultipleMixed3WithArgCalled3": 42, + "callAsyncMultipleMixedError1WithArg": Object { + "error": "Error in sync", + "type": "async", + }, + "callAsyncMultipleMixedError1WithArgCalled1": 42, + "callAsyncMultipleMixedError1WithArgCalled2": 42, + "callAsyncMultipleMixedError1WithArgCalled3": 42, + "callAsyncMultipleMixedError2WithArg": Object { + "error": "Error in promise", + "type": "async", + }, + "callAsyncMultipleMixedError2WithArgCalled1": 42, + "callAsyncMultipleMixedError2WithArgCalled2": 42, + "callAsyncMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedError3WithArgCalled1": 42, + "callAsyncMultipleMixedLateError": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedLateErrorCalled1": true, + "callAsyncMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseEarlyErrorCalled1": true, + "callAsyncMultiplePromiseError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseErrorCalled1": true, + "callAsyncMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "async", + }, + "callAsyncMultiplePromiseLateErrorCalled1": true, + "callAsyncMultiplePromiseWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgCalled1": 42, + "callAsyncMultiplePromiseWithArgCalled2": 42, + "callAsyncMultiplePromiseWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgFirstReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgFirstReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgLastReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgLastReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseWithArgNoReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgNoReturnCalled2": 42, + "callAsyncMultipleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncCalled2": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncLastReturnCalled1": true, + "callAsyncMultipleSyncLastReturnCalled2": true, + "callAsyncMultipleSyncNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncNoReturnCalled1": true, + "callAsyncMultipleSyncNoReturnCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleAsyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleAsyncWithArgCalled1": 42, + "callAsyncSinglePromiseWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSinglePromiseWithArgCalled1": 42, + "callAsyncSingleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncCalled1": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgCalled1": 42, + "callAsyncSingleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncEarlyErrorCalled1": true, + "promiseMultipleAsyncError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncErrorCalled1": true, + "promiseMultipleAsyncLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorCalled1": true, + "promiseMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorEarlyResult1Called1": true, + "promiseMultipleAsyncLateErrorEarlyResult2": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultipleAsyncLateErrorEarlyResult2Called1": true, + "promiseMultipleAsyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgCalled1": 42, + "promiseMultipleAsyncWithArgCalled2": 42, + "promiseMultipleAsyncWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgFirstReturnCalled1": 42, + "promiseMultipleAsyncWithArgFirstReturnCalled2": 42, + "promiseMultipleAsyncWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgLastReturnCalled1": 42, + "promiseMultipleAsyncWithArgLastReturnCalled2": 42, + "promiseMultipleAsyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncWithArgNoReturnCalled2": 42, + "promiseMultipleMixed1WithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleMixed1WithArgCalled1": 42, + "promiseMultipleMixed1WithArgCalled2": 42, + "promiseMultipleMixed1WithArgCalled3": 42, + "promiseMultipleMixed2WithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleMixed2WithArgCalled1": 42, + "promiseMultipleMixed2WithArgCalled2": 42, + "promiseMultipleMixed3WithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleMixed3WithArgCalled1": 42, + "promiseMultipleMixed3WithArgCalled2": 42, + "promiseMultipleMixed3WithArgCalled3": 42, + "promiseMultipleMixedError1WithArg": Object { + "error": "Error in sync", + "type": "promise", + }, + "promiseMultipleMixedError1WithArgCalled1": 42, + "promiseMultipleMixedError1WithArgCalled2": 42, + "promiseMultipleMixedError1WithArgCalled3": 42, + "promiseMultipleMixedError2WithArg": Object { + "error": "Error in promise", + "type": "promise", + }, + "promiseMultipleMixedError2WithArgCalled1": 42, + "promiseMultipleMixedError2WithArgCalled2": 42, + "promiseMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedError3WithArgCalled1": 42, + "promiseMultipleMixedLateError": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedLateErrorCalled1": true, + "promiseMultiplePromiseEarlyError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseEarlyErrorCalled1": true, + "promiseMultiplePromiseError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseErrorCalled1": true, + "promiseMultiplePromiseLateError": Object { + "error": "Error in async2", + "type": "promise", + }, + "promiseMultiplePromiseLateErrorCalled1": true, + "promiseMultiplePromiseWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgCalled1": 42, + "promiseMultiplePromiseWithArgCalled2": 42, + "promiseMultiplePromiseWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgFirstReturnCalled1": 42, + "promiseMultiplePromiseWithArgFirstReturnCalled2": 42, + "promiseMultiplePromiseWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgLastReturnCalled1": 42, + "promiseMultiplePromiseWithArgLastReturnCalled2": 42, + "promiseMultiplePromiseWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseWithArgNoReturnCalled1": 42, + "promiseMultiplePromiseWithArgNoReturnCalled2": 42, + "promiseMultipleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncCalled2": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncLastReturnCalled1": true, + "promiseMultipleSyncLastReturnCalled2": true, + "promiseMultipleSyncNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncNoReturnCalled1": true, + "promiseMultipleSyncNoReturnCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleAsyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleAsyncWithArgCalled1": 42, + "promiseSinglePromiseWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSinglePromiseWithArgCalled1": 42, + "promiseSingleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncCalled1": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgCalled1": 42, + "promiseSingleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgNoReturnCalled1": 42, + }, + "intercept": Object { + "callAsyncContextIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "callAsyncContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncContextInterceptedTap1": Object { + "number": 42, + }, + "callAsyncIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "promise", + "type": "promise", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "callAsyncUnusedContextIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedTap1": undefined, + "promiseContextIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "promiseContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseContextInterceptedTap1": Object { + "number": 42, + }, + "promiseIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "promise", + "type": "promise", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "promiseUnusedContextIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedTap1": undefined, + }, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncCalled2": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncErrorCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncMultipleSyncWithArgsCalled2": Array [ + 42, + 43, + 44, + ], + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncCalled": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncCalled2": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncErrorCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseMultipleSyncWithArgsCalled2": Array [ + 42, + 43, + 44, + ], + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncCalled": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; + +exports[`AsyncSeriesLoopHook should have to correct behavior 1`] = ` +Object { + "async": Object { + "callAsyncBrokenPromise": Object { + "error": "Tap function (tapPromise) did not return promise (returned this is not a promise)", + }, + "callAsyncMixed": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMixedCalled1": 124, + "callAsyncMixedCalled2": 83, + "callAsyncMixedCalled3": 42, + "callAsyncMultipleAsync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleAsyncCalled1": 83, + "callAsyncMultipleAsyncCalled2": 42, + "callAsyncMultiplePromise": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultiplePromiseCalled1": 83, + "callAsyncMultiplePromiseCalled2": 42, + "callAsyncSingleAsync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleAsyncCalled": 42, + "callAsyncSinglePromise": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSinglePromiseCalled": 42, + "promiseBrokenPromise": Object { + "error": "Tap function (tapPromise) did not return promise (returned this is not a promise)", + "type": "promise", + }, + "promiseMixed": Object { + "type": "promise", + "value": undefined, + }, + "promiseMixedCalled1": 124, + "promiseMixedCalled2": 83, + "promiseMixedCalled3": 42, + "promiseMultipleAsync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleAsyncCalled1": 83, + "promiseMultipleAsyncCalled2": 42, + "promiseMultiplePromise": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultiplePromiseCalled1": 83, + "promiseMultiplePromiseCalled2": 42, + "promiseSingleAsync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleAsyncCalled": 42, + "promiseSinglePromise": Object { + "type": "promise", + "value": undefined, + }, + "promiseSinglePromiseCalled": 42, + }, + "sync": Object { + "callAsyncInterceptedSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncInterceptedSyncCalled1": 83, + "callAsyncInterceptedSyncCalled2": 42, + "callAsyncInterceptedSyncCalledCall": 1, + "callAsyncInterceptedSyncCalledLoop": 83, + "callAsyncInterceptedSyncCalledTap": 125, + "callAsyncMultipleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncCalled1": 83, + "callAsyncMultipleSyncCalled2": 42, + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncCalled": 42, + "promiseInterceptedSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseInterceptedSyncCalled1": 83, + "promiseInterceptedSyncCalled2": 42, + "promiseInterceptedSyncCalledCall": 1, + "promiseInterceptedSyncCalledLoop": 83, + "promiseInterceptedSyncCalledTap": 125, + "promiseMultipleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncCalled1": 83, + "promiseMultipleSyncCalled2": 42, + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncCalled": 42, + }, +} +`; + +exports[`AsyncSeriesWaterfallHook should have to correct behavior 1`] = ` +Object { + "async": Object { + "callAsyncMultipleAsyncEarlyError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleAsyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleAsyncLateError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleAsyncLateErrorEarlyResult2": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleAsyncWithArg": Object { + "type": "async", + "value": 45, + }, + "callAsyncMultipleAsyncWithArgCalled1": 42, + "callAsyncMultipleAsyncWithArgCalled2": 43, + "callAsyncMultipleAsyncWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleAsyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgFirstReturnCalled2": 43, + "callAsyncMultipleAsyncWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultipleAsyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleAsyncWithArgNoReturn": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleAsyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleAsyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleMixed1WithArg": Object { + "type": "async", + "value": 48, + }, + "callAsyncMultipleMixed1WithArgCalled1": 42, + "callAsyncMultipleMixed1WithArgCalled2": 43, + "callAsyncMultipleMixed1WithArgCalled3": 45, + "callAsyncMultipleMixed2WithArg": Object { + "type": "async", + "value": 45, + }, + "callAsyncMultipleMixed2WithArgCalled1": 42, + "callAsyncMultipleMixed2WithArgCalled2": 43, + "callAsyncMultipleMixed3WithArg": Object { + "type": "async", + "value": 48, + }, + "callAsyncMultipleMixed3WithArgCalled1": 42, + "callAsyncMultipleMixed3WithArgCalled2": 43, + "callAsyncMultipleMixed3WithArgCalled3": 45, + "callAsyncMultipleMixedError1WithArg": Object { + "error": "Error in sync", + "type": "async", + }, + "callAsyncMultipleMixedError1WithArgCalled1": 42, + "callAsyncMultipleMixedError1WithArgCalled2": 42, + "callAsyncMultipleMixedError1WithArgCalled3": 43, + "callAsyncMultipleMixedError2WithArg": Object { + "error": "Error in promise", + "type": "async", + }, + "callAsyncMultipleMixedError2WithArgCalled1": 42, + "callAsyncMultipleMixedError2WithArgCalled2": 42, + "callAsyncMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "async", + }, + "callAsyncMultipleMixedError3WithArgCalled1": 42, + "callAsyncMultipleMixedLateError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultiplePromiseEarlyError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultiplePromiseError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultiplePromiseLateError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultiplePromiseWithArg": Object { + "type": "async", + "value": 45, + }, + "callAsyncMultiplePromiseWithArgCalled1": 42, + "callAsyncMultiplePromiseWithArgCalled2": 43, + "callAsyncMultiplePromiseWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultiplePromiseWithArgFirstReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgFirstReturnCalled2": 43, + "callAsyncMultiplePromiseWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultiplePromiseWithArgLastReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgLastReturnCalled2": 42, + "callAsyncMultiplePromiseWithArgNoReturn": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultiplePromiseWithArgNoReturnCalled1": 42, + "callAsyncMultiplePromiseWithArgNoReturnCalled2": 42, + "callAsyncMultipleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncLastReturn": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncNoReturn": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 45, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 43, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 43, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 43, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 44, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncNone": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleAsyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleAsyncWithArgCalled1": 42, + "callAsyncSinglePromiseWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncSinglePromiseWithArgCalled1": 42, + "callAsyncSingleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 43, + }, + "callAsyncSingleSyncWithArgCalled1": 42, + "callAsyncSingleSyncWithArgNoReturn": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncEarlyError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleAsyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleAsyncLateError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleAsyncLateErrorEarlyResult1": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleAsyncLateErrorEarlyResult2": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleAsyncWithArg": Object { + "type": "promise", + "value": 45, + }, + "promiseMultipleAsyncWithArgCalled1": 42, + "promiseMultipleAsyncWithArgCalled2": 43, + "promiseMultipleAsyncWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleAsyncWithArgFirstReturnCalled1": 42, + "promiseMultipleAsyncWithArgFirstReturnCalled2": 43, + "promiseMultipleAsyncWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultipleAsyncWithArgLastReturnCalled1": 42, + "promiseMultipleAsyncWithArgLastReturnCalled2": 42, + "promiseMultipleAsyncWithArgNoReturn": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleAsyncWithArgNoReturnCalled1": 42, + "promiseMultipleAsyncWithArgNoReturnCalled2": 42, + "promiseMultipleMixed1WithArg": Object { + "type": "promise", + "value": 48, + }, + "promiseMultipleMixed1WithArgCalled1": 42, + "promiseMultipleMixed1WithArgCalled2": 43, + "promiseMultipleMixed1WithArgCalled3": 45, + "promiseMultipleMixed2WithArg": Object { + "type": "promise", + "value": 45, + }, + "promiseMultipleMixed2WithArgCalled1": 42, + "promiseMultipleMixed2WithArgCalled2": 43, + "promiseMultipleMixed3WithArg": Object { + "type": "promise", + "value": 48, + }, + "promiseMultipleMixed3WithArgCalled1": 42, + "promiseMultipleMixed3WithArgCalled2": 43, + "promiseMultipleMixed3WithArgCalled3": 45, + "promiseMultipleMixedError1WithArg": Object { + "error": "Error in sync", + "type": "promise", + }, + "promiseMultipleMixedError1WithArgCalled1": 42, + "promiseMultipleMixedError1WithArgCalled2": 42, + "promiseMultipleMixedError1WithArgCalled3": 43, + "promiseMultipleMixedError2WithArg": Object { + "error": "Error in promise", + "type": "promise", + }, + "promiseMultipleMixedError2WithArgCalled1": 42, + "promiseMultipleMixedError2WithArgCalled2": 42, + "promiseMultipleMixedError3WithArg": Object { + "error": "Error in async", + "type": "promise", + }, + "promiseMultipleMixedError3WithArgCalled1": 42, + "promiseMultipleMixedLateError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultiplePromiseEarlyError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultiplePromiseError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultiplePromiseLateError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultiplePromiseWithArg": Object { + "type": "promise", + "value": 45, + }, + "promiseMultiplePromiseWithArgCalled1": 42, + "promiseMultiplePromiseWithArgCalled2": 43, + "promiseMultiplePromiseWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultiplePromiseWithArgFirstReturnCalled1": 42, + "promiseMultiplePromiseWithArgFirstReturnCalled2": 43, + "promiseMultiplePromiseWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultiplePromiseWithArgLastReturnCalled1": 42, + "promiseMultiplePromiseWithArgLastReturnCalled2": 42, + "promiseMultiplePromiseWithArgNoReturn": Object { + "type": "promise", + "value": 42, + }, + "promiseMultiplePromiseWithArgNoReturnCalled1": 42, + "promiseMultiplePromiseWithArgNoReturnCalled2": 42, + "promiseMultipleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncLastReturn": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncNoReturn": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 45, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 43, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 43, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 43, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 44, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseNone": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleAsyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleAsyncWithArgCalled1": 42, + "promiseSinglePromiseWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseSinglePromiseWithArgCalled1": 42, + "promiseSingleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 43, + }, + "promiseSingleSyncWithArgCalled1": 42, + "promiseSingleSyncWithArgNoReturn": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncWithArgNoReturnCalled1": 42, + }, + "intercept": Object { + "callAsyncContextIntercepted": Object { + "type": "async", + "value": 48, + }, + "callAsyncContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "callAsyncContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncContextInterceptedTap1": Object { + "number": 42, + }, + "callAsyncIntercepted": Object { + "type": "async", + "value": 9, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "promise", + "type": "promise", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "callAsyncUnusedContextIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncUnusedContextInterceptedTap1": undefined, + "promiseContextIntercepted": Object { + "type": "promise", + "value": 48, + }, + "promiseContextInterceptedCall1": Array [ + Object { + "number": 42, + }, + 1, + 2, + 3, + ], + "promiseContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseContextInterceptedTap1": Object { + "number": 42, + }, + "promiseIntercepted": Object { + "type": "promise", + "value": 9, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "promise", + "type": "promise", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync", + "type": "sync", + }, + "promiseUnusedContextIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseUnusedContextInterceptedCall1": Array [ + undefined, + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseUnusedContextInterceptedTap1": undefined, + }, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": 9, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 127, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 84, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 84, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 85, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": 217, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncMultipleSyncWithArgsCalled2": Array [ + 129, + 43, + 44, + ], + "callAsyncNone": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": 9, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 127, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 84, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 84, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 85, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": 217, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseMultipleSyncWithArgsCalled2": Array [ + 129, + 43, + 44, + ], + "promiseNone": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; diff --git a/node_modules/tapable/lib/__tests__/__snapshots__/HookCodeFactory.js.snap b/node_modules/tapable/lib/__tests__/__snapshots__/HookCodeFactory.js.snap new file mode 100644 index 00000000..a070a9a5 --- /dev/null +++ b/node_modules/tapable/lib/__tests__/__snapshots__/HookCodeFactory.js.snap @@ -0,0 +1,880 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`HookCodeFactory callTap (no args, no intercept) async with onResult 1`] = ` +"var _fn1 = _x[1]; +_fn1((_err1, _result1) => { +if(_err1) { +onError(_err1); +} else { +onResult(_result1); +} +}); +" +`; + +exports[`HookCodeFactory callTap (no args, no intercept) async without onResult 1`] = ` +"var _fn1 = _x[1]; +_fn1(_err1 => { +if(_err1) { +onError(_err1); +} else { +onDone(); +} +}); +" +`; + +exports[`HookCodeFactory callTap (no args, no intercept) promise with onResult 1`] = ` +"var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +onResult(_result2); +}, _err2 => { +if(_hasResult2) throw _err2; +onError(_err2); +}); +" +`; + +exports[`HookCodeFactory callTap (no args, no intercept) promise without onResult 1`] = ` +"var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +onDone(); +}, _err2 => { +if(_hasResult2) throw _err2; +onError(_err2); +}); +" +`; + +exports[`HookCodeFactory callTap (no args, no intercept) sync with onResult 1`] = ` +"var _fn0 = _x[0]; +var _hasError0 = false; +try { +var _result0 = _fn0(); +} catch(_err) { +_hasError0 = true; +onError(_err); +} +if(!_hasError0) { +onResult(_result0); +} +" +`; + +exports[`HookCodeFactory callTap (no args, no intercept) sync without onResult 1`] = ` +"var _fn0 = _x[0]; +var _hasError0 = false; +try { +_fn0(); +} catch(_err) { +_hasError0 = true; +onError(_err); +} +if(!_hasError0) { +onDone(); +} +" +`; + +exports[`HookCodeFactory callTap (with args, no intercept) async with onResult 1`] = ` +"var _fn1 = _x[1]; +_fn1(a, b, c, (_err1, _result1) => { +if(_err1) { +onError(_err1); +} else { +onResult(_result1); +} +}); +" +`; + +exports[`HookCodeFactory callTap (with args, no intercept) async without onResult 1`] = ` +"var _fn1 = _x[1]; +_fn1(a, b, c, _err1 => { +if(_err1) { +onError(_err1); +} else { +onDone(); +} +}); +" +`; + +exports[`HookCodeFactory callTap (with args, no intercept) promise with onResult 1`] = ` +"var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(a, b, c); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +onResult(_result2); +}, _err2 => { +if(_hasResult2) throw _err2; +onError(_err2); +}); +" +`; + +exports[`HookCodeFactory callTap (with args, no intercept) promise without onResult 1`] = ` +"var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(a, b, c); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +onDone(); +}, _err2 => { +if(_hasResult2) throw _err2; +onError(_err2); +}); +" +`; + +exports[`HookCodeFactory callTap (with args, no intercept) sync with onResult 1`] = ` +"var _fn0 = _x[0]; +var _hasError0 = false; +try { +var _result0 = _fn0(a, b, c); +} catch(_err) { +_hasError0 = true; +onError(_err); +} +if(!_hasError0) { +onResult(_result0); +} +" +`; + +exports[`HookCodeFactory callTap (with args, no intercept) sync without onResult 1`] = ` +"var _fn0 = _x[0]; +var _hasError0 = false; +try { +_fn0(a, b, c); +} catch(_err) { +_hasError0 = true; +onError(_err); +} +if(!_hasError0) { +onDone(); +} +" +`; + +exports[`HookCodeFactory callTap (with args, with intercept) async with onResult 1`] = ` +"var _tap1 = _taps[1]; +_interceptors[0].tap(_tap1); +_interceptors[1].tap(_tap1); +var _fn1 = _x[1]; +_fn1(a, b, c, (_err1, _result1) => { +if(_err1) { +onError(_err1); +} else { +onResult(_result1); +} +}); +" +`; + +exports[`HookCodeFactory callTap (with args, with intercept) async without onResult 1`] = ` +"var _tap1 = _taps[1]; +_interceptors[0].tap(_tap1); +_interceptors[1].tap(_tap1); +var _fn1 = _x[1]; +_fn1(a, b, c, _err1 => { +if(_err1) { +onError(_err1); +} else { +onDone(); +} +}); +" +`; + +exports[`HookCodeFactory callTap (with args, with intercept) promise with onResult 1`] = ` +"var _tap2 = _taps[2]; +_interceptors[0].tap(_tap2); +_interceptors[1].tap(_tap2); +var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(a, b, c); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +onResult(_result2); +}, _err2 => { +if(_hasResult2) throw _err2; +onError(_err2); +}); +" +`; + +exports[`HookCodeFactory callTap (with args, with intercept) promise without onResult 1`] = ` +"var _tap2 = _taps[2]; +_interceptors[0].tap(_tap2); +_interceptors[1].tap(_tap2); +var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(a, b, c); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +onDone(); +}, _err2 => { +if(_hasResult2) throw _err2; +onError(_err2); +}); +" +`; + +exports[`HookCodeFactory callTap (with args, with intercept) sync with onResult 1`] = ` +"var _tap0 = _taps[0]; +_interceptors[0].tap(_tap0); +_interceptors[1].tap(_tap0); +var _fn0 = _x[0]; +var _hasError0 = false; +try { +var _result0 = _fn0(a, b, c); +} catch(_err) { +_hasError0 = true; +onError(_err); +} +if(!_hasError0) { +onResult(_result0); +} +" +`; + +exports[`HookCodeFactory callTap (with args, with intercept) sync without onResult 1`] = ` +"var _tap0 = _taps[0]; +_interceptors[0].tap(_tap0); +_interceptors[1].tap(_tap0); +var _fn0 = _x[0]; +var _hasError0 = false; +try { +_fn0(a, b, c); +} catch(_err) { +_hasError0 = true; +onError(_err); +} +if(!_hasError0) { +onDone(); +} +" +`; + +exports[`HookCodeFactory taps (mixed) callTapsLooping 1`] = ` +"var _looper = () => { +var _loopAsync = false; +var _loop; +do { +_loop = false; +var _fn0 = _x[0]; +var _hasError0 = false; +try { +var _result0 = _fn0(a, b, c); +} catch(_err) { +_hasError0 = true; +onError(0, _err); +} +if(!_hasError0) { +if(_result0 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +var _fn1 = _x[1]; +_fn1(a, b, c, (_err1, _result1) => { +if(_err1) { +onError(1, _err1); +} else { +if(_result1 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(a, b, c); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +if(_result2 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +if(!_loop) { +onDone(); +} +} +}, _err2 => { +if(_hasResult2) throw _err2; +onError(2, _err2); +}); +} +} +}); +} +} +} while(_loop); +_loopAsync = true; +}; +_looper(); +" +`; + +exports[`HookCodeFactory taps (mixed) callTapsParallel 1`] = ` +"do { +var _counter = 3; +var _done = () => { +onDone(); +}; +if(_counter <= 0) break; +var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +if(_counter > 0) { +onResult(0, _result0, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +if(_counter <= 0) break; +var _fn1 = _x[1]; +_fn1(a, b, c, (_err1, _result1) => { +if(_err1) { +if(_counter > 0) { +onError(1, _err1); +} +} else { +if(_counter > 0) { +onResult(1, _result1, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +} +}); +if(_counter <= 0) break; +var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(a, b, c); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +if(_counter > 0) { +onResult(2, _result2, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +}, _err2 => { +if(_hasResult2) throw _err2; +if(_counter > 0) { +onError(2, _err2); +} +}); +} while(false); +" +`; + +exports[`HookCodeFactory taps (mixed) callTapsSeries 1`] = ` +"var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +onResult(0, _result0, () => { +var _fn1 = _x[1]; +_fn1(a, b, c, (_err1, _result1) => { +if(_err1) { +onError(1, _err1); +} else { +onResult(1, _result1, () => { +var _fn2 = _x[2]; +var _hasResult2 = false; +var _promise2 = _fn2(a, b, c); +if (!_promise2 || !_promise2.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise2 + ')'); +_promise2.then(_result2 => { +_hasResult2 = true; +onResult(2, _result2, () => { +onDone(); +}, () => { +onDone(); +}); +}, _err2 => { +if(_hasResult2) throw _err2; +onError(2, _err2); +}); +}, () => { +onDone(); +}); +} +}); +}, () => { +onDone(); +}); +" +`; + +exports[`HookCodeFactory taps (mixed2) callTapsLooping 1`] = ` +"var _looper = () => { +var _loopAsync = false; +var _loop; +do { +_loop = false; +var _fn0 = _x[0]; +_fn0(a, b, c, (_err0, _result0) => { +if(_err0) { +onError(0, _err0); +} else { +if(_result0 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +var _fn1 = _x[1]; +var _hasResult1 = false; +var _promise1 = _fn1(a, b, c); +if (!_promise1 || !_promise1.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise1 + ')'); +_promise1.then(_result1 => { +_hasResult1 = true; +if(_result1 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +var _fn2 = _x[2]; +var _hasError2 = false; +try { +var _result2 = _fn2(a, b, c); +} catch(_err) { +_hasError2 = true; +onError(2, _err); +} +if(!_hasError2) { +if(_result2 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +if(!_loop) { +onDone(); +} +} +} +} +}, _err1 => { +if(_hasResult1) throw _err1; +onError(1, _err1); +}); +} +} +}); +} while(_loop); +_loopAsync = true; +}; +_looper(); +" +`; + +exports[`HookCodeFactory taps (mixed2) callTapsParallel 1`] = ` +"do { +var _counter = 3; +var _done = () => { +onDone(); +}; +if(_counter <= 0) break; +var _fn0 = _x[0]; +_fn0(a, b, c, (_err0, _result0) => { +if(_err0) { +if(_counter > 0) { +onError(0, _err0); +} +} else { +if(_counter > 0) { +onResult(0, _result0, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +} +}); +if(_counter <= 0) break; +var _fn1 = _x[1]; +var _hasResult1 = false; +var _promise1 = _fn1(a, b, c); +if (!_promise1 || !_promise1.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise1 + ')'); +_promise1.then(_result1 => { +_hasResult1 = true; +if(_counter > 0) { +onResult(1, _result1, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +}, _err1 => { +if(_hasResult1) throw _err1; +if(_counter > 0) { +onError(1, _err1); +} +}); +if(_counter <= 0) break; +var _fn2 = _x[2]; +var _result2 = _fn2(a, b, c); +if(_counter > 0) { +onResult(2, _result2, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +} while(false); +" +`; + +exports[`HookCodeFactory taps (mixed2) callTapsSeries 1`] = ` +"var _fn0 = _x[0]; +_fn0(a, b, c, (_err0, _result0) => { +if(_err0) { +onError(0, _err0); +} else { +onResult(0, _result0, () => { +var _fn1 = _x[1]; +var _hasResult1 = false; +var _promise1 = _fn1(a, b, c); +if (!_promise1 || !_promise1.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise1 + ')'); +_promise1.then(_result1 => { +_hasResult1 = true; +onResult(1, _result1, () => { +var _fn2 = _x[2]; +var _hasError2 = false; +try { +var _result2 = _fn2(a, b, c); +} catch(_err) { +_hasError2 = true; +onError(2, _err); +} +if(!_hasError2) { +onResult(2, _result2, () => { +onDone(); +}, () => { +onDone(); +}); +} +}, () => { +onDone(); +}); +}, _err1 => { +if(_hasResult1) throw _err1; +onError(1, _err1); +}); +}, () => { +onDone(); +}); +} +}); +" +`; + +exports[`HookCodeFactory taps (multiple sync) callTapsLooping 1`] = ` +"var _loop; +do { +_loop = false; +var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +if(_result0 !== undefined) { +_loop = true; +} else { +var _fn1 = _x[1]; +var _result1 = _fn1(a, b, c); +if(_result1 !== undefined) { +_loop = true; +} else { +var _fn2 = _x[2]; +var _result2 = _fn2(a, b, c); +if(_result2 !== undefined) { +_loop = true; +} else { +if(!_loop) { +onDone(); +} +} +} +} +} while(_loop); +" +`; + +exports[`HookCodeFactory taps (multiple sync) callTapsParallel 1`] = ` +"do { +var _counter = 3; +var _done = () => { +onDone(); +}; +if(_counter <= 0) break; +var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +if(_counter > 0) { +onResult(0, _result0, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +if(_counter <= 0) break; +var _fn1 = _x[1]; +var _result1 = _fn1(a, b, c); +if(_counter > 0) { +onResult(1, _result1, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +if(_counter <= 0) break; +var _fn2 = _x[2]; +var _result2 = _fn2(a, b, c); +if(_counter > 0) { +onResult(2, _result2, () => { +if(--_counter === 0) _done(); +}, () => { +_counter = 0; +_done(); +}); +} +} while(false); +" +`; + +exports[`HookCodeFactory taps (multiple sync) callTapsSeries 1`] = ` +"var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +onResult(0, _result0, () => { +var _fn1 = _x[1]; +var _result1 = _fn1(a, b, c); +onResult(1, _result1, () => { +var _fn2 = _x[2]; +var _result2 = _fn2(a, b, c); +onResult(2, _result2, () => { +onDone(); +}, () => { +onDone(); +}); +}, () => { +onDone(); +}); +}, () => { +onDone(); +}); +" +`; + +exports[`HookCodeFactory taps (none) callTapsLooping 1`] = ` +"onDone(); +" +`; + +exports[`HookCodeFactory taps (none) callTapsParallel 1`] = ` +"onDone(); +" +`; + +exports[`HookCodeFactory taps (none) callTapsSeries 1`] = ` +"onDone(); +" +`; + +exports[`HookCodeFactory taps (single async) callTapsLooping 1`] = ` +"var _looper = () => { +var _loopAsync = false; +var _loop; +do { +_loop = false; +var _fn0 = _x[0]; +_fn0(a, b, c, (_err0, _result0) => { +if(_err0) { +onError(0, _err0); +} else { +if(_result0 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +if(!_loop) { +onDone(); +} +} +} +}); +} while(_loop); +_loopAsync = true; +}; +_looper(); +" +`; + +exports[`HookCodeFactory taps (single async) callTapsParallel 1`] = ` +"var _fn0 = _x[0]; +_fn0(a, b, c, (_err0, _result0) => { +if(_err0) { +onError(0, _err0); +} else { +onResult(0, _result0, () => { +onDone(); +}, () => { +onDone(); +}); +} +}); +" +`; + +exports[`HookCodeFactory taps (single async) callTapsSeries 1`] = ` +"var _fn0 = _x[0]; +_fn0(a, b, c, (_err0, _result0) => { +if(_err0) { +onError(0, _err0); +} else { +onResult(0, _result0, () => { +onDone(); +}, () => { +onDone(); +}); +} +}); +" +`; + +exports[`HookCodeFactory taps (single promise) callTapsLooping 1`] = ` +"var _looper = () => { +var _loopAsync = false; +var _loop; +do { +_loop = false; +var _fn0 = _x[0]; +var _hasResult0 = false; +var _promise0 = _fn0(a, b, c); +if (!_promise0 || !_promise0.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise0 + ')'); +_promise0.then(_result0 => { +_hasResult0 = true; +if(_result0 !== undefined) { +_loop = true; +if(_loopAsync) _looper(); +} else { +if(!_loop) { +onDone(); +} +} +}, _err0 => { +if(_hasResult0) throw _err0; +onError(0, _err0); +}); +} while(_loop); +_loopAsync = true; +}; +_looper(); +" +`; + +exports[`HookCodeFactory taps (single promise) callTapsParallel 1`] = ` +"var _fn0 = _x[0]; +var _hasResult0 = false; +var _promise0 = _fn0(a, b, c); +if (!_promise0 || !_promise0.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise0 + ')'); +_promise0.then(_result0 => { +_hasResult0 = true; +onResult(0, _result0, () => { +onDone(); +}, () => { +onDone(); +}); +}, _err0 => { +if(_hasResult0) throw _err0; +onError(0, _err0); +}); +" +`; + +exports[`HookCodeFactory taps (single promise) callTapsSeries 1`] = ` +"var _fn0 = _x[0]; +var _hasResult0 = false; +var _promise0 = _fn0(a, b, c); +if (!_promise0 || !_promise0.then) + throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise0 + ')'); +_promise0.then(_result0 => { +_hasResult0 = true; +onResult(0, _result0, () => { +onDone(); +}, () => { +onDone(); +}); +}, _err0 => { +if(_hasResult0) throw _err0; +onError(0, _err0); +}); +" +`; + +exports[`HookCodeFactory taps (single sync) callTapsLooping 1`] = ` +"var _loop; +do { +_loop = false; +var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +if(_result0 !== undefined) { +_loop = true; +} else { +if(!_loop) { +onDone(); +} +} +} while(_loop); +" +`; + +exports[`HookCodeFactory taps (single sync) callTapsParallel 1`] = ` +"var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +onResult(0, _result0, () => { +onDone(); +}, () => { +onDone(); +}); +" +`; + +exports[`HookCodeFactory taps (single sync) callTapsSeries 1`] = ` +"var _fn0 = _x[0]; +var _result0 = _fn0(a, b, c); +onResult(0, _result0, () => { +onDone(); +}, () => { +onDone(); +}); +" +`; diff --git a/node_modules/tapable/lib/__tests__/__snapshots__/SyncHooks.js.snap b/node_modules/tapable/lib/__tests__/__snapshots__/SyncHooks.js.snap new file mode 100644 index 00000000..10a4126d --- /dev/null +++ b/node_modules/tapable/lib/__tests__/__snapshots__/SyncHooks.js.snap @@ -0,0 +1,876 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SyncBailHook should have to correct behavior 1`] = ` +Object { + "async": Object {}, + "intercept": Object {}, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": 6, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncErrorCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 85, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": 129, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncCalled": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "callIntercepted": Object { + "type": "return", + "value": 6, + }, + "callInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callInterceptedTap1": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callMultipleSync": Object { + "type": "return", + "value": 42, + }, + "callMultipleSyncCalled1": true, + "callMultipleSyncError": Object { + "error": "Error in sync2", + }, + "callMultipleSyncErrorCalled1": true, + "callMultipleSyncErrorCalled2": true, + "callMultipleSyncWithArg": Object { + "type": "return", + "value": 84, + }, + "callMultipleSyncWithArgCalled1": 42, + "callMultipleSyncWithArgFirstReturn": Object { + "type": "return", + "value": 84, + }, + "callMultipleSyncWithArgFirstReturnCalled1": 42, + "callMultipleSyncWithArgLastReturn": Object { + "type": "return", + "value": 85, + }, + "callMultipleSyncWithArgLastReturnCalled1": 42, + "callMultipleSyncWithArgLastReturnCalled2": 42, + "callMultipleSyncWithArgNoReturn": Object { + "type": "no result", + }, + "callMultipleSyncWithArgNoReturnCalled1": 42, + "callMultipleSyncWithArgNoReturnCalled2": 42, + "callMultipleSyncWithArgs": Object { + "type": "return", + "value": 129, + }, + "callMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callNone": Object { + "type": "no result", + }, + "callNoneWithArg": Object { + "type": "no result", + }, + "callSingleSync": Object { + "type": "return", + "value": 42, + }, + "callSingleSyncCalled": true, + "callSingleSyncWithArg": Object { + "type": "return", + "value": 42, + }, + "callSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": 6, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncErrorCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 85, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": 129, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncCalled": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; + +exports[`SyncHook should have to correct behavior 1`] = ` +Object { + "async": Object {}, + "intercept": Object {}, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": undefined, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncCalled1": true, + "callAsyncMultipleSyncCalled2": true, + "callAsyncMultipleSyncError": Object { + "error": "Error in sync2", + "type": "async", + }, + "callAsyncMultipleSyncErrorCalled1": true, + "callAsyncMultipleSyncErrorCalled2": true, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 42, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 42, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncMultipleSyncWithArgsCalled2": Array [ + 42, + 43, + 44, + ], + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncCalled": true, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "callIntercepted": Object { + "type": "no result", + }, + "callInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "callInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callMultipleSync": Object { + "type": "no result", + }, + "callMultipleSyncCalled1": true, + "callMultipleSyncCalled2": true, + "callMultipleSyncError": Object { + "error": "Error in sync2", + }, + "callMultipleSyncErrorCalled1": true, + "callMultipleSyncErrorCalled2": true, + "callMultipleSyncWithArg": Object { + "type": "no result", + }, + "callMultipleSyncWithArgCalled1": 42, + "callMultipleSyncWithArgCalled2": 42, + "callMultipleSyncWithArgFirstReturn": Object { + "type": "no result", + }, + "callMultipleSyncWithArgFirstReturnCalled1": 42, + "callMultipleSyncWithArgFirstReturnCalled2": 42, + "callMultipleSyncWithArgLastReturn": Object { + "type": "no result", + }, + "callMultipleSyncWithArgLastReturnCalled1": 42, + "callMultipleSyncWithArgLastReturnCalled2": 42, + "callMultipleSyncWithArgNoReturn": Object { + "type": "no result", + }, + "callMultipleSyncWithArgNoReturnCalled1": 42, + "callMultipleSyncWithArgNoReturnCalled2": 42, + "callMultipleSyncWithArgs": Object { + "type": "no result", + }, + "callMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callMultipleSyncWithArgsCalled2": Array [ + 42, + 43, + 44, + ], + "callNone": Object { + "type": "no result", + }, + "callNoneWithArg": Object { + "type": "no result", + }, + "callSingleSync": Object { + "type": "no result", + }, + "callSingleSyncCalled": true, + "callSingleSyncWithArg": Object { + "type": "no result", + }, + "callSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": undefined, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncCalled1": true, + "promiseMultipleSyncCalled2": true, + "promiseMultipleSyncError": Object { + "error": "Error in sync2", + "type": "promise", + }, + "promiseMultipleSyncErrorCalled1": true, + "promiseMultipleSyncErrorCalled2": true, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 42, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 42, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseMultipleSyncWithArgsCalled2": Array [ + 42, + 43, + 44, + ], + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncCalled": true, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; + +exports[`SyncLoopHook should have to correct behavior 1`] = ` +Object { + "async": Object {}, + "sync": Object { + "callAsyncInterceptedSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncInterceptedSyncCalled1": 83, + "callAsyncInterceptedSyncCalled2": 42, + "callAsyncInterceptedSyncCalledCall": 1, + "callAsyncInterceptedSyncCalledLoop": 83, + "callAsyncInterceptedSyncCalledTap": 125, + "callAsyncMultipleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncMultipleSyncCalled1": 83, + "callAsyncMultipleSyncCalled2": 42, + "callAsyncNone": Object { + "type": "async", + "value": undefined, + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSync": Object { + "type": "async", + "value": undefined, + }, + "callAsyncSingleSyncCalled": 42, + "callInterceptedSync": Object { + "type": "no result", + }, + "callInterceptedSyncCalled1": 83, + "callInterceptedSyncCalled2": 42, + "callInterceptedSyncCalledCall": 1, + "callInterceptedSyncCalledLoop": 83, + "callInterceptedSyncCalledTap": 125, + "callMultipleSync": Object { + "type": "no result", + }, + "callMultipleSyncCalled1": 83, + "callMultipleSyncCalled2": 42, + "callNone": Object { + "type": "no result", + }, + "callNoneWithArg": Object { + "type": "no result", + }, + "callSingleSync": Object { + "type": "no result", + }, + "callSingleSyncCalled": 42, + "promiseInterceptedSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseInterceptedSyncCalled1": 83, + "promiseInterceptedSyncCalled2": 42, + "promiseInterceptedSyncCalledCall": 1, + "promiseInterceptedSyncCalledLoop": 83, + "promiseInterceptedSyncCalledTap": 125, + "promiseMultipleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseMultipleSyncCalled1": 83, + "promiseMultipleSyncCalled2": 42, + "promiseNone": Object { + "type": "promise", + "value": undefined, + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSync": Object { + "type": "promise", + "value": undefined, + }, + "promiseSingleSyncCalled": 42, + }, +} +`; + +exports[`SyncWaterfallHook should have to correct behavior 1`] = ` +Object { + "async": Object {}, + "intercept": Object {}, + "sync": Object { + "callAsyncIntercepted": Object { + "type": "async", + "value": 9, + }, + "callAsyncInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callAsyncInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "callAsyncInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callAsyncMultipleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncMultipleSyncWithArg": Object { + "type": "async", + "value": 127, + }, + "callAsyncMultipleSyncWithArgCalled1": 42, + "callAsyncMultipleSyncWithArgCalled2": 84, + "callAsyncMultipleSyncWithArgFirstReturn": Object { + "type": "async", + "value": 84, + }, + "callAsyncMultipleSyncWithArgFirstReturnCalled1": 42, + "callAsyncMultipleSyncWithArgFirstReturnCalled2": 84, + "callAsyncMultipleSyncWithArgLastReturn": Object { + "type": "async", + "value": 85, + }, + "callAsyncMultipleSyncWithArgLastReturnCalled1": 42, + "callAsyncMultipleSyncWithArgLastReturnCalled2": 42, + "callAsyncMultipleSyncWithArgNoReturn": Object { + "type": "async", + "value": 42, + }, + "callAsyncMultipleSyncWithArgNoReturnCalled1": 42, + "callAsyncMultipleSyncWithArgNoReturnCalled2": 42, + "callAsyncMultipleSyncWithArgs": Object { + "type": "async", + "value": 217, + }, + "callAsyncMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callAsyncMultipleSyncWithArgsCalled2": Array [ + 129, + 43, + 44, + ], + "callAsyncNone": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncNoneWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callAsyncSingleSyncWithArg": Object { + "type": "async", + "value": 42, + }, + "callAsyncSingleSyncWithArgCalled": 42, + "callIntercepted": Object { + "type": "return", + "value": 9, + }, + "callInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "callInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "callInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "callInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "callMultipleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callMultipleSyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callMultipleSyncWithArg": Object { + "type": "return", + "value": 127, + }, + "callMultipleSyncWithArgCalled1": 42, + "callMultipleSyncWithArgCalled2": 84, + "callMultipleSyncWithArgFirstReturn": Object { + "type": "return", + "value": 84, + }, + "callMultipleSyncWithArgFirstReturnCalled1": 42, + "callMultipleSyncWithArgFirstReturnCalled2": 84, + "callMultipleSyncWithArgLastReturn": Object { + "type": "return", + "value": 85, + }, + "callMultipleSyncWithArgLastReturnCalled1": 42, + "callMultipleSyncWithArgLastReturnCalled2": 42, + "callMultipleSyncWithArgNoReturn": Object { + "type": "return", + "value": 42, + }, + "callMultipleSyncWithArgNoReturnCalled1": 42, + "callMultipleSyncWithArgNoReturnCalled2": 42, + "callMultipleSyncWithArgs": Object { + "type": "return", + "value": 217, + }, + "callMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "callMultipleSyncWithArgsCalled2": Array [ + 129, + 43, + 44, + ], + "callNone": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callNoneWithArg": Object { + "type": "return", + "value": 42, + }, + "callSingleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "callSingleSyncWithArg": Object { + "type": "return", + "value": 42, + }, + "callSingleSyncWithArgCalled": 42, + "promiseIntercepted": Object { + "type": "promise", + "value": 9, + }, + "promiseInterceptedCall1": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedCall2": Array [ + 1, + 2, + 3, + ], + "promiseInterceptedTap1": Object { + "fn": 2, + "name": "sync2", + "type": "sync", + }, + "promiseInterceptedTap2": Object { + "fn": 3, + "name": "sync1", + "type": "sync", + }, + "promiseMultipleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncError": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseMultipleSyncWithArg": Object { + "type": "promise", + "value": 127, + }, + "promiseMultipleSyncWithArgCalled1": 42, + "promiseMultipleSyncWithArgCalled2": 84, + "promiseMultipleSyncWithArgFirstReturn": Object { + "type": "promise", + "value": 84, + }, + "promiseMultipleSyncWithArgFirstReturnCalled1": 42, + "promiseMultipleSyncWithArgFirstReturnCalled2": 84, + "promiseMultipleSyncWithArgLastReturn": Object { + "type": "promise", + "value": 85, + }, + "promiseMultipleSyncWithArgLastReturnCalled1": 42, + "promiseMultipleSyncWithArgLastReturnCalled2": 42, + "promiseMultipleSyncWithArgNoReturn": Object { + "type": "promise", + "value": 42, + }, + "promiseMultipleSyncWithArgNoReturnCalled1": 42, + "promiseMultipleSyncWithArgNoReturnCalled2": 42, + "promiseMultipleSyncWithArgs": Object { + "type": "promise", + "value": 217, + }, + "promiseMultipleSyncWithArgsCalled1": Array [ + 42, + 43, + 44, + ], + "promiseMultipleSyncWithArgsCalled2": Array [ + 129, + 43, + 44, + ], + "promiseNone": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseNoneWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSync": Object { + "error": "Waterfall hooks must have at least one argument", + }, + "promiseSingleSyncWithArg": Object { + "type": "promise", + "value": 42, + }, + "promiseSingleSyncWithArgCalled": 42, + }, +} +`; diff --git a/node_modules/tapable/lib/index.js b/node_modules/tapable/lib/index.js new file mode 100644 index 00000000..9205ce85 --- /dev/null +++ b/node_modules/tapable/lib/index.js @@ -0,0 +1,19 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +exports.__esModule = true; +exports.Tapable = require("./Tapable"); +exports.SyncHook = require("./SyncHook"); +exports.SyncBailHook = require("./SyncBailHook"); +exports.SyncWaterfallHook = require("./SyncWaterfallHook"); +exports.SyncLoopHook = require("./SyncLoopHook"); +exports.AsyncParallelHook = require("./AsyncParallelHook"); +exports.AsyncParallelBailHook = require("./AsyncParallelBailHook"); +exports.AsyncSeriesHook = require("./AsyncSeriesHook"); +exports.AsyncSeriesBailHook = require("./AsyncSeriesBailHook"); +exports.AsyncSeriesWaterfallHook = require("./AsyncSeriesWaterfallHook"); +exports.HookMap = require("./HookMap"); +exports.MultiHook = require("./MultiHook"); diff --git a/node_modules/tapable/package.json b/node_modules/tapable/package.json new file mode 100644 index 00000000..bb232aee --- /dev/null +++ b/node_modules/tapable/package.json @@ -0,0 +1,38 @@ +{ + "name": "tapable", + "version": "1.1.0", + "author": "Tobias Koppers @sokra", + "description": "Just a little module for plugins.", + "license": "MIT", + "repository": { + "type": "git", + "url": "http://github.com/webpack/tapable.git" + }, + "devDependencies": { + "babel-core": "^6.26.0", + "babel-jest": "^21.0.2", + "babel-polyfill": "^6.26.0", + "babel-preset-env": "^1.6.0", + "codecov": "^2.3.0", + "jest": "^21.0.4", + "prettier": "^1.13.2" + }, + "engines": { + "node": ">=6" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/webpack/tapable", + "main": "lib/index.js", + "scripts": { + "test": "jest", + "travis": "jest --coverage && codecov", + "pretty": "prettier --write lib/*.js lib/__tests__/*.js" + }, + "jest": { + "transform": { + "__tests__[\\\\/].+\\.js$": "babel-jest" + } + } +} -- cgit v1.2.3