| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  | import {EventEmitter, TemplateRef, ViewContainerRef} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  | import {AttributeMarker, RenderFlags, ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdirectiveInject} from '../../src/render3/index'; | 
					
						
							|  |  |  | import {ɵɵbind, ɵɵelement, ɵɵelementContainerEnd, ɵɵelementContainerStart, ɵɵelementEnd, ɵɵelementProperty, ɵɵelementStart, ɵɵlistener, ɵɵtemplate, ɵɵtext} from '../../src/render3/instructions/all'; | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  | import {NgIf} from './common_with_def'; | 
					
						
							| 
									
										
										
										
											2019-04-04 11:41:52 -07:00
										 |  |  | import {ComponentFixture, TemplateFixture, createComponent} from './render_util'; | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe('directive', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |   describe('selectors', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should match directives with attribute selectors on bindings', () => { | 
					
						
							|  |  |  |       let directiveInstance: Directive; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       class Directive { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         static ngDirectiveDef = ɵɵdefineDirective({ | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |           type: Directive, | 
					
						
							|  |  |  |           selectors: [['', 'test', '']], | 
					
						
							|  |  |  |           factory: () => directiveInstance = new Directive, | 
					
						
							|  |  |  |           inputs: {test: 'test', other: 'other'} | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-18 16:38:33 -07:00
										 |  |  |         // TODO(issue/24571): remove '!'.
 | 
					
						
							|  |  |  |         testValue !: boolean; | 
					
						
							|  |  |  |         // TODO(issue/24571): remove '!'.
 | 
					
						
							|  |  |  |         other !: boolean; | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         /** | 
					
						
							|  |  |  |          * A setter to assert that a binding is not invoked with stringified attribute value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         set test(value: any) { | 
					
						
							|  |  |  |           // if a binding is processed correctly we should only be invoked with a false Boolean
 | 
					
						
							|  |  |  |           // and never with the "false" string literal
 | 
					
						
							|  |  |  |           this.testValue = value; | 
					
						
							|  |  |  |           if (value !== false) { | 
					
						
							|  |  |  |             fail('Should only be called with a false Boolean value, got a non-falsy value'); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * <span [test]="false" [other]="true"></span> | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       function createTemplate() { | 
					
						
							|  |  |  |         // using 2 bindings to show example shape of attributes array
 | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         ɵɵelement(0, 'span', ['class', 'fade', AttributeMarker.Bindings, 'test', 'other']); | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |       function updateTemplate() { ɵɵelementProperty(0, 'test', ɵɵbind(false)); } | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 11:14:50 -07:00
										 |  |  |       const fixture = new TemplateFixture(createTemplate, updateTemplate, 1, 1, [Directive]); | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // the "test" attribute should not be reflected in the DOM as it is here only for directive
 | 
					
						
							|  |  |  |       // matching purposes
 | 
					
						
							|  |  |  |       expect(fixture.html).toEqual('<span class="fade"></span>'); | 
					
						
							|  |  |  |       expect(directiveInstance !.testValue).toBe(false); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should not accidentally set inputs from attributes extracted from bindings / outputs', | 
					
						
							|  |  |  |        () => { | 
					
						
							|  |  |  |          let directiveInstance: Directive; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |          class Directive { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |            static ngDirectiveDef = ɵɵdefineDirective({ | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |              type: Directive, | 
					
						
							|  |  |  |              selectors: [['', 'test', '']], | 
					
						
							|  |  |  |              factory: () => directiveInstance = new Directive, | 
					
						
							|  |  |  |              inputs: {test: 'test', prop1: 'prop1', prop2: 'prop2'} | 
					
						
							|  |  |  |            }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-18 16:38:33 -07:00
										 |  |  |            // TODO(issue/24571): remove '!'.
 | 
					
						
							|  |  |  |            prop1 !: boolean; | 
					
						
							|  |  |  |            // TODO(issue/24571): remove '!'.
 | 
					
						
							|  |  |  |            prop2 !: boolean; | 
					
						
							|  |  |  |            // TODO(issue/24571): remove '!'.
 | 
					
						
							|  |  |  |            testValue !: boolean; | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            /** | 
					
						
							|  |  |  |             * A setter to assert that a binding is not invoked with stringified attribute value | 
					
						
							|  |  |  |             */ | 
					
						
							|  |  |  |            set test(value: any) { | 
					
						
							|  |  |  |              // if a binding is processed correctly we should only be invoked with a false Boolean
 | 
					
						
							|  |  |  |              // and never with the "false" string literal
 | 
					
						
							|  |  |  |              this.testValue = value; | 
					
						
							|  |  |  |              if (value !== false) { | 
					
						
							|  |  |  |                fail('Should only be called with a false Boolean value, got a non-falsy value'); | 
					
						
							|  |  |  |              } | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  |          } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |          /** | 
					
						
							| 
									
										
										
										
											2018-06-08 15:25:39 -07:00
										 |  |  |           * <span class="fade" [prop1]="true" [test]="false" [prop2]="true"></span> | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |           */ | 
					
						
							|  |  |  |          function createTemplate() { | 
					
						
							|  |  |  |            // putting name (test) in the "usual" value position
 | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |            ɵɵelement( | 
					
						
							| 
									
										
										
										
											2019-03-07 08:31:31 +00:00
										 |  |  |                0, 'span', ['class', 'fade', AttributeMarker.Bindings, 'prop1', 'test', 'prop2']); | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |          } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |          function updateTemplate() { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |            ɵɵelementProperty(0, 'prop1', ɵɵbind(true)); | 
					
						
							|  |  |  |            ɵɵelementProperty(0, 'test', ɵɵbind(false)); | 
					
						
							|  |  |  |            ɵɵelementProperty(0, 'prop2', ɵɵbind(true)); | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |          } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 11:14:50 -07:00
										 |  |  |          const fixture = new TemplateFixture(createTemplate, updateTemplate, 1, 3, [Directive]); | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |          // the "test" attribute should not be reflected in the DOM as it is here only for directive
 | 
					
						
							|  |  |  |          // matching purposes
 | 
					
						
							|  |  |  |          expect(fixture.html).toEqual('<span class="fade"></span>'); | 
					
						
							|  |  |  |          expect(directiveInstance !.testValue).toBe(false); | 
					
						
							|  |  |  |        }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |     it('should match directives on <ng-template>', () => { | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        *   @Directive({ | 
					
						
							|  |  |  |        *     selector: 'ng-template[directiveA]' | 
					
						
							|  |  |  |        *   }) | 
					
						
							|  |  |  |        *   export class DirectiveA { | 
					
						
							|  |  |  |        *     constructor(public templateRef: TemplateRef<any>) {} | 
					
						
							|  |  |  |        *   } | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       let tmplRef: any; | 
					
						
							|  |  |  |       class DirectiveA { | 
					
						
							|  |  |  |         constructor(public templateRef: any) { tmplRef = templateRef; } | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         static ngDirectiveDef = ɵɵdefineDirective({ | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |           type: DirectiveA, | 
					
						
							|  |  |  |           selectors: [['ng-template', 'directiveA', '']], | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |           factory: () => new DirectiveA(ɵɵdirectiveInject(TemplateRef as any)) | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       function MyComponent_ng_template_Template_0(rf: RenderFlags, ctx: any) { | 
					
						
							|  |  |  |         if (rf & RenderFlags.Create) { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |           ɵɵtext(0, 'Some content'); | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       class MyComponent { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         static ngComponentDef = ɵɵdefineComponent({ | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |           type: MyComponent, | 
					
						
							|  |  |  |           selectors: [['my-component']], | 
					
						
							|  |  |  |           factory: () => new MyComponent(), | 
					
						
							|  |  |  |           consts: 1, | 
					
						
							|  |  |  |           vars: 0, | 
					
						
							|  |  |  |           // <ng-template directiveA>Some content</ng-template>
 | 
					
						
							|  |  |  |           template: function MyComponent_Template(rf: RenderFlags, ctx: any) { | 
					
						
							|  |  |  |             if (rf & RenderFlags.Create) { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |               ɵɵtemplate( | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |                   0, MyComponent_ng_template_Template_0, 1, 0, 'ng-template', ['directiveA', '']); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           directives: [DirectiveA] | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       new ComponentFixture(MyComponent); | 
					
						
							|  |  |  |       expect(tmplRef instanceof TemplateRef).toBeTruthy(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should match directives on <ng-container>', () => { | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        *   @Directive({ | 
					
						
							|  |  |  |        *     selector: 'ng-container[directiveA]' | 
					
						
							|  |  |  |        *   }) | 
					
						
							|  |  |  |        *   export class DirectiveA { | 
					
						
							|  |  |  |        *     constructor(public vcRef: ViewContainerRef<any>) {} | 
					
						
							|  |  |  |        *   } | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       let vcRef: any; | 
					
						
							|  |  |  |       class DirectiveA { | 
					
						
							|  |  |  |         constructor(public viewContainerRef: any) { vcRef = viewContainerRef; } | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         static ngDirectiveDef = ɵɵdefineDirective({ | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |           type: DirectiveA, | 
					
						
							|  |  |  |           selectors: [['ng-container', 'directiveA', '']], | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |           factory: () => new DirectiveA(ɵɵdirectiveInject(ViewContainerRef as any)) | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       function MyComponent_ng_container_Template_0(rf: RenderFlags, ctx: any) { | 
					
						
							|  |  |  |         if (rf & RenderFlags.Create) { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |           ɵɵelementContainerStart(0, ['directiveA', '']); | 
					
						
							|  |  |  |           ɵɵtext(1, 'Some content'); | 
					
						
							|  |  |  |           ɵɵelementContainerEnd(); | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       class MyComponent { | 
					
						
							|  |  |  |         visible = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         static ngComponentDef = ɵɵdefineComponent({ | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |           type: MyComponent, | 
					
						
							|  |  |  |           selectors: [['my-component']], | 
					
						
							|  |  |  |           factory: () => new MyComponent(), | 
					
						
							|  |  |  |           consts: 1, | 
					
						
							|  |  |  |           vars: 1, | 
					
						
							|  |  |  |           // <ng-container *ngIf="visible" directiveA>Some content</ng-container>
 | 
					
						
							|  |  |  |           template: function MyComponent_Template(rf: RenderFlags, ctx: any) { | 
					
						
							|  |  |  |             if (rf & RenderFlags.Create) { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |               ɵɵtemplate( | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |                   0, MyComponent_ng_container_Template_0, 2, 0, 'ng-container', | 
					
						
							| 
									
										
										
										
											2019-03-07 08:31:31 +00:00
										 |  |  |                   ['directiveA', '', AttributeMarker.Template, 'ngIf']); | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |             } | 
					
						
							|  |  |  |             if (rf & RenderFlags.Update) { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |               ɵɵelementProperty(0, 'ngIf', ɵɵbind(ctx.visible)); | 
					
						
							| 
									
										
										
										
											2018-12-12 15:23:12 -08:00
										 |  |  |             } | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           directives: [DirectiveA, NgIf] | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       new ComponentFixture(MyComponent); | 
					
						
							|  |  |  |       expect(vcRef instanceof ViewContainerRef).toBeTruthy(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |     it('should match directives with attribute selectors on outputs', () => { | 
					
						
							|  |  |  |       let directiveInstance: Directive; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       class Directive { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         static ngDirectiveDef = ɵɵdefineDirective({ | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |           type: Directive, | 
					
						
							|  |  |  |           selectors: [['', 'out', '']], | 
					
						
							|  |  |  |           factory: () => directiveInstance = new Directive, | 
					
						
							|  |  |  |           outputs: {out: 'out'} | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         out = new EventEmitter(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * <span (out)="someVar = true"></span> | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       function createTemplate() { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |         ɵɵelementStart(0, 'span', [AttributeMarker.Bindings, 'out']); | 
					
						
							|  |  |  |         { ɵɵlistener('out', () => {}); } | 
					
						
							|  |  |  |         ɵɵelementEnd(); | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 11:14:50 -07:00
										 |  |  |       const fixture = new TemplateFixture(createTemplate, () => {}, 1, 0, [Directive]); | 
					
						
							| 
									
										
										
										
											2018-05-04 15:58:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // "out" should not be part of reflected attributes
 | 
					
						
							|  |  |  |       expect(fixture.html).toEqual('<span></span>'); | 
					
						
							|  |  |  |       expect(directiveInstance !).not.toBeUndefined(); | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-08-28 15:31:09 +02:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('outputs', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let directiveInstance: Directive; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class Directive { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |       static ngDirectiveDef = ɵɵdefineDirective({ | 
					
						
							| 
									
										
										
										
											2018-08-28 15:31:09 +02:00
										 |  |  |         type: Directive, | 
					
						
							|  |  |  |         selectors: [['', 'out', '']], | 
					
						
							|  |  |  |         factory: () => directiveInstance = new Directive, | 
					
						
							|  |  |  |         outputs: {out: 'out'} | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       out = new EventEmitter(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should allow outputs of directive on ng-template', () => { | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * <ng-template (out)="value = true"></ng-template> | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       const Cmpt = createComponent('Cmpt', function(rf: RenderFlags, ctx: {value: any}) { | 
					
						
							|  |  |  |         if (rf & RenderFlags.Create) { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |           ɵɵtemplate(0, null, 0, 0, 'ng-template', [AttributeMarker.Bindings, 'out']); | 
					
						
							|  |  |  |           ɵɵlistener('out', () => { ctx.value = true; }); | 
					
						
							| 
									
										
										
										
											2018-08-28 15:31:09 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |       }, 1, 0, [Directive]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const fixture = new ComponentFixture(Cmpt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(directiveInstance !).not.toBeUndefined(); | 
					
						
							|  |  |  |       expect(fixture.component.value).toBeFalsy(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       directiveInstance !.out.emit(); | 
					
						
							|  |  |  |       fixture.update(); | 
					
						
							|  |  |  |       expect(fixture.component.value).toBeTruthy(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should allow outputs of directive on ng-container', () => { | 
					
						
							|  |  |  |       /** | 
					
						
							|  |  |  |        * <ng-container (out)="value = true"></ng-container> | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       const Cmpt = createComponent('Cmpt', function(rf: RenderFlags, ctx: {value: any}) { | 
					
						
							|  |  |  |         if (rf & RenderFlags.Create) { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |           ɵɵelementContainerStart(0, [AttributeMarker.Bindings, 'out']); | 
					
						
							| 
									
										
										
										
											2018-08-28 15:31:09 +02:00
										 |  |  |           { | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |             ɵɵlistener('out', () => { ctx.value = true; }); | 
					
						
							| 
									
										
										
										
											2018-08-28 15:31:09 +02:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2019-04-11 13:46:47 -07:00
										 |  |  |           ɵɵelementContainerEnd(); | 
					
						
							| 
									
										
										
										
											2018-08-28 15:31:09 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |       }, 1, 0, [Directive]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const fixture = new ComponentFixture(Cmpt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(directiveInstance !).not.toBeUndefined(); | 
					
						
							|  |  |  |       expect(fixture.component.value).toBeFalsy(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       directiveInstance !.out.emit(); | 
					
						
							|  |  |  |       fixture.update(); | 
					
						
							|  |  |  |       expect(fixture.component.value).toBeTruthy(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); |