feat(forms): add optional controls

This commit is contained in:
vsavkin
2015-02-24 11:59:10 -08:00
parent a73c643322
commit f27e538e2c
7 changed files with 220 additions and 41 deletions

View File

@ -1,5 +1,5 @@
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, el} from 'angular2/test_lib';
import {ControlGroup, Control, required, compose, controlGroupValidator} from 'angular2/forms';
import {ControlGroup, Control, required, compose, controlGroupValidator, nullValidator} from 'angular2/forms';
export function main() {
function validator(key:string, error:any){
@ -35,6 +35,11 @@ export function main() {
var c = compose([validator("a", 1), validator("a", 2)]);
expect(c(new Control(""))).toEqual({"a" : 2});
});
it("should return null when no errors", () => {
var c = compose([nullValidator, nullValidator]);
expect(c(new Control(""))).toEqual(null);
});
});
describe("controlGroupValidator", () => {