1
+ import { _supportsShadowDom } from '@angular/cdk/platform' ;
1
2
import {
2
3
ComponentHarness ,
3
4
ComponentHarnessConstructor ,
@@ -7,12 +8,12 @@ import {
7
8
import { expectAsyncError } from '@angular/cdk/testing/private' ;
8
9
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed' ;
9
10
import { async , ComponentFixture , fakeAsync , TestBed } from '@angular/core/testing' ;
11
+ import { querySelectorAll as piercingQuerySelectorAll } from 'kagekiri' ;
10
12
import { FakeOverlayHarness } from './harnesses/fake-overlay-harness' ;
11
13
import { MainComponentHarness } from './harnesses/main-component-harness' ;
12
14
import { SubComponentHarness , SubComponentSpecialHarness } from './harnesses/sub-component-harness' ;
13
15
import { TestComponentsModule } from './test-components-module' ;
14
16
import { TestMainComponent } from './test-main-component' ;
15
- import { querySelectorAll as piercingQuerySelectorAll } from 'kagekiri' ;
16
17
17
18
function activeElementText ( ) {
18
19
return document . activeElement && ( document . activeElement as HTMLElement ) . innerText || '' ;
@@ -494,26 +495,28 @@ describe('TestbedHarnessEnvironment', () => {
494
495
} ) ;
495
496
} ) ;
496
497
497
- describe ( 'shadow DOM interaction' , ( ) => {
498
- it ( 'should not pierce shadow boundary by default' , async ( ) => {
499
- const harness = await TestbedHarnessEnvironment
500
- . harnessForFixture ( fixture , MainComponentHarness ) ;
501
- expect ( await harness . shadows ( ) ) . toEqual ( [ ] ) ;
502
- } ) ;
503
-
504
- it ( 'should pierce shadow boundary when using piercing query' , async ( ) => {
505
- const harness = await TestbedHarnessEnvironment
506
- . harnessForFixture ( fixture , MainComponentHarness , piercingQuerySelectorAll ) ;
507
- const shadows = await harness . shadows ( ) ;
508
- expect ( await Promise . all ( shadows . map ( el => el . text ( ) ) ) ) . toEqual ( [ 'Shadow 1' , 'Shadow 2' ] ) ;
498
+ if ( _supportsShadowDom ( ) ) {
499
+ describe ( 'shadow DOM interaction' , ( ) => {
500
+ it ( 'should not pierce shadow boundary by default' , async ( ) => {
501
+ const harness = await TestbedHarnessEnvironment
502
+ . harnessForFixture ( fixture , MainComponentHarness ) ;
503
+ expect ( await harness . shadows ( ) ) . toEqual ( [ ] ) ;
504
+ } ) ;
505
+
506
+ it ( 'should pierce shadow boundary when using piercing query' , async ( ) => {
507
+ const harness = await TestbedHarnessEnvironment
508
+ . harnessForFixture ( fixture , MainComponentHarness , piercingQuerySelectorAll ) ;
509
+ const shadows = await harness . shadows ( ) ;
510
+ expect ( await Promise . all ( shadows . map ( el => el . text ( ) ) ) ) . toEqual ( [ 'Shadow 1' , 'Shadow 2' ] ) ;
511
+ } ) ;
512
+
513
+ it ( 'should allow querying across shadow boundary' , async ( ) => {
514
+ const harness = await TestbedHarnessEnvironment
515
+ . harnessForFixture ( fixture , MainComponentHarness , piercingQuerySelectorAll ) ;
516
+ expect ( await ( await harness . deepShadow ( ) ) . text ( ) ) . toBe ( 'Shadow 2' ) ;
517
+ } ) ;
509
518
} ) ;
510
-
511
- it ( 'should allow querying across shadow boundary' , async ( ) => {
512
- const harness = await TestbedHarnessEnvironment
513
- . harnessForFixture ( fixture , MainComponentHarness , piercingQuerySelectorAll ) ;
514
- expect ( await ( await harness . deepShadow ( ) ) . text ( ) ) . toBe ( 'Shadow 2' ) ;
515
- } ) ;
516
- } ) ;
519
+ }
517
520
} ) ;
518
521
519
522
async function checkIsElement ( result : ComponentHarness | TestElement , selector ?: string ) {
0 commit comments