@@ -10,30 +10,6 @@ import {DOCUMENT} from '@angular/common';
1010import { Inject , Injectable , OnDestroy } from '@angular/core' ;
1111import { Platform } from '@angular/cdk/platform' ;
1212
13- // Avoid using `declare const` because it caused conflicts inside Google
14- // with the real typings for these symbols. We use `declare interface` instead
15- // of just `interface` for interop with Closure Compiler (prevents property renaming):
16- // https://github.com/angular/tsickle/blob/master/README.md#differences-from-typescript
17- declare interface TestGlobals {
18- jasmine : unknown ;
19- __karma__ : unknown ;
20- jest : unknown ;
21- Mocha : unknown ;
22- }
23-
24- const globalsForTest = ( typeof window !== 'undefined' ? window : { } ) as { } as TestGlobals ;
25-
26- /**
27- * Whether we're in a testing environment.
28- * TODO(crisbeto): remove this once we have an overlay testing module or Angular starts tearing
29- * down the testing `NgModule` (see https://github.com/angular/angular/issues/18831).
30- */
31- const isTestEnvironment =
32- ( typeof globalsForTest . __karma__ !== 'undefined' && ! ! globalsForTest . __karma__ ) ||
33- ( typeof globalsForTest . jasmine !== 'undefined' && ! ! globalsForTest . jasmine ) ||
34- ( typeof globalsForTest . jest !== 'undefined' && ! ! globalsForTest . jest ) ||
35- ( typeof globalsForTest . Mocha !== 'undefined' && ! ! globalsForTest . Mocha ) ;
36-
3713/** Container inside which all overlays will render. */
3814@Injectable ( { providedIn : 'root' } )
3915export class OverlayContainer implements OnDestroy {
@@ -54,7 +30,7 @@ export class OverlayContainer implements OnDestroy {
5430
5531 /**
5632 * This method returns the overlay container element. It will lazily
57- * create the element the first time it is called to facilitate using
33+ * create the element the first time it is called to facilitate using
5834 * the container in non-browser environments.
5935 * @returns the container element
6036 */
@@ -73,7 +49,10 @@ export class OverlayContainer implements OnDestroy {
7349 protected _createContainer ( ) : void {
7450 const containerClass = 'cdk-overlay-container' ;
7551
76- if ( this . _platform . isBrowser || isTestEnvironment ) {
52+ // TODO(crisbeto): remove the testing check once we have an overlay testing
53+ // module or Angular starts tearing down the testing `NgModule`. See:
54+ // https://github.com/angular/angular/issues/18831
55+ if ( this . _platform . isBrowser || this . _platform . isTest ) {
7756 const oppositePlatformContainers =
7857 this . _document . querySelectorAll ( `.${ containerClass } [platform="server"], ` +
7958 `.${ containerClass } [platform="test"]` ) ;
@@ -97,7 +76,7 @@ export class OverlayContainer implements OnDestroy {
9776 // module which does the cleanup, we try to detect that we're in a test environment and we
9877 // always clear the container. See #17006.
9978 // TODO(crisbeto): remove the test environment check once we have an overlay testing module.
100- if ( isTestEnvironment ) {
79+ if ( this . _platform . isTest ) {
10180 container . setAttribute ( 'platform' , 'test' ) ;
10281 } else if ( ! this . _platform . isBrowser ) {
10382 container . setAttribute ( 'platform' , 'server' ) ;
0 commit comments