diff --git a/modules/change_detection/src/watch_group.js b/modules/change_detection/src/watch_group.js index cc4ff4e3df..7d59d00ae8 100644 --- a/modules/change_detection/src/watch_group.js +++ b/modules/change_detection/src/watch_group.js @@ -48,15 +48,6 @@ export class ProtoWatchGroup { return watchGroup; } - /** - * Sets the context (the object) on which the change detection expressions will - * dereference themselves on. Since the WatchGroup can be reused the context - * can be re-set many times during the lifetime of the WatchGroup. - * - * @param context the new context for change dection for the curren WatchGroup - */ - setContext(context) { - } } export class WatchGroup { @@ -79,6 +70,15 @@ export class WatchGroup { /// IMPLEMENT } + /** + * Sets the context (the object) on which the change detection expressions will + * dereference themselves on. Since the WatchGroup can be reused the context + * can be re-set many times during the lifetime of the WatchGroup. + * + * @param context the new context for change dection for the curren WatchGroup + */ + setContext(context) { + } } export class WatchGroupDispatcher { diff --git a/modules/change_detection/test/change_detection_spec.js b/modules/change_detection/test/change_detection_spec.js new file mode 100644 index 0000000000..cea4d8c373 --- /dev/null +++ b/modules/change_detection/test/change_detection_spec.js @@ -0,0 +1,42 @@ +import {describe, it, expect} from 'test_lib/test_lib'; +import {ProtoWatchGroup, WatchGroup, WatchGroupDispatcher} from 'change_detection/watch_group'; +import {DOM} from 'facade/dom'; + + +export function main() { + describe('change_detection', function() { + describe('ChangeDetection', function() { + it('should do simple watching', function() { + return; // remove me after getting the test to pass. + var person = new Person('misko', 38); + var pwg = new ProtoWatchGroup(); + pwg.watch('name', 'nameToken'); + pwg.watch('age', 'ageToken'); + var dispatcher = new LoggingDispatcher(); + var wg = pwg.instantiate(dispatcher); + wg.setContext(person); + var cd = new ChangeDetection(wg); + cd.detectChanges(); + expect(dispatcher.log).toEqual(['ageToken=38']); + dispatcher.clear(); + cd.detectChanges(); + expect(dispatcher.log).toEqual([]); + person.age=1; + person.name="Misko"; + cd.detectChanges(); + expect(dispatcher.log).toEqual(['nameToken=Misko', 'ageToken=1']); + }); + }); + }); +} + +class Person { + constructor(name:string, age:number) { + this.name = null; + this.a + } +} + +class Dispatcher extends WatchGroupDispatcher { + +}