feat(form): implemented an imperative way of updating the view by updating the value of a control

This commit is contained in:
vsavkin
2015-06-01 10:41:50 -07:00
parent 559f54e92b
commit 652ed0cf6d
9 changed files with 145 additions and 75 deletions

View File

@ -114,6 +114,30 @@ export function main() {
});
}));
it("should update DOM elements when updating the value of a control",
inject([TestBed, AsyncTestCompleter], (tb, async) => {
var login = new Control("oldValue");
var form = new ControlGroup({"login": login});
var ctx = MyComp.create({form: form});
var t = `<div [form-model]="form">
<input type="text" control="login">
</div>`;
tb.createView(MyComp, {context: ctx, html: t})
.then((view) => {
view.detectChanges();
login.updateValue("newValue");
view.detectChanges();
var input = view.querySelector("input");
expect(input.value).toEqual("newValue");
async.done();
});
}));
describe("different control types", () => {
it("should support <input type=text>", inject([TestBed, AsyncTestCompleter], (tb, async) => {
var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})});