2016-06-08 19:38:52 -04:00
|
|
|
import {AnimationMetadata, animate, group, sequence, style, transition, trigger} from '@angular/core';
|
|
|
|
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
2016-05-25 15:46:22 -04:00
|
|
|
|
|
|
|
import {AnimationCompiler, CompiledAnimation} from '../../src/animation/animation_compiler';
|
2016-06-08 19:38:52 -04:00
|
|
|
import {CompileDirectiveMetadata, CompileTemplateMetadata, CompileTypeMetadata} from '../../src/compile_metadata';
|
2016-05-25 15:46:22 -04:00
|
|
|
import {CompileMetadataResolver} from '../../src/metadata_resolver';
|
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('RuntimeAnimationCompiler', () => {
|
2016-06-08 18:45:15 -04:00
|
|
|
var resolver: any /** TODO #9100 */;
|
2016-06-08 19:38:52 -04:00
|
|
|
beforeEach(
|
|
|
|
inject([CompileMetadataResolver], (res: CompileMetadataResolver) => { resolver = res; }));
|
2016-05-25 15:46:22 -04:00
|
|
|
|
|
|
|
var compiler = new AnimationCompiler();
|
|
|
|
|
|
|
|
var compileAnimations = (component: CompileDirectiveMetadata): CompiledAnimation => {
|
|
|
|
return compiler.compileComponent(component)[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
var compile = (seq: AnimationMetadata) => {
|
2016-06-08 19:38:52 -04:00
|
|
|
var entry = trigger('myAnimation', [transition('state1 => state2', seq)]);
|
2016-05-25 15:46:22 -04:00
|
|
|
|
|
|
|
var compiledAnimationEntry = resolver.getAnimationEntryMetadata(entry);
|
|
|
|
var component = CompileDirectiveMetadata.create({
|
2016-06-08 19:38:52 -04:00
|
|
|
type: new CompileTypeMetadata({name: 'something'}),
|
|
|
|
template: new CompileTemplateMetadata({animations: [compiledAnimationEntry]})
|
2016-05-25 15:46:22 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
return compileAnimations(component);
|
|
|
|
};
|
|
|
|
|
|
|
|
it('should throw an exception containing all the inner animation parser errors', () => {
|
|
|
|
var animation = sequence([
|
2016-06-08 19:38:52 -04:00
|
|
|
style({'color': 'red'}), animate(1000, style({'font-size': '100px'})),
|
|
|
|
style({'color': 'blue'}), animate(1000, style(':missing_state')), style({'color': 'gold'}),
|
|
|
|
animate(1000, style('broken_state'))
|
2016-05-25 15:46:22 -04:00
|
|
|
]);
|
|
|
|
|
|
|
|
var capturedErrorMessage: string;
|
|
|
|
try {
|
|
|
|
compile(animation);
|
|
|
|
} catch (e) {
|
|
|
|
capturedErrorMessage = e.message;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(capturedErrorMessage)
|
2016-06-22 17:53:02 -04:00
|
|
|
.toMatch(/Unable to apply styles due to missing a state: "missing_state"/g);
|
2016-05-25 15:46:22 -04:00
|
|
|
|
|
|
|
expect(capturedErrorMessage)
|
2016-06-22 17:53:02 -04:00
|
|
|
.toMatch(/Animation states via styles must be prefixed with a ":"/);
|
2016-05-25 15:46:22 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|