feat(change_detector): add support for method calls

This commit is contained in:
vsavkin
2014-11-11 16:54:15 -08:00
parent dcd905ae85
commit 4e38e3a96c
4 changed files with 77 additions and 18 deletions

View File

@ -69,6 +69,22 @@ export function main() {
.toEqual(['address.city=Grenoble']);
});
it("should support method calls", () => {
var person = new Person('Victor');
expect(executeWatch('m', 'sayHi("Jim")', person)).toEqual(['m=Hi, Jim']);
});
it("should support function calls", () => {
var td = new TestData(() => (a) => a);
expect(executeWatch('value', 'a()(99)', td)).toEqual(['value=99']);
});
it("should support chained method calls", () => {
var person = new Person('Victor');
var td = new TestData(person);
expect(executeWatch('m', 'a.sayHi("Jim")', td)).toEqual(['m=Hi, Jim']);
});
it("should support literals", () => {
expect(executeWatch('const', '10')).toEqual(['const=10']);
});
@ -123,6 +139,10 @@ class Person {
this.address = address;
}
sayHi(m) {
return `Hi, ${m}`;
}
toString():string {
var address = this.address == null ? '' : ' address=' + this.address.toString();
@ -140,6 +160,12 @@ class Address {
}
}
class TestData {
constructor(a) {
this.a = a;
}
}
class LoggingDispatcher extends WatchGroupDispatcher {
constructor() {
this.log = null;