@@ -12,6 +12,7 @@ import {Component, DebugNode, Directive, ElementRef, EmbeddedViewRef, EventEmitt
12
12
import { ComponentFixture , TestBed , async } from '@angular/core/testing' ;
13
13
import { By } from '@angular/platform-browser/src/dom/debug/by' ;
14
14
import { getDOM } from '@angular/platform-browser/src/dom/dom_adapter' ;
15
+ import { hasClass } from '@angular/platform-browser/testing/src/browser_util' ;
15
16
import { expect } from '@angular/platform-browser/testing/src/matchers' ;
16
17
import { ivyEnabled } from '@angular/private/testing' ;
17
18
@@ -254,24 +255,24 @@ class TestCmptWithPropBindings {
254
255
255
256
// The root component has 3 elements in its view.
256
257
expect ( childEls . length ) . toEqual ( 3 ) ;
257
- expect ( getDOM ( ) . hasClass ( childEls [ 0 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
258
- expect ( getDOM ( ) . hasClass ( childEls [ 1 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
259
- expect ( getDOM ( ) . hasClass ( childEls [ 2 ] . nativeElement , 'child-comp-class' ) ) . toBe ( true ) ;
258
+ expect ( hasClass ( childEls [ 0 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
259
+ expect ( hasClass ( childEls [ 1 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
260
+ expect ( hasClass ( childEls [ 2 ] . nativeElement , 'child-comp-class' ) ) . toBe ( true ) ;
260
261
261
262
const nested = childEls [ 0 ] . children ;
262
263
expect ( nested . length ) . toEqual ( 1 ) ;
263
- expect ( getDOM ( ) . hasClass ( nested [ 0 ] . nativeElement , 'parentnested' ) ) . toBe ( true ) ;
264
+ expect ( hasClass ( nested [ 0 ] . nativeElement , 'parentnested' ) ) . toBe ( true ) ;
264
265
265
266
const childComponent = childEls [ 2 ] ;
266
267
267
268
const childCompChildren = childComponent . children ;
268
269
expect ( childCompChildren . length ) . toEqual ( 2 ) ;
269
- expect ( getDOM ( ) . hasClass ( childCompChildren [ 0 ] . nativeElement , 'child' ) ) . toBe ( true ) ;
270
- expect ( getDOM ( ) . hasClass ( childCompChildren [ 1 ] . nativeElement , 'child' ) ) . toBe ( true ) ;
270
+ expect ( hasClass ( childCompChildren [ 0 ] . nativeElement , 'child' ) ) . toBe ( true ) ;
271
+ expect ( hasClass ( childCompChildren [ 1 ] . nativeElement , 'child' ) ) . toBe ( true ) ;
271
272
272
273
const childNested = childCompChildren [ 0 ] . children ;
273
274
expect ( childNested . length ) . toEqual ( 1 ) ;
274
- expect ( getDOM ( ) . hasClass ( childNested [ 0 ] . nativeElement , 'childnested' ) ) . toBe ( true ) ;
275
+ expect ( hasClass ( childNested [ 0 ] . nativeElement , 'childnested' ) ) . toBe ( true ) ;
275
276
} ) ;
276
277
277
278
it ( 'should list conditional component child elements' , ( ) => {
@@ -282,8 +283,8 @@ class TestCmptWithPropBindings {
282
283
283
284
// The root component has 2 elements in its view.
284
285
expect ( childEls . length ) . toEqual ( 2 ) ;
285
- expect ( getDOM ( ) . hasClass ( childEls [ 0 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
286
- expect ( getDOM ( ) . hasClass ( childEls [ 1 ] . nativeElement , 'cond-content-comp-class' ) ) . toBe ( true ) ;
286
+ expect ( hasClass ( childEls [ 0 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
287
+ expect ( hasClass ( childEls [ 1 ] . nativeElement , 'cond-content-comp-class' ) ) . toBe ( true ) ;
287
288
288
289
const conditionalContentComp = childEls [ 1 ] ;
289
290
@@ -353,7 +354,7 @@ class TestCmptWithPropBindings {
353
354
const childTestEls = fixture . debugElement . queryAll ( By . css ( 'child-comp' ) ) ;
354
355
355
356
expect ( childTestEls . length ) . toBe ( 1 ) ;
356
- expect ( getDOM ( ) . hasClass ( childTestEls [ 0 ] . nativeElement , 'child-comp-class' ) ) . toBe ( true ) ;
357
+ expect ( hasClass ( childTestEls [ 0 ] . nativeElement , 'child-comp-class' ) ) . toBe ( true ) ;
357
358
} ) ;
358
359
359
360
it ( 'should query child elements by directive' , ( ) => {
@@ -363,10 +364,10 @@ class TestCmptWithPropBindings {
363
364
const childTestEls = fixture . debugElement . queryAll ( By . directive ( MessageDir ) ) ;
364
365
365
366
expect ( childTestEls . length ) . toBe ( 4 ) ;
366
- expect ( getDOM ( ) . hasClass ( childTestEls [ 0 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
367
- expect ( getDOM ( ) . hasClass ( childTestEls [ 1 ] . nativeElement , 'parentnested' ) ) . toBe ( true ) ;
368
- expect ( getDOM ( ) . hasClass ( childTestEls [ 2 ] . nativeElement , 'child' ) ) . toBe ( true ) ;
369
- expect ( getDOM ( ) . hasClass ( childTestEls [ 3 ] . nativeElement , 'childnested' ) ) . toBe ( true ) ;
367
+ expect ( hasClass ( childTestEls [ 0 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
368
+ expect ( hasClass ( childTestEls [ 1 ] . nativeElement , 'parentnested' ) ) . toBe ( true ) ;
369
+ expect ( hasClass ( childTestEls [ 2 ] . nativeElement , 'child' ) ) . toBe ( true ) ;
370
+ expect ( hasClass ( childTestEls [ 3 ] . nativeElement , 'childnested' ) ) . toBe ( true ) ;
370
371
} ) ;
371
372
372
373
it ( 'should query projected child elements by directive' , ( ) => {
0 commit comments