| 
									
										
										
										
											2016-06-23 09:47:54 -07: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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | import {DirectiveResolver} from '@angular/compiler/src/directive_resolver'; | 
					
						
							| 
									
										
										
										
											2016-09-12 19:14:17 -07:00
										 |  |  | import {Component, ContentChild, ContentChildren, Directive, HostBinding, HostListener, Input, Output, ViewChild, ViewChildren} from '@angular/core/src/metadata'; | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: 'someDirective'}) | 
					
						
							|  |  |  | class SomeDirective { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: 'someChildDirective'}) | 
					
						
							|  |  |  | class SomeChildDirective extends SomeDirective { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  | @Directive({selector: 'someDirective', inputs: ['c']}) | 
					
						
							| 
									
										
										
										
											2015-10-02 16:21:49 -07:00
										 |  |  | class SomeDirectiveWithInputs { | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   @Input() a: any; | 
					
						
							|  |  |  |   @Input('renamed') b: any; | 
					
						
							|  |  |  |   c: any; | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  | @Directive({selector: 'someDirective', outputs: ['c']}) | 
					
						
							|  |  |  | class SomeDirectiveWithOutputs { | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   @Output() a: any; | 
					
						
							|  |  |  |   @Output('renamed') b: any; | 
					
						
							|  |  |  |   c: any; | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-04 17:08:51 +08:00
										 |  |  | @Directive({selector: 'someDirective', outputs: ['a']}) | 
					
						
							|  |  |  | class SomeDirectiveWithDuplicateOutputs { | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   @Output() a: any; | 
					
						
							| 
									
										
										
										
											2015-11-04 17:08:51 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  | @Directive({selector: 'someDirective', outputs: ['localA: a']}) | 
					
						
							|  |  |  | class SomeDirectiveWithDuplicateRenamedOutputs { | 
					
						
							|  |  |  |   @Output() a: any; | 
					
						
							|  |  |  |   localA: any; | 
					
						
							| 
									
										
										
										
											2015-10-02 16:21:49 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-11 16:01:49 -07:00
										 |  |  | @Directive({selector: 'someDirective', inputs: ['a']}) | 
					
						
							|  |  |  | class SomeDirectiveWithDuplicateInputs { | 
					
						
							|  |  |  |   @Input() a: any; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: 'someDirective', inputs: ['localA: a']}) | 
					
						
							|  |  |  | class SomeDirectiveWithDuplicateRenamedInputs { | 
					
						
							|  |  |  |   @Input() a: any; | 
					
						
							|  |  |  |   localA: any; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | @Directive({selector: 'someDirective'}) | 
					
						
							|  |  |  | class SomeDirectiveWithSetterProps { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   @Input('renamed') | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   set a(value: any) {} | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: 'someDirective'}) | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  | class SomeDirectiveWithGetterOutputs { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   @Output('renamed') | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   get a(): any { return null; } | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  | @Directive({selector: 'someDirective', host: {'[c]': 'c'}}) | 
					
						
							|  |  |  | class SomeDirectiveWithHostBindings { | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   @HostBinding() a: any; | 
					
						
							|  |  |  |   @HostBinding('renamed') b: any; | 
					
						
							|  |  |  |   c: any; | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: 'someDirective', host: {'(c)': 'onC()'}}) | 
					
						
							|  |  |  | class SomeDirectiveWithHostListeners { | 
					
						
							|  |  |  |   @HostListener('a') | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   onA() {} | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  |   @HostListener('b', ['$event.value']) | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   onB(value: any) {} | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | @Directive({selector: 'someDirective', queries: {'cs': new ContentChildren('c')}}) | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  | class SomeDirectiveWithContentChildren { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   @ContentChildren('a') as: any; | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   c: any; | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | @Directive({selector: 'someDirective', queries: {'cs': new ViewChildren('c')}}) | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  | class SomeDirectiveWithViewChildren { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   @ViewChildren('a') as: any; | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   c: any; | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | @Directive({selector: 'someDirective', queries: {'c': new ContentChild('c')}}) | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  | class SomeDirectiveWithContentChild { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   @ContentChild('a') a: any; | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   c: any; | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | @Directive({selector: 'someDirective', queries: {'c': new ViewChild('c')}}) | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  | class SomeDirectiveWithViewChild { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   @ViewChild('a') a: any; | 
					
						
							| 
									
										
										
										
											2016-07-11 15:27:57 -07:00
										 |  |  |   c: any; | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 13:51:45 -07:00
										 |  |  | @Component({selector: 'sample', template: 'some template', styles: ['some styles']}) | 
					
						
							| 
									
										
										
										
											2016-07-28 06:31:26 -07:00
										 |  |  | class ComponentWithTemplate { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-27 16:07:01 -07:00
										 |  |  | @Directive({ | 
					
						
							|  |  |  |   selector: 'someDirective', | 
					
						
							|  |  |  |   host: {'[decorator]': 'decorator'}, | 
					
						
							|  |  |  |   inputs: ['decorator'], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | class SomeDirectiveWithSameHostBindingAndInput { | 
					
						
							|  |  |  |   @Input() @HostBinding() prop: any; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 13:53:53 -07:00
										 |  |  | @Directive({selector: 'someDirective'}) | 
					
						
							|  |  |  | class SomeDirectiveWithMalformedHostBinding1 { | 
					
						
							|  |  |  |   @HostBinding('(a)') | 
					
						
							|  |  |  |   onA() {} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: 'someDirective'}) | 
					
						
							|  |  |  | class SomeDirectiveWithMalformedHostBinding2 { | 
					
						
							|  |  |  |   @HostBinding('[a]') | 
					
						
							|  |  |  |   onA() {} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | class SomeDirectiveWithoutMetadata {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   describe('DirectiveResolver', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |     let resolver: DirectiveResolver; | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     beforeEach(() => { resolver = new DirectiveResolver(); }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should read out the Directive metadata', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |       const directiveMetadata = resolver.resolve(SomeDirective); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |       expect(directiveMetadata) | 
					
						
							| 
									
										
										
										
											2016-09-12 19:14:17 -07:00
										 |  |  |           .toEqual(new Directive( | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |               {selector: 'someDirective', inputs: [], outputs: [], host: {}, queries: {}})); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should throw if not matching metadata is found', () => { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |       expect(() => { | 
					
						
							|  |  |  |         resolver.resolve(SomeDirectiveWithoutMetadata); | 
					
						
							|  |  |  |       }).toThrowError('No Directive annotation found on SomeDirectiveWithoutMetadata'); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should not read parent class Directive metadata', function() { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |       const directiveMetadata = resolver.resolve(SomeChildDirective); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |       expect(directiveMetadata) | 
					
						
							| 
									
										
										
										
											2016-09-12 19:14:17 -07:00
										 |  |  |           .toEqual(new Directive( | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |               {selector: 'someChildDirective', inputs: [], outputs: [], host: {}, queries: {}})); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |     describe('inputs', () => { | 
					
						
							|  |  |  |       it('should append directive inputs', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithInputs); | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |         expect(directiveMetadata.inputs).toEqual(['c', 'a', 'b: renamed']); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should work with getters and setters', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithSetterProps); | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |         expect(directiveMetadata.inputs).toEqual(['a: renamed']); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-10-02 16:21:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-11 16:01:49 -07:00
										 |  |  |       it('should throw if duplicate inputs', () => { | 
					
						
							|  |  |  |         expect(() => { | 
					
						
							|  |  |  |           resolver.resolve(SomeDirectiveWithDuplicateInputs); | 
					
						
							|  |  |  |         }).toThrowError(`Input 'a' defined multiple times in 'SomeDirectiveWithDuplicateInputs'`); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should throw if duplicate inputs (with rename)', () => { | 
					
						
							|  |  |  |         expect(() => { resolver.resolve(SomeDirectiveWithDuplicateRenamedInputs); }) | 
					
						
							|  |  |  |             .toThrowError( | 
					
						
							|  |  |  |                 `Input 'a' defined multiple times in 'SomeDirectiveWithDuplicateRenamedInputs'`); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |     describe('outputs', () => { | 
					
						
							|  |  |  |       it('should append directive outputs', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithOutputs); | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |         expect(directiveMetadata.outputs).toEqual(['c', 'a', 'b: renamed']); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should work with getters and setters', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithGetterOutputs); | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |         expect(directiveMetadata.outputs).toEqual(['a: renamed']); | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-11-04 17:08:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should throw if duplicate outputs', () => { | 
					
						
							|  |  |  |         expect(() => { resolver.resolve(SomeDirectiveWithDuplicateOutputs); }) | 
					
						
							|  |  |  |             .toThrowError( | 
					
						
							|  |  |  |                 `Output event 'a' defined multiple times in 'SomeDirectiveWithDuplicateOutputs'`); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2016-07-11 16:01:49 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should throw if duplicate outputs (with rename)', () => { | 
					
						
							|  |  |  |         expect(() => { resolver.resolve(SomeDirectiveWithDuplicateRenamedOutputs); }) | 
					
						
							|  |  |  |             .toThrowError( | 
					
						
							|  |  |  |                 `Output event 'a' defined multiple times in 'SomeDirectiveWithDuplicateRenamedOutputs'`); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe('host', () => { | 
					
						
							|  |  |  |       it('should append host bindings', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithHostBindings); | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  |         expect(directiveMetadata.host).toEqual({'[c]': 'c', '[a]': 'a', '[renamed]': 'b'}); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-27 16:07:01 -07:00
										 |  |  |       it('should append host binding and input on the same property', () => { | 
					
						
							|  |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithSameHostBindingAndInput); | 
					
						
							|  |  |  |         expect(directiveMetadata.host).toEqual({'[decorator]': 'decorator', '[prop]': 'prop'}); | 
					
						
							|  |  |  |         expect(directiveMetadata.inputs).toEqual(['decorator', 'prop']); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  |       it('should append host listeners', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithHostListeners); | 
					
						
							| 
									
										
										
										
											2015-09-04 14:07:16 -07:00
										 |  |  |         expect(directiveMetadata.host) | 
					
						
							|  |  |  |             .toEqual({'(c)': 'onC()', '(a)': 'onA()', '(b)': 'onB($event.value)'}); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2016-10-07 13:53:53 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should throw when @HostBinding name starts with "("', () => { | 
					
						
							|  |  |  |         expect(() => resolver.resolve(SomeDirectiveWithMalformedHostBinding1)) | 
					
						
							|  |  |  |             .toThrowError('@HostBinding can not bind to events. Use @HostListener instead.'); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should throw when @HostBinding name starts with "["', () => { | 
					
						
							|  |  |  |         expect(() => resolver.resolve(SomeDirectiveWithMalformedHostBinding2)) | 
					
						
							|  |  |  |             .toThrowError( | 
					
						
							|  |  |  |                 `@HostBinding parameter should be a property name, 'class.<name>', or 'attr.<name>'.`); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     describe('queries', () => { | 
					
						
							|  |  |  |       it('should append ContentChildren', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithContentChildren); | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  |         expect(directiveMetadata.queries) | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |             .toEqual({'cs': new ContentChildren('c'), 'as': new ContentChildren('a')}); | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should append ViewChildren', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithViewChildren); | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  |         expect(directiveMetadata.queries) | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |             .toEqual({'cs': new ViewChildren('c'), 'as': new ViewChildren('a')}); | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should append ContentChild', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithContentChild); | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |         expect(directiveMetadata.queries) | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |             .toEqual({'c': new ContentChild('c'), 'a': new ContentChild('a')}); | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should append ViewChild', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const directiveMetadata = resolver.resolve(SomeDirectiveWithViewChild); | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |         expect(directiveMetadata.queries) | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |             .toEqual({'c': new ViewChild('c'), 'a': new ViewChild('a')}); | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:49 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2016-07-28 06:31:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |     describe('Component', () => { | 
					
						
							| 
									
										
										
										
											2016-07-28 06:31:26 -07:00
										 |  |  |       it('should read out the template related metadata from the Component metadata', () => { | 
					
						
							| 
									
										
										
										
											2016-09-27 15:41:37 -07:00
										 |  |  |         const compMetadata: Component = resolver.resolve(ComponentWithTemplate); | 
					
						
							| 
									
										
										
										
											2016-07-28 06:31:26 -07:00
										 |  |  |         expect(compMetadata.template).toEqual('some template'); | 
					
						
							|  |  |  |         expect(compMetadata.styles).toEqual(['some styles']); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-09-03 15:10:48 -07:00
										 |  |  |   }); | 
					
						
							|  |  |  | } |