Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digit tests #9

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions test/input-text/input-text-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,78 @@ 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, 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() {
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("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("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, 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");
});
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);
});
});
});
});
Expand Down
11 changes: 10 additions & 1 deletion test/input-text/input-text-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": {
"prototype": "test/input-text/input-text-test[Test]",
"properties": {
"inputText": {"@": "inputText"}
"inputText": {"@": "inputText"},
"inputTextWithAttributes": {"@": "inputTextWithAttributes"}
}
},

Expand All @@ -18,6 +19,13 @@
"properties": {
"element": {"#": "inputText"}
}
},

"inputTextWithAttributes": {
"prototype": "input-text.reel",
"properties": {
"element": {"#": "inputTextWithAttributes"}
}
}
}
</script>
Expand All @@ -27,5 +35,6 @@
<h1>InputText</h1>

<div data-montage-id="inputText"></div>
<input data-montage-id="inputTextWithAttributes" value="a string" maxlength=7 required></div>
</body>
</html>
71 changes: 69 additions & 2 deletions test/select/select-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
});
});
});
});
Expand Down
28 changes: 27 additions & 1 deletion test/select/select-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"test": {
"prototype": "test/select/select-test[Test]",
"properties": {
"select": {"@": "select"}
"select": {"@": "select"},
"selectWithOptions": {"@": "selectWithOptions"},
"selectWithAttributes": {"@": "selectWithAttributes"}
}
},

Expand All @@ -18,6 +20,20 @@
"properties": {
"element": {"#": "select"}
}
},

"selectWithOptions": {
"prototype": "select.reel",
"properties": {
"element": {"#": "selectWithOptions"}
}
},

"selectWithAttributes": {
"prototype": "select.reel",
"properties": {
"element": {"#": "selectWithAttributes"}
}
}
}
</script>
Expand All @@ -27,5 +43,15 @@
<h1>Select</h1>

<div data-montage-id="select"></div>

<select data-montage-id="selectWithOptions">
<option value="apple">Green</option>
<option value="banana">Yellow</option>
</select>

<select data-montage-id="selectWithAttributes" required>
<option value="apple">Green</option>
<option value="banana" selected>Yellow</option>
</select>
</body>
</html>
74 changes: 72 additions & 2 deletions test/textarea/textarea-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,78 @@ 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, 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() {
it("should have correct default", function() {
expect(defaultValue).toEqual("");
});
it("can be set", function() {
textarea.value = "a string";
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);
});
});
});
});
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);
});
});
});
});
Expand Down
11 changes: 10 additions & 1 deletion test/textarea/textarea-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": {
"prototype": "test/textarea/textarea-test[Test]",
"properties": {
"textarea": {"@": "textarea"}
"textarea": {"@": "textarea"},
"textareaWithAttributes": {"@": "textareaWithAttributes"}
}
},

Expand All @@ -18,6 +19,13 @@
"properties": {
"element": {"#": "textarea"}
}
},

"textareaWithAttributes": {
"prototype": "textarea.reel",
"properties": {
"element": {"#": "textareaWithAttributes"}
}
}
}
</script>
Expand All @@ -27,5 +35,6 @@
<h1>Textarea</h1>

<div data-montage-id="textarea"></div>
<textarea data-montage-id="textareaWithAttributes" maxlength=150 required>a string</textarea>
</body>
</html>
41 changes: 39 additions & 2 deletions test/toggle/toggle-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});
});
});
Expand Down