|
1 | | -import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, el} from 'angular2/test_lib'; |
| 1 | +import { |
| 2 | + ddescribe, |
| 3 | + describe, |
| 4 | + it, |
| 5 | + iit, |
| 6 | + xit, |
| 7 | + expect, |
| 8 | + beforeEach, |
| 9 | + afterEach, |
| 10 | + el |
| 11 | +} from 'angular2/test_lib'; |
2 | 12 | import {Control, FormBuilder, Validators} from 'angular2/forms'; |
3 | 13 |
|
4 | 14 | export function main() { |
5 | 15 | describe("Form Builder", () => { |
6 | 16 | var b; |
7 | 17 |
|
8 | | - beforeEach(() => { |
9 | | - b = new FormBuilder(); |
10 | | - }); |
| 18 | + beforeEach(() => { b = new FormBuilder(); }); |
11 | 19 |
|
12 | 20 | it("should create controls from a value", () => { |
13 | | - var g = b.group({ |
14 | | - "login": "some value" |
15 | | - }); |
| 21 | + var g = b.group({"login": "some value"}); |
16 | 22 |
|
17 | 23 | expect(g.controls["login"].value).toEqual("some value"); |
18 | 24 | }); |
19 | 25 |
|
20 | 26 | it("should create controls from an array", () => { |
21 | | - var g = b.group({ |
22 | | - "login": ["some value"], |
23 | | - "password": ["some value", Validators.required] |
24 | | - }); |
| 27 | + var g = b.group({"login": ["some value"], "password": ["some value", Validators.required]}); |
25 | 28 |
|
26 | 29 | expect(g.controls["login"].value).toEqual("some value"); |
27 | 30 | expect(g.controls["password"].value).toEqual("some value"); |
28 | 31 | expect(g.controls["password"].validator).toEqual(Validators.required); |
29 | 32 | }); |
30 | 33 |
|
31 | 34 | it("should use controls", () => { |
32 | | - var g = b.group({ |
33 | | - "login": b.control("some value", Validators.required) |
34 | | - }); |
| 35 | + var g = b.group({"login": b.control("some value", Validators.required)}); |
35 | 36 |
|
36 | 37 | expect(g.controls["login"].value).toEqual("some value"); |
37 | 38 | expect(g.controls["login"].validator).toBe(Validators.required); |
38 | 39 | }); |
39 | 40 |
|
40 | 41 | it("should create groups with optional controls", () => { |
41 | | - var g = b.group({ |
42 | | - "login": "some value" |
43 | | - }, {"optionals": {"login" : false}}); |
| 42 | + var g = b.group({"login": "some value"}, {"optionals": {"login": false}}); |
44 | 43 |
|
45 | 44 | expect(g.contains("login")).toEqual(false); |
46 | 45 | }); |
47 | 46 |
|
48 | 47 | it("should create groups with a custom validator", () => { |
49 | | - var g = b.group({ |
50 | | - "login": "some value" |
51 | | - }, {"validator": Validators.nullValidator}); |
| 48 | + var g = b.group({"login": "some value"}, {"validator": Validators.nullValidator}); |
52 | 49 |
|
53 | 50 | expect(g.validator).toBe(Validators.nullValidator); |
54 | 51 | }); |
55 | 52 |
|
56 | 53 | it("should use default validators when no validators are provided", () => { |
57 | | - var g = b.group({ |
58 | | - "login": "some value" |
59 | | - }); |
| 54 | + var g = b.group({"login": "some value"}); |
60 | 55 | expect(g.controls["login"].validator).toBe(Validators.nullValidator); |
61 | 56 | expect(g.validator).toBe(Validators.group); |
62 | 57 | }); |
63 | 58 |
|
64 | 59 | it("should create control arrays", () => { |
65 | 60 | var c = b.control("three"); |
66 | | - var a = b.array([ |
67 | | - "one", |
68 | | - ["two", Validators.required], |
69 | | - c, |
70 | | - b.array(['four']) |
71 | | - ]); |
| 61 | + var a = b.array(["one", ["two", Validators.required], c, b.array(['four'])]); |
72 | 62 |
|
73 | 63 | expect(a.value).toEqual(['one', 'two', 'three', ['four']]); |
74 | 64 | }); |
75 | 65 | }); |
76 | 66 | } |
77 | | - |
0 commit comments