| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {trigger} from '@angular/animations'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {TriggerAst} from '../src/dsl/animation_ast'; | 
					
						
							|  |  |  | import {buildAnimationAst} from '../src/dsl/animation_ast_builder'; | 
					
						
							|  |  |  | import {AnimationTrigger, buildTrigger} from '../src/dsl/animation_trigger'; | 
					
						
							| 
									
										
										
										
											2017-08-15 16:11:11 -07:00
										 |  |  | import {MockAnimationDriver} from '../testing/src/mock_animation_driver'; | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function makeTrigger( | 
					
						
							|  |  |  |     name: string, steps: any, skipErrors: boolean = false): AnimationTrigger { | 
					
						
							| 
									
										
										
										
											2017-08-15 16:11:11 -07:00
										 |  |  |   const driver = new MockAnimationDriver(); | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   const errors: any[] = []; | 
					
						
							|  |  |  |   const triggerData = trigger(name, steps); | 
					
						
							| 
									
										
										
										
											2017-08-15 16:11:11 -07:00
										 |  |  |   const triggerAst = buildAnimationAst(driver, triggerData, errors) as TriggerAst; | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   if (!skipErrors && errors.length) { | 
					
						
							|  |  |  |     const LINE_START = '\n - '; | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  |     throw new Error(`Animation parsing for the ${name} trigger have failed:${LINE_START}${ | 
					
						
							|  |  |  |         errors.join(LINE_START)}`);
 | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   } | 
					
						
							|  |  |  |   return buildTrigger(name, triggerAst); | 
					
						
							|  |  |  | } |