26ddc6f63ebc849302350e5a3049410b64a2f787
[ccsdk/features.git] / sdnr / wt / devicemanager / provider / src / main / resources / elasticsearch / plugins / head / src / app / ui / checkField / checkFieldSpec.js
1 describe("app.ui.CheckField", function() {
2
3         var CheckField = window.app.ui.CheckField;
4
5         it("should have a label", function() {
6                 expect( ( new CheckField({ label: "foo" }) ).label ).toBe( "foo" );
7         });
8
9         it("should have a name", function() {
10                 expect( ( new CheckField({ name: "foo" }) ).name ).toBe( "foo" );
11         });
12
13         it("should have a val that is false when then field is not checked", function() {
14                 expect( ( new CheckField({ name: "foo", value: false }) ).val() ).toBe( false );
15         });
16
17         it("should have a val that is true when the field is checked", function() {
18                 expect( ( new CheckField({ name: "foo", value: true }) ).val() ).toBe( true );
19         });
20
21         it("should be valid if the field value is true", function() {
22                 expect( ( new CheckField({ name: "foo", value: true }) ).validate() ).toBe( true );
23         });
24
25         it("should be valid if require is false", function() {
26                 expect( ( new CheckField({ name: "foo", require: false, value: true }) ).validate() ).toBe( true );
27                 expect( ( new CheckField({ name: "foo", require: false, value: false }) ).validate() ).toBe( true );
28         });
29
30         it("should be invalid if require is true and value is false", function() {
31                 expect( ( new CheckField({ name: "foo", require: true, value: false }) ).validate() ).toBe( false );
32         });
33
34 });