| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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-09-12 19:14:17 -07:00
										 |  |  | import {Injector, Pipe} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2017-05-18 13:46:51 -07:00
										 |  |  | import {inject} from '@angular/core/testing'; | 
					
						
							| 
									
										
										
										
											2017-08-16 09:00:03 -07:00
										 |  |  | import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_reflector'; | 
					
						
							| 
									
										
										
										
											2017-05-18 13:46:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-02 12:12:46 -08:00
										 |  |  | import {MockPipeResolver} from '../testing'; | 
					
						
							| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-16 14:42:55 -08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  |   describe('MockPipeResolver', () => { | 
					
						
							| 
									
										
										
										
											2016-11-12 14:08:58 +01:00
										 |  |  |     let pipeResolver: MockPipeResolver; | 
					
						
							| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-18 13:46:51 -07:00
										 |  |  |     beforeEach(inject([Injector], (injector: Injector) => { | 
					
						
							| 
									
										
										
										
											2017-08-16 09:00:03 -07:00
										 |  |  |       pipeResolver = new MockPipeResolver(new JitReflector()); | 
					
						
							| 
									
										
										
										
											2017-05-18 13:46:51 -07:00
										 |  |  |     })); | 
					
						
							| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     describe('Pipe overriding', () => { | 
					
						
							|  |  |  |       it('should fallback to the default PipeResolver when templates are not overridden', () => { | 
					
						
							| 
									
										
										
										
											2016-11-12 14:08:58 +01:00
										 |  |  |         const pipe = pipeResolver.resolve(SomePipe); | 
					
						
							| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  |         expect(pipe.name).toEqual('somePipe'); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should allow overriding the @Pipe', () => { | 
					
						
							| 
									
										
										
										
											2016-09-12 19:14:17 -07:00
										 |  |  |         pipeResolver.setPipe(SomePipe, new Pipe({name: 'someOtherName'})); | 
					
						
							| 
									
										
										
										
											2016-11-12 14:08:58 +01:00
										 |  |  |         const pipe = pipeResolver.resolve(SomePipe); | 
					
						
							| 
									
										
										
										
											2016-07-28 06:40:50 -07:00
										 |  |  |         expect(pipe.name).toEqual('someOtherName'); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Pipe({name: 'somePipe'}) | 
					
						
							|  |  |  | class SomePipe { | 
					
						
							|  |  |  | } |