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