feat(forms): added pristine and dirty

This commit is contained in:
vsavkin
2015-03-19 10:51:49 -07:00
parent 38b96ed746
commit 8a10edec01
2 changed files with 83 additions and 13 deletions

View File

@ -22,6 +22,32 @@ export function main() {
expect(c.errors).toEqual({"required" : true});
});
});
describe("pristine", () => {
it("should be true after creating a control", () => {
var c = new Control("value");
expect(c.pristine).toEqual(true);
});
it("should be false after changing the value of the control", () => {
var c = new Control("value");
c.updateValue("new value");
expect(c.pristine).toEqual(false);
});
});
describe("dirty", () => {
it("should be false after creating a control", () => {
var c = new Control("value");
expect(c.dirty).toEqual(false);
});
it("should be true after changing the value of the control", () => {
var c = new Control("value");
c.updateValue("new value");
expect(c.dirty).toEqual(true);
});
});
});
describe("ControlGroup", () => {
@ -85,6 +111,23 @@ export function main() {
});
});
describe("pristine", () => {
it("should be true after creating a control", () => {
var c = new Control('value');
var g = new ControlGroup({"one": c});
expect(g.pristine).toEqual(true);
});
it("should be false after changing the value of the control", () => {
var c = new Control('value');
var g = new ControlGroup({"one": c});
c.updateValue('new value');
expect(g.pristine).toEqual(false);
});
});
describe("optional components", () => {
describe("contains", () => {
var group;