angular/packages/animations/browser/test/shared.ts
Joey Perrott 9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00

36 lines
1.3 KiB
TypeScript

/**
* @license
* Copyright Google LLC 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.dev/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';
import {NoopAnimationStyleNormalizer} from '../src/dsl/style_normalization/animation_style_normalizer';
import {triggerParsingFailed} from '../src/error_helpers';
import {triggerParsingWarnings} from '../src/warning_helpers';
import {MockAnimationDriver} from '../testing/src/mock_animation_driver';
export function makeTrigger(
name: string,
steps: any,
skipErrors: boolean = false,
): AnimationTrigger {
const driver = new MockAnimationDriver();
const errors: Error[] = [];
const warnings: string[] = [];
const triggerData = trigger(name, steps);
const triggerAst = buildAnimationAst(driver, triggerData, errors, warnings) as TriggerAst;
if (!skipErrors && errors.length) {
throw triggerParsingFailed(name, errors);
}
if (warnings.length) {
triggerParsingWarnings(name, warnings);
}
return buildTrigger(name, triggerAst, new NoopAnimationStyleNormalizer());
}