aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/main/resources/elasticsearch/plugins/head/src/app/ui/checkField/checkFieldSpec.js
blob: 26ddc6f63ebc849302350e5a3049410b64a2f787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 );
	});

});