feat(forms): added pristine and dirty
This commit is contained in:
43
modules/angular2/test/forms/model_spec.js
vendored
43
modules/angular2/test/forms/model_spec.js
vendored
@ -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;
|
||||
|
Reference in New Issue
Block a user