UNPKG

10.6 kBSource Map (JSON)View Raw
1{"version":3,"file":"component_fixture.js","sourceRoot":"","sources":["../../../../modules/@angular/core/testing/component_fixture.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;OAEI,EAAoE,YAAY,EAAC,MAAM,eAAe;OACtG,EAAC,iBAAiB,EAAC,MAAM,eAAe;AAG/C;;;;GAIG;AACH;IAmCE,0BACW,YAA6B,EAAS,MAAc,EAAU,WAAoB;QApC/F,iBA0KC;QAtIY,iBAAY,GAAZ,YAAY,CAAiB;QAAS,WAAM,GAAN,MAAM,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAS;QAVrF,cAAS,GAAY,IAAI,CAAC;QAC1B,iBAAY,GAAY,KAAK,CAAC;QAE9B,aAAQ,GAAiB,IAAI,CAAC;QAC9B,4BAAuB,GAA0B,IAAI,CAAC;QACtD,0BAAqB,GAA0B,IAAI,CAAC;QACpD,kCAA6B,GAA0B,IAAI,CAAC;QAC5D,yBAAoB,GAA0B,IAAI,CAAC;QAIzD,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC,iBAAiB,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,YAAY,GAAiB,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAC9E,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC,QAAQ,CAAC;QAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QACnD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,uBAAuB;gBACxB,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAC,IAAI,EAAE,cAAQ,KAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,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,oBAAoB,GAAG,IAAI,CAAC;YACnC,CAAC;YACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;IACH,CAAC;IACH,uBAAC;AAAD,CAAC,AA1KD,IA0KC","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\nimport {ChangeDetectorRef, ComponentRef, DebugElement, ElementRef, NgZone, getDebugNode} from '@angular/core';\nimport {scheduleMicroTask} from './facade/lang';\n\n\n/**\n * Fixture for debugging and testing a component.\n *\n * @stable\n */\nexport class ComponentFixture<T> {\n /**\n * The DebugElement associated with the root element of this component.\n */\n debugElement: DebugElement;\n\n /**\n * The instance of the root component class.\n */\n componentInstance: T;\n\n /**\n * The native element at the root of the component.\n */\n nativeElement: any;\n\n /**\n * The ElementRef for the element at the root of the component.\n */\n elementRef: ElementRef;\n\n /**\n * The ChangeDetectorRef for the component\n */\n changeDetectorRef: ChangeDetectorRef;\n\n private _isStable: boolean = true;\n private _isDestroyed: boolean = false;\n private _resolve: (result: any) => void;\n private _promise: Promise<any> = null;\n private _onUnstableSubscription: any /** TODO #9100 */ = null;\n private _onStableSubscription: any /** TODO #9100 */ = null;\n private _onMicrotaskEmptySubscription: any /** TODO #9100 */ = null;\n private _onErrorSubscription: any /** TODO #9100 */ = null;\n\n constructor(\n public componentRef: ComponentRef<T>, public ngZone: NgZone, private _autoDetect: boolean) {\n this.changeDetectorRef = componentRef.changeDetectorRef;\n this.elementRef = componentRef.location;\n this.debugElement = <DebugElement>getDebugNode(this.elementRef.nativeElement);\n this.componentInstance = componentRef.instance;\n this.nativeElement = this.elementRef.nativeElement;\n this.componentRef = componentRef;\n this.ngZone = ngZone;\n\n if (ngZone != null) {\n this._onUnstableSubscription =\n ngZone.onUnstable.subscribe({next: () => { this._isStable = false; }});\n this._onMicrotaskEmptySubscription = ngZone.onMicrotaskEmpty.subscribe({\n next: () => {\n if (this._autoDetect) {\n // Do a change detection run with checkNoChanges set to true to check\n // there are no changes on the second run.\n this.detectChanges(true);\n }\n }\n });\n this._onStableSubscription = ngZone.onStable.subscribe({\n next: () => {\n this._isStable = true;\n // Check whether there is a pending whenStable() completer to resolve.\n if (this._promise !== null) {\n // If so check whether there are no pending macrotasks before resolving.\n // Do this check in the next tick so that ngZone gets a chance to update the state of\n // pending macrotasks.\n scheduleMicroTask(() => {\n if (!this.ngZone.hasPendingMacrotasks) {\n if (this._promise !== null) {\n this._resolve(true);\n this._resolve = null;\n this._promise = null;\n }\n }\n });\n }\n }\n });\n\n this._onErrorSubscription =\n ngZone.onError.subscribe({next: (error: any) => { throw error; }});\n }\n }\n\n private _tick(checkNoChanges: boolean) {\n this.changeDetectorRef.detectChanges();\n if (checkNoChanges) {\n this.checkNoChanges();\n }\n }\n\n /**\n * Trigger a change detection cycle for the component.\n */\n detectChanges(checkNoChanges: boolean = true): void {\n if (this.ngZone != null) {\n // Run the change detection inside the NgZone so that any async tasks as part of the change\n // detection are captured by the zone and can be waited for in isStable.\n this.ngZone.run(() => { this._tick(checkNoChanges); });\n } else {\n // Running without zone. Just do the change detection.\n this._tick(checkNoChanges);\n }\n }\n\n /**\n * Do a change detection run to make sure there were no changes.\n */\n checkNoChanges(): void { this.changeDetectorRef.checkNoChanges(); }\n\n /**\n * Set whether the fixture should autodetect changes.\n *\n * Also runs detectChanges once so that any existing change is detected.\n */\n autoDetectChanges(autoDetect: boolean = true) {\n if (this.ngZone == null) {\n throw new Error('Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set');\n }\n this._autoDetect = autoDetect;\n this.detectChanges();\n }\n\n /**\n * Return whether the fixture is currently stable or has async tasks that have not been completed\n * yet.\n */\n isStable(): boolean { return this._isStable && !this.ngZone.hasPendingMacrotasks; }\n\n /**\n * Get a promise that resolves when the fixture is stable.\n *\n * This can be used to resume testing after events have triggered asynchronous activity or\n * asynchronous change detection.\n */\n whenStable(): Promise<any> {\n if (this.isStable()) {\n return Promise.resolve(false);\n } else if (this._promise !== null) {\n return this._promise;\n } else {\n this._promise = new Promise(res => { this._resolve = res; });\n return this._promise;\n }\n }\n\n /**\n * Trigger component destruction.\n */\n destroy(): void {\n if (!this._isDestroyed) {\n this.componentRef.destroy();\n if (this._onUnstableSubscription != null) {\n this._onUnstableSubscription.unsubscribe();\n this._onUnstableSubscription = null;\n }\n if (this._onStableSubscription != null) {\n this._onStableSubscription.unsubscribe();\n this._onStableSubscription = null;\n }\n if (this._onMicrotaskEmptySubscription != null) {\n this._onMicrotaskEmptySubscription.unsubscribe();\n this._onMicrotaskEmptySubscription = null;\n }\n if (this._onErrorSubscription != null) {\n this._onErrorSubscription.unsubscribe();\n this._onErrorSubscription = null;\n }\n this._isDestroyed = true;\n }\n }\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file