From c7f574174dcbd02466f3c27eb66b9fa48212cb27 Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Thu, 7 Mar 2013 21:42:06 +0100 Subject: [PATCH 1/9] initial input-text tests --- test/input-text/input-text-spec.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/test/input-text/input-text-spec.js b/test/input-text/input-text-spec.js index 03a5331..97b9a41 100644 --- a/test/input-text/input-text-spec.js +++ b/test/input-text/input-text-spec.js @@ -9,8 +9,33 @@ TestPageLoader.queueTest("input-text-test", function(testPage) { }); describe("InputText", function() { - it("can be created", function() { - expect(testPage.test.inputText).toBeDefined(); + describe("default", function () { + it("can be created", function() { + expect(testPage.test.inputText).toBeDefined(); + }); + var inputText, defaultValue; + beforeEach(function() { + if (!inputText) { + inputText = testPage.test.inputText; + //keep default values + defaultValue = inputText.value; + } + //restore default values + inputText.value = defaultValue; + }); + describe("property", function() { + describe("value", function() { + it("TODO should have correct default", function() { + expect(defaultValue).toEqual(""); + }); + it("can be set", function() { + inputText.value = "a string"; + expect(inputText.value).toEqual("a string"); + }); + describe("behavior", function() { + }); + }); + }); }); }); }); From 29cf28909302f08c8519d28a3f9022d31ec6cf82 Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Thu, 7 Mar 2013 23:34:05 +0100 Subject: [PATCH 2/9] initial textarea tests --- test/textarea/textarea-spec.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/textarea/textarea-spec.js b/test/textarea/textarea-spec.js index 1814e41..0fdcee3 100644 --- a/test/textarea/textarea-spec.js +++ b/test/textarea/textarea-spec.js @@ -9,8 +9,31 @@ TestPageLoader.queueTest("textarea-test", function(testPage) { }); describe("Textarea", function() { - it("can be created", function() { - expect(testPage.test.textarea).toBeDefined(); + describe("default", function () { + it("can be created", function() { + expect(testPage.test.textarea).toBeDefined(); + }); + var textarea, defaultValue; + beforeEach(function() { + if (!textarea) { + textarea = testPage.test.textarea; + //keep default values + defaultValue = textarea.value; + } + //restore default values + textarea.value = defaultValue; + }); + describe("property", function() { + describe("value", function() { + it("should have correct default", function() { + expect(defaultValue).toEqual(""); + }); + it("can be set", function() { + textarea.value = "a string"; + expect(textarea.value).toEqual("a string"); + }); + }); + }); }); }); }); From 706c11fbd4e6f541516de52891e86a21bae3336b Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Thu, 7 Mar 2013 23:34:22 +0100 Subject: [PATCH 3/9] initial toggle tests --- test/toggle/toggle-spec.js | 41 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/toggle/toggle-spec.js b/test/toggle/toggle-spec.js index c226f29..fd88971 100644 --- a/test/toggle/toggle-spec.js +++ b/test/toggle/toggle-spec.js @@ -9,8 +9,45 @@ TestPageLoader.queueTest("toggle-test", function(testPage) { }); describe("Toggle", function() { - it("can be created", function() { - expect(testPage.test.toggle).toBeDefined(); + describe("default", function () { + it("can be created", function() { + expect(testPage.test.toggle).toBeDefined(); + }); + var toggle, defaultChecked; + beforeEach(function() { + if (!toggle) { + toggle = testPage.test.toggle; + //keep default values + defaultChecked = toggle.checked; + } + //restore default values + toggle.checked = defaultChecked; + }); + describe("property", function() { + describe("checked", function() { + it("TODO should have correct default", function() { + expect(defaultChecked).toEqual(false); + }); + it("can be set", function() { + toggle.checked = true; + expect(toggle.checked).toEqual(true); + }); + }); + }); + describe("interaction", function () { + describe("press", function () { + it("TODO should check toggle if not already checked", function () { + toggle.checked = false; + toggle.handlePress(); + expect(toggle.checked).toEqual(true); + }); + it("TODO should uncheck toggle if already checked", function () { + toggle.checked = true; + toggle.handlePress(); + expect(toggle.checked).toEqual(false); + }); + }); + }); }); }); }); From 48d8f9e76a3d4bcaf6a9121702da2ae7b0181670 Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Mon, 11 Mar 2013 14:03:04 +0100 Subject: [PATCH 4/9] Add tests for 'required' attribute and initialization attributes to inputText --- test/input-text/input-text-spec.js | 33 ++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/test/input-text/input-text-spec.js b/test/input-text/input-text-spec.js index 97b9a41..5ff596e 100644 --- a/test/input-text/input-text-spec.js +++ b/test/input-text/input-text-spec.js @@ -13,15 +13,17 @@ TestPageLoader.queueTest("input-text-test", function(testPage) { it("can be created", function() { expect(testPage.test.inputText).toBeDefined(); }); - var inputText, defaultValue; + var inputText, defaultValue, defaultRequired; beforeEach(function() { if (!inputText) { inputText = testPage.test.inputText; //keep default values defaultValue = inputText.value; + defaultRequired = inputText.required; } //restore default values inputText.value = defaultValue; + inputText.required = defaultRequired; }); describe("property", function() { describe("value", function() { @@ -32,11 +34,38 @@ TestPageLoader.queueTest("input-text-test", function(testPage) { inputText.value = "a string"; expect(inputText.value).toEqual("a string"); }); - describe("behavior", function() { + }); + describe("required", function() { + it("TODO should have correct default", function() { + expect(defaultRequired).toEqual(false); + }); + it("TODO can be set", function() { + inputText.required = true; + expect(inputText.required).toEqual(true); }); }); }); }); + describe("initialization attributes", function () { + var inputText, defaultValue, defaultRequired; + beforeEach(function() { + if (!inputText) { + inputText = testPage.test.inputTextWithAttributes; + //keep default values + defaultValue = inputText.value; + defaultRequired = inputText.required; + } + //restore default values + inputText.value = defaultValue; + inputText.required = defaultRequired; + }); + it("TODO should have expected value property value", function () { + expect(inputText.value).toEqual("a string"); + }); + it("TODO should have expected required property value", function () { + expect(inputText.required).toEqual(true); + }); + }); }); }); }); From 5cea64536e09b998646dfa677b16b9913283587b Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Mon, 11 Mar 2013 14:26:15 +0100 Subject: [PATCH 5/9] Add tests for required and maxLength for inputText --- test/input-text/input-text-spec.js | 20 ++++++++++++++++++-- test/input-text/input-text-test.html | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/test/input-text/input-text-spec.js b/test/input-text/input-text-spec.js index 5ff596e..911024d 100644 --- a/test/input-text/input-text-spec.js +++ b/test/input-text/input-text-spec.js @@ -13,17 +13,19 @@ TestPageLoader.queueTest("input-text-test", function(testPage) { it("can be created", function() { expect(testPage.test.inputText).toBeDefined(); }); - var inputText, defaultValue, defaultRequired; + var inputText, defaultValue, defaultRequired, defaultMaxLength; beforeEach(function() { if (!inputText) { inputText = testPage.test.inputText; //keep default values defaultValue = inputText.value; defaultRequired = inputText.required; + defaultMaxLength = inputText.maxLength; } //restore default values inputText.value = defaultValue; inputText.required = defaultRequired; + inputText.maxLength = defaultMaxLength; }); describe("property", function() { describe("value", function() { @@ -44,20 +46,31 @@ TestPageLoader.queueTest("input-text-test", function(testPage) { expect(inputText.required).toEqual(true); }); }); + describe("maxLength", function() { + it("TODO should have correct default", function() { + expect(defaultMaxLength).toEqual(-1); + }); + it("TODO can be set", function() { + inputText.maxLength = 12; + expect(inputText.maxLength).toEqual(12); + }); + }); }); }); describe("initialization attributes", function () { - var inputText, defaultValue, defaultRequired; + var inputText, defaultValue, defaultRequired, defaultMaxLength; beforeEach(function() { if (!inputText) { inputText = testPage.test.inputTextWithAttributes; //keep default values defaultValue = inputText.value; defaultRequired = inputText.required; + defaultMaxLength = inputText.maxLength; } //restore default values inputText.value = defaultValue; inputText.required = defaultRequired; + inputText.maxLength = defaultMaxLength; }); it("TODO should have expected value property value", function () { expect(inputText.value).toEqual("a string"); @@ -65,6 +78,9 @@ TestPageLoader.queueTest("input-text-test", function(testPage) { it("TODO should have expected required property value", function () { expect(inputText.required).toEqual(true); }); + it("TODO should have expected maxLength property value", function () { + expect(inputText.maxLength).toEqual(7); + }); }); }); }); diff --git a/test/input-text/input-text-test.html b/test/input-text/input-text-test.html index 15ba409..a495ed9 100644 --- a/test/input-text/input-text-test.html +++ b/test/input-text/input-text-test.html @@ -27,5 +27,6 @@

InputText

+ From 7408325c04faf3a7258064a1db0c7a2e069e3147 Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Mon, 11 Mar 2013 14:31:50 +0100 Subject: [PATCH 6/9] Add tests for required, maxLength for textarea --- test/textarea/textarea-spec.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/textarea/textarea-spec.js b/test/textarea/textarea-spec.js index 0fdcee3..48bcf04 100644 --- a/test/textarea/textarea-spec.js +++ b/test/textarea/textarea-spec.js @@ -13,15 +13,19 @@ TestPageLoader.queueTest("textarea-test", function(testPage) { it("can be created", function() { expect(testPage.test.textarea).toBeDefined(); }); - var textarea, defaultValue; + var textarea, defaultValue, defaultRequired, defaultMaxLength; beforeEach(function() { if (!textarea) { textarea = testPage.test.textarea; //keep default values defaultValue = textarea.value; + defaultRequired = textarea.required; + defaultMaxLength = textarea.maxLength; } //restore default values textarea.value = defaultValue; + textarea.required = defaultRequired; + textarea.maxLength = defaultMaxLength; }); describe("property", function() { describe("value", function() { @@ -33,6 +37,24 @@ TestPageLoader.queueTest("textarea-test", function(testPage) { expect(textarea.value).toEqual("a string"); }); }); + describe("required", function() { + it("TODO should have correct default", function() { + expect(defaultRequired).toEqual(false); + }); + it("TODO can be set", function() { + textarea.required = true; + expect(textarea.required).toEqual(true); + }); + }); + describe("maxLength", function() { + it("TODO should have correct default", function() { + expect(defaultMaxLength).toEqual(-1); + }); + it("TODO can be set", function() { + textarea.maxLength = 400; + expect(textarea.maxLength).toEqual(400); + }); + }); }); }); }); From 6e40e6e521d97c84796cd1bd699194744e8bc3b5 Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Mon, 11 Mar 2013 14:34:54 +0100 Subject: [PATCH 7/9] Fix element name --- test/input-text/input-text-test.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/input-text/input-text-test.html b/test/input-text/input-text-test.html index a495ed9..f58b8b8 100644 --- a/test/input-text/input-text-test.html +++ b/test/input-text/input-text-test.html @@ -9,7 +9,8 @@ "test": { "prototype": "test/input-text/input-text-test[Test]", "properties": { - "inputText": {"@": "inputText"} + "inputText": {"@": "inputText"}, + "inputTextWithAttributes": {"@": "inputTextWithAttributes"} } }, @@ -18,6 +19,13 @@ "properties": { "element": {"#": "inputText"} } + }, + + "inputTextWithAttributes": { + "prototype": "input-text.reel", + "properties": { + "element": {"#": "inputTextWithAttributes"} + } } } @@ -27,6 +35,6 @@

InputText

- + From 039ebabfd984f60d3e321b0978348bcc5ba718d1 Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Mon, 11 Mar 2013 14:37:32 +0100 Subject: [PATCH 8/9] Add tests for initialization attributes for textarea --- test/textarea/textarea-spec.js | 25 +++++++++++++++++++++++++ test/textarea/textarea-test.html | 11 ++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/test/textarea/textarea-spec.js b/test/textarea/textarea-spec.js index 48bcf04..04feb8f 100644 --- a/test/textarea/textarea-spec.js +++ b/test/textarea/textarea-spec.js @@ -57,6 +57,31 @@ TestPageLoader.queueTest("textarea-test", function(testPage) { }); }); }); + describe("initialization attributes", function () { + var textarea, defaultValue, defaultRequired, defaultMaxLength; + beforeEach(function() { + if (!textarea) { + textarea = testPage.test.textareaWithAttributes; + //keep default values + defaultValue = textarea.value; + defaultRequired = textarea.required; + defaultMaxLength = textarea.maxLength; + } + //restore default values + textarea.value = defaultValue; + textarea.required = defaultRequired; + textarea.maxLength = defaultMaxLength; + }); + it("TODO should have expected value property value", function () { + expect(textarea.value).toEqual("a string"); + }); + it("TODO should have expected required property value", function () { + expect(textarea.required).toEqual(true); + }); + it("TODO should have expected maxLength property value", function () { + expect(textarea.maxLength).toEqual(150); + }); + }); }); }); }); diff --git a/test/textarea/textarea-test.html b/test/textarea/textarea-test.html index f672abf..d0ec1f1 100644 --- a/test/textarea/textarea-test.html +++ b/test/textarea/textarea-test.html @@ -9,7 +9,8 @@ "test": { "prototype": "test/textarea/textarea-test[Test]", "properties": { - "textarea": {"@": "textarea"} + "textarea": {"@": "textarea"}, + "textareaWithAttributes": {"@": "textareaWithAttributes"} } }, @@ -18,6 +19,13 @@ "properties": { "element": {"#": "textarea"} } + }, + + "textareaWithAttributes": { + "prototype": "textarea.reel", + "properties": { + "element": {"#": "textareaWithAttributes"} + } } } @@ -27,5 +35,6 @@

Textarea

+ From 36a288ee1cc2472aed142016d5015c138303a7b7 Mon Sep 17 00:00:00 2001 From: Jacob Seidelin Date: Tue, 12 Mar 2013 00:01:25 +0100 Subject: [PATCH 9/9] Add basic tests for select component --- test/select/select-spec.js | 71 +++++++++++++++++++++++++++++++++++- test/select/select-test.html | 28 +++++++++++++- 2 files changed, 96 insertions(+), 3 deletions(-) diff --git a/test/select/select-spec.js b/test/select/select-spec.js index f2c20ac..de9e6e5 100644 --- a/test/select/select-spec.js +++ b/test/select/select-spec.js @@ -9,8 +9,75 @@ TestPageLoader.queueTest("select-test", function(testPage) { }); describe("Select", function() { - it("can be created", function() { - expect(testPage.test.select).toBeDefined(); + describe("default", function () { + it("can be created", function() { + expect(testPage.test.select).toBeDefined(); + }); + var select, defaultValue, defaultRequired; + beforeEach(function() { + if (!select) { + select = testPage.test.select; + //keep default values + defaultValue = select.value; + defaultRequired = select.required; + } + //restore default values + select.value = defaultValue; + select.required = defaultRequired; + }); + describe("property", function() { + describe("value", function() { + it("TODO should have correct default", function() { + expect(defaultValue).toEqual(null); + }); + it("TODO can not be set with no option", function() { + select.value = "banana"; + expect(select.value).toEqual(defaultValue); + }); + }); + describe("required", function() { + it("TODO should have correct default", function() { + expect(defaultRequired).toEqual(false); + }); + it("TODO can be set", function() { + select.required = true; + expect(select.required).toEqual(true); + }); + }); + }); + }); + describe("with options", function () { + it("can be created", function() { + expect(testPage.test.selectWithOptions).toBeDefined(); + }); + var select, defaultValue, defaultRequired; + beforeEach(function() { + if (!select) { + select = testPage.test.selectWithOptions; + //keep default values + defaultValue = select.value; + defaultRequired = select.required; + } + //restore default values + select.value = defaultValue; + select.required = defaultRequired; + }); + describe("property", function() { + describe("value", function() { + it("TODO should default to first option", function() { + expect(defaultValue).toEqual("apple"); + }); + it("TODO can be set", function() { + select.value = "banana"; + expect(select.value).toEqual("banana"); + }); + it("TODO can not be set to nonexistent option", function() { + select.value = "banana"; + select.value = "pear"; + expect(select.value).toEqual("banana"); + }); + }); + }); }); }); }); diff --git a/test/select/select-test.html b/test/select/select-test.html index 9e7d7e9..e472c61 100644 --- a/test/select/select-test.html +++ b/test/select/select-test.html @@ -9,7 +9,9 @@ "test": { "prototype": "test/select/select-test[Test]", "properties": { - "select": {"@": "select"} + "select": {"@": "select"}, + "selectWithOptions": {"@": "selectWithOptions"}, + "selectWithAttributes": {"@": "selectWithAttributes"} } }, @@ -18,6 +20,20 @@ "properties": { "element": {"#": "select"} } + }, + + "selectWithOptions": { + "prototype": "select.reel", + "properties": { + "element": {"#": "selectWithOptions"} + } + }, + + "selectWithAttributes": { + "prototype": "select.reel", + "properties": { + "element": {"#": "selectWithAttributes"} + } } } @@ -27,5 +43,15 @@

Select

+ + + +