Skip to content

Commit 42b1003

Browse files
[atoms] Add a test for mixed type value for getAttribute
1 parent da53187 commit 42b1003

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

javascript/atoms/test/attribute_test.html

+25-15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
limitations under the License.
1717
-->
1818
<html>
19+
1920
<head>
2021
<title>attribute_test.html</title>
2122
<script src="test_bootstrap.js"></script>
@@ -25,30 +26,31 @@
2526
goog.require('goog.events.EventType');
2627
goog.require('goog.testing.jsunit');
2728
</script>
29+
<meta charset="UTF-8">
2830
<script type="text/javascript">
2931
function testCanFindNamedAttributes() {
30-
var e = bot.locators.findElement({id: 'cheddar'});
32+
var e = bot.locators.findElement({ id: 'cheddar' });
3133
assertAttributeEquals('cheese', e, 'name');
3234
}
3335

3436
function testCanFindAttributesOnTheExpando() {
35-
var e = bot.locators.findElement({id: 'cheddar'});
37+
var e = bot.locators.findElement({ id: 'cheddar' });
3638
assertAttributeEquals('lovely', e, 'unknown');
3739
}
3840

3941
function testShouldReturnClassAttribute() {
40-
var e = bot.locators.findElement({id: 'cheddar'});
42+
var e = bot.locators.findElement({ id: 'cheddar' });
4143
assertAttributeEquals('tasty', e, 'class');
4244
}
4345

4446
function testShouldReturnNullForMissingAttributes() {
45-
var e = bot.locators.findElement({id: 'checky'});
47+
var e = bot.locators.findElement({ id: 'checky' });
4648
assertAttributeEquals(null, e, 'never_there');
4749
assertAttributeEquals(null, e, 'class');
4850
}
4951

5052
function testShouldReturnAnEmptyStringWhenAttributesValueIsAnEmptyString() {
51-
var e = bot.locators.findElement({id: 'cheddar'});
53+
var e = bot.locators.findElement({ id: 'cheddar' });
5254
assertAttributeEquals('', e, 'empty');
5355
}
5456

@@ -58,46 +60,52 @@
5860
assertEquals(String(elem.getAttribute(attr)), value);
5961
}
6062

61-
var e = bot.locators.findElement({id: 'selecty'});
63+
var e = bot.locators.findElement({ id: 'selecty' });
6264
assertPresentBooleanAttr(e, 'selected');
6365

64-
var e = bot.locators.findElement({id: 'checky'});
66+
var e = bot.locators.findElement({ id: 'checky' });
6567
assertPresentBooleanAttr(e, 'disabled');
6668
assertPresentBooleanAttr(e, 'readonly');
6769
assertPresentBooleanAttr(e, 'checked');
6870
}
6971

7072
function testReturnNullForAbsentBooleanAttributes() {
71-
var e = bot.locators.findElement({id: 'unselecty'});
73+
var e = bot.locators.findElement({ id: 'unselecty' });
7274
assertAttributeEquals(null, e, 'selected');
7375

74-
var e = bot.locators.findElement({id: 'unchecky'});
76+
var e = bot.locators.findElement({ id: 'unchecky' });
7577
assertAttributeEquals(null, e, 'disabled');
7678
assertAttributeEquals(null, e, 'readonly');
7779
assertAttributeEquals(null, e, 'checked');
7880
}
7981

8082
function testCanGetValueAttributeFromInput() {
81-
var input = bot.locators.findElement({id: 'unchecky'});
82-
var option = bot.locators.findElement({id: 'unselecty'});
83+
var input = bot.locators.findElement({ id: 'unchecky' });
84+
var option = bot.locators.findElement({ id: 'unselecty' });
8385

8486
assertAttributeEquals('unchecky', input, 'value');
8587
assertAttributeEquals('unselecty', option, 'value');
8688
}
8789

8890
function testAttributeMatchesAreCaseInsensitive() {
89-
var e = bot.locators.findElement({id: 'checky'});
91+
var e = bot.locators.findElement({ id: 'checky' });
9092
assertAttributeEquals(bot.dom.getAttribute(e, 'readonly'), e, 'readOnly');
9193
assertAttributeEquals(bot.dom.getAttribute(e, 'name'), e, 'NaMe');
9294
}
9395

96+
function testAttributeDoesNotChangeTheTypeOfTheAttribute() {
97+
var e = bot.locators.findElement({ id: 'aValue' });
98+
assertAttributeEquals("4b273a33fbbd29013nN93dy4F1A~", e, "value");
99+
}
100+
94101
function assertAttributeEquals(expected, elem, attr) {
95102
assertEquals('Expected attribute "' + attr + '" to equal "' +
96-
expected + '"', expected, bot.dom.getAttribute(elem, attr));
103+
expected + '"', expected, bot.dom.getAttribute(elem, attr));
97104
}
98105

99106
</script>
100107
</head>
108+
101109
<body>
102110
<div id="cheddar" name="cheese" class="tasty" unknown="lovely" empty="">Cheddar</div>
103111

@@ -107,8 +115,10 @@
107115
<option id="unselecty" value="unselecty">unselecty</option>
108116
</select>
109117
<!-- Setting checked="false" but getAttribute should be non-null. -->
110-
<input id="checky" type="checkbox" disabled readonly="readonly" checked="false"/>
111-
<input id="unchecky" type="checkbox" value="unchecky"/>
118+
<input id="checky" type="checkbox" disabled readonly="readonly" checked="false" />
119+
<input id="unchecky" type="checkbox" value="unchecky" />
112120
</form>
121+
<li id=aValue value="4b273a33fbbd29013nN93dy4F1A~" class="cur"></li>
113122
</body>
123+
114124
</html>

0 commit comments

Comments
 (0)