UNPKG

6.18 kBSource Map (JSON)View Raw
1{"version":3,"file":"fake_async.js","sourceRoot":"","sources":["../../../../modules/@angular/core/testing/fake_async.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,IAAM,qBAAqB,GAAI,IAAY,CAAC,uBAAuB,CAAC,CAAC;AAIrE,IAAM,aAAa,GACd,IAAY,CAAC,eAAe,CAAC,CAAC;AAEnC,IAAI,sBAAsB,GAAQ,IAAI,CAAC;AAEvC;;;;;GAKG;AACH;IACE,sBAAsB,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,aAAa,EAAE,CAAC,aAAa,EAAE,CAAC;AAChD,CAAC;AAED,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B;;;;;;;;;;;;;;;;;GAiBG;AACH,0BAA0B,EAAY;IACpC,MAAM,CAAC;QAAS,cAAc;aAAd,WAAc,CAAd,sBAAc,CAAd,IAAc;YAAd,6BAAc;;QAC5B,IAAM,aAAa,GAAG,aAAa,CAAC,aAAa,EAAE,CAAC;QACpD,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,gBAAgB,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC;YACH,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBAC5B,EAAE,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE,YAAY,qBAAqB,CAAC,CAAC,CAAC;oBACjE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;gBACzD,CAAC;gBAED,sBAAsB,GAAG,IAAI,qBAAqB,EAAE,CAAC;YACvD,CAAC;YAED,IAAI,GAAG,SAAK,CAAC;YACb,IAAM,iBAAiB,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;YACtD,aAAa,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;YAClD,IAAI,CAAC;gBACH,GAAG,GAAG,EAA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EAAE,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n\nconst FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec'];\ntype ProxyZoneSpec = {\n setDelegate(delegateSpec: ZoneSpec): void; getDelegate(): ZoneSpec; resetDelegate(): void;\n};\nconst ProxyZoneSpec: {get(): ProxyZoneSpec; assertPresent: () => ProxyZoneSpec} =\n (Zone as any)['ProxyZoneSpec'];\n\nlet _fakeAsyncTestZoneSpec: any = null;\n\n/**\n * Clears out the shared fake async zone for a test.\n * To be called in a global `beforeEach`.\n *\n * @experimental\n */\nexport function resetFakeAsyncZone() {\n _fakeAsyncTestZoneSpec = null;\n ProxyZoneSpec.assertPresent().resetDelegate();\n}\n\nlet _inFakeAsyncCall = false;\n\n/**\n * Wraps a function to be executed in the fakeAsync zone:\n * - microtasks are manually executed by calling `flushMicrotasks()`,\n * - timers are synchronous, `tick()` simulates the asynchronous passage of time.\n *\n * If there are any pending timers at the end of the function, an exception will be thrown.\n *\n * Can be used to wrap inject() calls.\n *\n * ## Example\n *\n * {@example testing/ts/fake_async.ts region='basic'}\n *\n * @param fn\n * @returns {Function} The function wrapped to be executed in the fakeAsync zone\n *\n * @experimental\n */\nexport function fakeAsync(fn: Function): (...args: any[]) => any {\n return function(...args: any[]) {\n const proxyZoneSpec = ProxyZoneSpec.assertPresent();\n if (_inFakeAsyncCall) {\n throw new Error('fakeAsync() calls can not be nested');\n }\n _inFakeAsyncCall = true;\n try {\n if (!_fakeAsyncTestZoneSpec) {\n if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) {\n throw new Error('fakeAsync() calls can not be nested');\n }\n\n _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec();\n }\n\n let res: any;\n const lastProxyZoneSpec = proxyZoneSpec.getDelegate();\n proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec);\n try {\n res = fn(...args);\n flushMicrotasks();\n } finally {\n proxyZoneSpec.setDelegate(lastProxyZoneSpec);\n }\n\n if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) {\n throw new Error(\n `${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` +\n `periodic timer(s) still in the queue.`);\n }\n\n if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) {\n throw new Error(\n `${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`);\n }\n return res;\n } finally {\n _inFakeAsyncCall = false;\n resetFakeAsyncZone();\n }\n };\n}\n\nfunction _getFakeAsyncZoneSpec(): any {\n if (_fakeAsyncTestZoneSpec == null) {\n throw new Error('The code should be running in the fakeAsync zone to call this function');\n }\n return _fakeAsyncTestZoneSpec;\n}\n\n/**\n * Simulates the asynchronous passage of time for the timers in the fakeAsync zone.\n *\n * The microtasks queue is drained at the very start of this function and after any timer callback\n * has been executed.\n *\n * ## Example\n *\n * {@example testing/ts/fake_async.ts region='basic'}\n *\n * @experimental\n */\nexport function tick(millis: number = 0): void {\n _getFakeAsyncZoneSpec().tick(millis);\n}\n\n/**\n * Discard all remaining periodic tasks.\n *\n * @experimental\n */\nexport function discardPeriodicTasks(): void {\n const zoneSpec = _getFakeAsyncZoneSpec();\n const pendingTimers = zoneSpec.pendingPeriodicTimers;\n zoneSpec.pendingPeriodicTimers.length = 0;\n}\n\n/**\n * Flush any pending microtasks.\n *\n * @experimental\n */\nexport function flushMicrotasks(): void {\n _getFakeAsyncZoneSpec().flushMicrotasks();\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file