@@ -16,12 +16,15 @@ let ctx: BindingsContext;
1616
1717@Component ( {
1818 template : `
19- <div [ioClick]="methodDiv">1</div>
20- <button [ioClick]="methodBut">2</button>
21- <div id="b" ioOnDynamic [ioClick]="methodDyn"><b id="b1">B</b></div>
22- <b id="b2" [ioClick] (clickBinder)="methodParam($event, 'foo')"></b>
23- <b ioClick>bad</b>
24- <b [ioClick]="fff">bad2</b>` ,
19+ <div id="d1" [ioClick]="methodDiv">1</div>
20+ <button [ioClick]="methodBut">2</button>
21+ <div id="b" ioOnDynamic [ioClick]="methodDyn"><b id="b1">B</b></div>
22+ <b id="b2" ioClick (clickBinder)="methodParam($event, 'foo')"></b>
23+ <b ioClick>bad</b>
24+ <b [ioClick]="fff">bad2</b>,
25+ @if(true) {<div id="d3" [ioClick]="methodDiv">3</div>}
26+ @switch(true) { @case(true) {<div id="d4" [ioClick]="methodDiv">4</div>} }
27+ @switch(true) { @case(false) {} @default{ <div id="d5" [ioClick]="methodDiv">5</div>} }` ,
2528 standalone : true ,
2629 imports : [ ClickBinderDirective , OnDynamicDirective ]
2730} )
@@ -103,14 +106,35 @@ describe("click directive", () => {
103106 } ) ;
104107
105108 it ( "should produce a StubCmd1 on a click on the div" , ( ) => {
106- const div = fixture . debugElement . query ( By . css ( "div" ) ) . nativeElement as HTMLElement ;
109+ const div = fixture . debugElement . query ( By . css ( "#d1" ) ) . nativeElement as HTMLElement ;
110+ robot ( div ) . click ( ) ;
111+ expect ( ctx . commands . length ) . toEqual ( 1 ) ;
112+ expect ( ctx . commands [ 0 ] ) . toBeInstanceOf ( StubCmd1 ) ;
113+ } ) ;
114+
115+ it ( "should produce a StubCmd1 on a click on the div in a if statement" , ( ) => {
116+ const div = fixture . debugElement . query ( By . css ( "#d3" ) ) . nativeElement as HTMLElement ;
117+ robot ( div ) . click ( ) ;
118+ expect ( ctx . commands . length ) . toEqual ( 1 ) ;
119+ expect ( ctx . commands [ 0 ] ) . toBeInstanceOf ( StubCmd1 ) ;
120+ } ) ;
121+
122+ it ( "should produce a StubCmd1 on a click on the div in a switch case statement" , ( ) => {
123+ const div = fixture . debugElement . query ( By . css ( "#d4" ) ) . nativeElement as HTMLElement ;
124+ robot ( div ) . click ( ) ;
125+ expect ( ctx . commands . length ) . toEqual ( 1 ) ;
126+ expect ( ctx . commands [ 0 ] ) . toBeInstanceOf ( StubCmd1 ) ;
127+ } ) ;
128+
129+ it ( "should produce a StubCmd1 on a click on the div in a switch default statement" , ( ) => {
130+ const div = fixture . debugElement . query ( By . css ( "#d5" ) ) . nativeElement as HTMLElement ;
107131 robot ( div ) . click ( ) ;
108132 expect ( ctx . commands . length ) . toEqual ( 1 ) ;
109133 expect ( ctx . commands [ 0 ] ) . toBeInstanceOf ( StubCmd1 ) ;
110134 } ) ;
111135
112136 it ( "should produce two StubCmd1 on two click on the div" , ( ) => {
113- const div = fixture . debugElement . query ( By . css ( "div " ) ) . nativeElement as HTMLElement ;
137+ const div = fixture . debugElement . query ( By . css ( "#d1 " ) ) . nativeElement as HTMLElement ;
114138 robot ( ) . click ( div , 2 ) ;
115139 expect ( ctx . commands . length ) . toEqual ( 2 ) ;
116140 } ) ;
0 commit comments