fix(core): resurrect OnChange interface

This commit is contained in:
yjbanov
2015-05-22 13:14:59 -07:00
parent 3525c9c074
commit d48fae3566
3 changed files with 44 additions and 1 deletions
@@ -104,6 +104,24 @@ main() {
});
}));
});
describe('OnChange', () {
it('should be notified of changes',
inject([TestBed, AsyncTestCompleter], (tb, async) {
tb.overrideView(Dummy, new View(
template: '''<on-change [prop]="'hello'"></on-change>''',
directives: [OnChangeComponent]
));
tb.createView(Dummy).then((view) {
view.detectChanges();
var cmp = view.rawView.elementInjectors[0].get(OnChangeComponent);
expect(cmp.prop).toEqual('hello');
expect(cmp.changes.containsKey('prop')).toEqual(true);
async.done();
});
}));
});
}
@Component(selector: 'dummy')
@@ -168,3 +186,20 @@ class PropertyAccess {
class NoPropertyAccess {
final model = new PropModel();
}
@Component(
selector: 'on-change',
// TODO: needed because of https://github.com/angular/angular/issues/2120
lifecycle: const [onChange],
properties: const { 'prop': 'prop' }
)
@View(template: '')
class OnChangeComponent implements OnChange {
Map changes;
String prop;
@override
void onChange(Map changes) {
this.changes = changes;
}
}