import {describe, beforeEach, it, expect, iit, ddescribe, el} from 'angular2/test_lib'; import {IMPLEMENTS} from 'angular2/src/facade/lang'; import {PropertyBindingParser} from 'angular2/src/render/dom/compiler/property_binding_parser'; import {CompilePipeline} from 'angular2/src/render/dom/compiler/compile_pipeline'; import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection'; import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element'; import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step'; import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control'; import {Lexer, Parser} from 'angular2/change_detection'; import {ElementBinderBuilder} from 'angular2/src/render/dom/view/proto_view_builder'; var EMPTY_MAP = new Map(); export function main() { describe('PropertyBindingParser', () => { function createPipeline(hasNestedProtoView = false) { return new CompilePipeline([ new MockStep((parent, current, control) => { if (hasNestedProtoView) { current.bindElement().bindNestedProtoView(el('')); } }), new PropertyBindingParser(new Parser(new Lexer())) ]); } function process(element, hasNestedProtoView = false): List { return ListWrapper.map(createPipeline(hasNestedProtoView).process(element), (compileElement) => compileElement.inheritedElementBinder); } it('should detect [] syntax', () => { var results = process(el('
')); expect(results[0].propertyBindings.get('a').source).toEqual('b'); }); it('should detect [] syntax with data- prefix', () => { var results = process(el('
')); expect(results[0].propertyBindings.get('a').source).toEqual('b'); }); it('should detect [] syntax only if an attribute name starts and ends with []', () => { expect(process(el('
'))[0]).toBe(null); expect(process(el('
'))[0]).toBe(null); }); it('should detect bind- syntax', () => { var results = process(el('
')); expect(results[0].propertyBindings.get('a').source).toEqual('b'); }); it('should detect bind- syntax with data- prefix', () => { var results = process(el('
')); expect(results[0].propertyBindings.get('a').source).toEqual('b'); }); it('should detect bind- syntax only if an attribute name starts with bind', () => { expect(process(el('
'))[0]).toEqual(null); }); it('should detect interpolation syntax', () => { var results = process(el('
')); expect(results[0].propertyBindings.get('a').source).toEqual('{{b}}'); }); it('should detect interpolation syntax with data- prefix', () => { var results = process(el('
')); expect(results[0].propertyBindings.get('a').source).toEqual('{{b}}'); }); it('should store property setters as camel case', () => { var element = el('
'); var results = process(element); expect(results[0].propertyBindings.get('someProp')).toBeTruthy(); }); it('should detect var- syntax', () => { var results = process(el('')); expect(results[0].variableBindings.get('b')).toEqual('a'); }); it('should detect var- syntax with data- prefix', () => { var results = process(el('')); expect(results[0].variableBindings.get('b')).toEqual('a'); }); it('should store variable binding for a template element on the nestedProtoView', () => { var results = process(el('