From 2d313c4d1d0aab3668ca89119cfe469d7553702f Mon Sep 17 00:00:00 2001 From: Yegor Jbanov Date: Sat, 5 Dec 2015 22:06:24 -0800 Subject: [PATCH] chore(parser): add tests for conditional expressions Closes #5647 --- .../test/core/change_detection/parser/parser_spec.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/angular2/test/core/change_detection/parser/parser_spec.ts b/modules/angular2/test/core/change_detection/parser/parser_spec.ts index b13d9c4ca4..be9f8fc6a6 100644 --- a/modules/angular2/test/core/change_detection/parser/parser_spec.ts +++ b/modules/angular2/test/core/change_detection/parser/parser_spec.ts @@ -31,6 +31,12 @@ export function main() { function unparse(ast: AST): string { return new Unparser().unparse(ast); } + function checkInterpolation(exp: string, expected?: string) { + var ast = parseInterpolation(exp); + if (isBlank(expected)) expected = exp; + expect(unparse(ast)).toEqual(expected); + } + function checkBinding(exp: string, expected?: string) { var ast = parseBinding(exp); if (isBlank(expected)) expected = exp; @@ -262,6 +268,8 @@ export function main() { expectBindingError("{{a.b}}") .toThrowErrorWith('Got interpolation ({{}}) where expression was expected'); }); + + it('should parse conditional expression', () => { checkBinding('a < b ? a : b'); }); }); describe('parseTemplateBindings', () => { @@ -410,6 +418,9 @@ export function main() { .toThrowErrorWith( "Parser Error: Blank expressions are not allowed in interpolated strings"); }); + + it('should parse conditional expression', + () => { checkInterpolation('{{ a < b ? a : b }}'); }); }); describe("parseSimpleBinding", () => {