feat(forms): improved error messages

Closes #1839
This commit is contained in:
vsavkin
2015-05-11 12:00:56 -07:00
committed by Misko Hevery
parent ad29b12cde
commit 11e4385173
3 changed files with 62 additions and 32 deletions
+26
View File
@@ -0,0 +1,26 @@
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, el,
AsyncTestCompleter, inject} from 'angular2/test_lib';
import {ControlGroup, ControlDirective, ControlGroupDirective} from 'angular2/forms';
export function main() {
describe("Form Directives", () => {
describe("Control", () => {
it("should throw when the group is not found and the control is not set", () => {
var c = new ControlDirective(null, null);
expect(() => {
c.controlOrName = 'login';
}).toThrowError(new RegExp('No control group found for "login"'));
});
it("should throw when cannot find the control in the group", () => {
var emptyGroup = new ControlGroupDirective(null);
emptyGroup.controlOrName = new ControlGroup({});
var c = new ControlDirective(emptyGroup, null);
expect(() => {
c.controlOrName = 'login';
}).toThrowError(new RegExp('Cannot find control "login"'));
});
});
});
}