1 describe("app.ui.CheckField", function() {
3 var CheckField = window.app.ui.CheckField;
5 it("should have a label", function() {
6 expect( ( new CheckField({ label: "foo" }) ).label ).toBe( "foo" );
9 it("should have a name", function() {
10 expect( ( new CheckField({ name: "foo" }) ).name ).toBe( "foo" );
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 );
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 );
21 it("should be valid if the field value is true", function() {
22 expect( ( new CheckField({ name: "foo", value: true }) ).validate() ).toBe( true );
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 );
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 );