diff options
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/test/resources/elasticsearch/plugins/head/src/app/ui/checkField/checkFieldSpec.js')
-rw-r--r-- | sdnr/wt/devicemanager/provider/src/test/resources/elasticsearch/plugins/head/src/app/ui/checkField/checkFieldSpec.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/elasticsearch/plugins/head/src/app/ui/checkField/checkFieldSpec.js b/sdnr/wt/devicemanager/provider/src/test/resources/elasticsearch/plugins/head/src/app/ui/checkField/checkFieldSpec.js new file mode 100644 index 000000000..26ddc6f63 --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/resources/elasticsearch/plugins/head/src/app/ui/checkField/checkFieldSpec.js @@ -0,0 +1,34 @@ +describe("app.ui.CheckField", function() { + + var CheckField = window.app.ui.CheckField; + + it("should have a label", function() { + expect( ( new CheckField({ label: "foo" }) ).label ).toBe( "foo" ); + }); + + it("should have a name", function() { + expect( ( new CheckField({ name: "foo" }) ).name ).toBe( "foo" ); + }); + + it("should have a val that is false when then field is not checked", function() { + expect( ( new CheckField({ name: "foo", value: false }) ).val() ).toBe( false ); + }); + + it("should have a val that is true when the field is checked", function() { + expect( ( new CheckField({ name: "foo", value: true }) ).val() ).toBe( true ); + }); + + it("should be valid if the field value is true", function() { + expect( ( new CheckField({ name: "foo", value: true }) ).validate() ).toBe( true ); + }); + + it("should be valid if require is false", function() { + expect( ( new CheckField({ name: "foo", require: false, value: true }) ).validate() ).toBe( true ); + expect( ( new CheckField({ name: "foo", require: false, value: false }) ).validate() ).toBe( true ); + }); + + it("should be invalid if require is true and value is false", function() { + expect( ( new CheckField({ name: "foo", require: true, value: false }) ).validate() ).toBe( false ); + }); + +});
\ No newline at end of file |