clean(forms): cleanup

This commit is contained in:
vsavkin
2015-02-25 12:54:27 -08:00
parent f27e538e2c
commit cf9cb61665
6 changed files with 32 additions and 34 deletions

View File

@ -51,13 +51,12 @@ export function main() {
});
it("should run the validator with the initial value (invalid)", () => {
var g = new ControlGroup({
"one": new Control(null, validations.required)
});
var one = new Control(null, validations.required);
var g = new ControlGroup({"one": one});
expect(g.valid).toEqual(false);
expect(g.errors).toEqual({"one": {"required" : true}});
expect(g.errors).toEqual({"required": [one]});
});
it("should run the validator with the value changes", () => {

View File

@ -44,25 +44,23 @@ export function main() {
describe("controlGroupValidator", () => {
it("should collect errors from the child controls", () => {
var g = new ControlGroup({
"one" : new Control("one", validator("a", true)),
"two" : new Control("two", validator("b", true))
});
var one = new Control("one", validator("a", true));
var two = new Control("one", validator("b", true));
var g = new ControlGroup({"one" : one, "two" : two});
expect(controlGroupValidator(g)).toEqual({
"one" : {"a" : true},
"two" : {"b" : true}
"a" : [one],
"b" : [two]
});
});
it("should not include keys for controls that have no errors", () => {
var g = new ControlGroup({
"one" : new Control("one", validator("a", true)),
"two" : new Control("one")
});
it("should not include controls that have no errors", () => {
var one = new Control("one", validator("a", true));
var two = new Control("two");
var g = new ControlGroup({"one" : one, "two" : two});
expect(controlGroupValidator(g)).toEqual({
"one" : {"a" : true}
"a": [one]
});
});