1+ import { Component } from '@angular/core' ;
12import { ComponentFixture , TestBed } from '@angular/core/testing' ;
23
34import { Observable } from 'rxjs' ;
@@ -10,23 +11,32 @@ import { PoTagIcon } from './enums/po-tag-icon.enum';
1011import { PoTagOrientation } from './enums/po-tag-orientation.enum' ;
1112import { PoTagType } from './enums/po-tag-type.enum' ;
1213
14+ @Component ( {
15+ template : `<po-tag p-label="Mock" (p-click)="onClick()"></po-tag>`
16+ } )
17+ class PoTagClickableComponent {
18+ onClick ( ) { }
19+ }
20+
1321describe ( 'PoTagComponent:' , ( ) => {
1422 let component : PoTagComponent ;
1523 let fixture : ComponentFixture < PoTagComponent > ;
1624
25+ let fixtureClickable : ComponentFixture < PoTagClickableComponent > ;
26+
1727 let nativeElement : any ;
1828
1929 configureTestSuite ( ( ) => {
2030 TestBed . configureTestingModule ( {
21- declarations : [ PoTagComponent ]
31+ declarations : [ PoTagComponent , PoTagClickableComponent ]
2232 } ) ;
2333 } ) ;
2434
2535 beforeEach ( ( ) => {
2636 fixture = TestBed . createComponent ( PoTagComponent ) ;
2737 component = fixture . componentInstance ;
2838
29- fixture . detectChanges ( ) ;
39+ fixtureClickable = TestBed . createComponent ( PoTagClickableComponent ) ;
3040
3141 nativeElement = fixture . debugElement . nativeElement ;
3242 } ) ;
@@ -231,6 +241,8 @@ describe('PoTagComponent:', () => {
231241 } ) ;
232242
233243 it ( 'should add `po-tag-info` as default.' , ( ) => {
244+ fixture . detectChanges ( ) ;
245+
234246 expect ( nativeElement . querySelector ( '.po-tag-info' ) ) . toBeTruthy ( ) ;
235247 } ) ;
236248
@@ -303,10 +315,9 @@ describe('PoTagComponent:', () => {
303315 } ) ;
304316
305317 it ( 'should add `po-clickable` if `p-click` @Output is wire up`.' , ( ) => {
306- component . isClickable = true ;
318+ fixtureClickable . detectChanges ( ) ;
307319
308- fixture . detectChanges ( ) ;
309- expect ( nativeElement . querySelector ( '.po-clickable' ) ) . toBeTruthy ( ) ;
320+ expect ( fixtureClickable . debugElement . nativeElement . querySelector ( '.po-clickable' ) ) . toBeTruthy ( ) ;
310321 } ) ;
311322
312323 it ( 'shouldn`t add `po-clickable` if `p-click` @Output isn`t wire up`.' , ( ) => {
0 commit comments