mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This CL is just a search-and-replace. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/694423002
63 lines
2.3 KiB
Plaintext
63 lines
2.3 KiB
Plaintext
<html>
|
|
<import src="../resources/mocha.sky" />
|
|
<import src="../resources/chai.sky" />
|
|
<script>
|
|
describe("Attribute collection", function() {
|
|
var div;
|
|
beforeEach(function() {
|
|
div = document.createElement("div");
|
|
});
|
|
|
|
it("should get by index", function() {
|
|
div.setAttribute("attr0", "value0");
|
|
div.setAttribute("attr1", "value1");
|
|
var attrs = div.getAttributes();
|
|
assert.equal(attrs.length, 2);
|
|
assert.equal(attrs[0].name, "attr0");
|
|
assert.equal(attrs[0].value, "value0");
|
|
assert.equal(attrs[1].name, "attr1");
|
|
assert.equal(attrs[1].value, "value1");
|
|
});
|
|
it("should set by name", function() {
|
|
div.setAttribute("attrName", "value0");
|
|
assert.equal(div.getAttribute("attrName"), "value0");
|
|
assert.equal(div.getAttributes()[0].name, "attrName");
|
|
assert.equal(div.getAttributes()[0].value, "value0");
|
|
div.setAttribute("attrName", "new value");
|
|
assert.equal(div.getAttribute("attrName"), "new value");
|
|
assert.equal(div.getAttributes()[0].name, "attrName");
|
|
assert.equal(div.getAttributes()[0].value, "new value");
|
|
});
|
|
it("should be case sensitive", function() {
|
|
div.setAttribute("attrName", "value0");
|
|
assert.isNull(div.getAttribute("attrname"));
|
|
assert.equal(div.getAttribute("attrName"), "value0");
|
|
});
|
|
it("should not live update", function() {
|
|
div.setAttribute("attr0", "0");
|
|
div.setAttribute("attr1", "1");
|
|
div.setAttribute("attr2", "2");
|
|
var oldAttributes = div.getAttributes();
|
|
assert.equal(oldAttributes.length, 3);
|
|
div.removeAttribute("attr1");
|
|
assert.equal(oldAttributes.length, 3);
|
|
div.setAttribute("attr0", "value0");
|
|
div.setAttribute("attr2", "value2");
|
|
var newAttributes = div.getAttributes();
|
|
assert.equal(newAttributes.length, 2);
|
|
assert.equal(newAttributes[0].name, "attr0");
|
|
assert.equal(newAttributes[0].value, "value0");
|
|
assert.equal(newAttributes[1].name, "attr2");
|
|
assert.equal(newAttributes[1].value, "value2");
|
|
assert.notEqual(newAttributes, oldAttributes);
|
|
assert.equal(oldAttributes[0].name, "attr0");
|
|
assert.equal(oldAttributes[0].value, "0");
|
|
assert.equal(oldAttributes[1].name, "attr1");
|
|
assert.equal(oldAttributes[1].value, "1");
|
|
assert.equal(oldAttributes[2].name, "attr2");
|
|
assert.equal(oldAttributes[2].value, "2");
|
|
});
|
|
});
|
|
</script>
|
|
</html>
|