Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: sky/tests/lowlevel/attribute-collection.sky

Issue 691893002: Add support for Element#getAttributes (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <link rel="import" href="../resources/mocha.sky" /> 2 <link rel="import" href="../resources/mocha.sky" />
3 <link rel="import" href="../resources/chai.sky" /> 3 <link rel="import" href="../resources/chai.sky" />
4 <script> 4 <script>
5 describe("Attribute collection", function() { 5 describe("Attribute collection", function() {
6 var div; 6 var div;
7 beforeEach(function() { 7 beforeEach(function() {
8 div = document.createElement("div"); 8 div = document.createElement("div");
9 }); 9 });
10 10
11 it("should get by index", function() { 11 it("should get by index", function() {
12 div.setAttribute("attr0", "value0"); 12 div.setAttribute("attr0", "value0");
13 div.setAttribute("attr1", "value1"); 13 div.setAttribute("attr1", "value1");
14 assert.equal(div.attributes.length, 2); 14 assert.equal(div.attributes.length, 2);
15 assert.equal(div.attributes[0].name, "attr0"); 15 assert.equal(div.attributes[0].name, "attr0");
16 assert.equal(div.attributes[0].value, "value0"); 16 assert.equal(div.attributes[0].value, "value0");
17 assert.equal(div.attributes[1].name, "attr1"); 17 assert.equal(div.attributes[1].name, "attr1");
18 assert.equal(div.attributes[1].value, "value1"); 18 assert.equal(div.attributes[1].value, "value1");
19 }); 19 });
20 it("should get by name", function() { 20 it("should get by name", function() {
21 div.setAttribute("attr0", "value0"); 21 div.setAttribute("attr0", "value0");
22 div.setAttribute("attr1", "value1"); 22 div.setAttribute("attr1", "value1");
23 assert.equal(div.attributes.length, 2); 23 assert.equal(div.attributes.length, 2);
24 assert.equal(div.attributes.attr0.value, "value0"); 24 assert.equal(div.attributes.attr0.value, "value0");
25 assert.equal(div.attributes.attr1.value, "value1"); 25 assert.equal(div.attributes.attr1.value, "value1");
26 }); 26 });
27 it("should get all at once", function() {
28 div.setAttribute("attr0", "value0");
29 div.setAttribute("attr1", "value1");
30 var attrs = div.getAttributes();
31 assert.equal(attrs.length, 2);
32 assert.equal(attrs[0].name, "attr0");
33 assert.equal(attrs[0].value, "value0");
34 assert.equal(attrs[1].name, "attr1");
35 assert.equal(attrs[1].value, "value1");
36 });
27 it("should set by name", function() { 37 it("should set by name", function() {
28 div.setAttribute("attrName", "value0"); 38 div.setAttribute("attrName", "value0");
29 div.attributes.attrName.value = "new value"; 39 div.attributes.attrName.value = "new value";
30 assert.equal(div.getAttribute("attrName"), "new value"); 40 assert.equal(div.getAttribute("attrName"), "new value");
31 assert.equal(div.attributes.attrName.value, "new value"); 41 assert.equal(div.attributes.attrName.value, "new value");
32 }); 42 });
33 it("should be case sensitive", function() { 43 it("should be case sensitive", function() {
34 div.setAttribute("attrName", "value0"); 44 div.setAttribute("attrName", "value0");
35 assert.isUndefined(div.attributes.attrname); 45 assert.isUndefined(div.attributes.attrname);
36 assert.ok(div.attributes.attrName); 46 assert.ok(div.attributes.attrName);
(...skipping 10 matching lines...) Expand all
47 assert.equal(div.attributes[1].name, "attr2"); 57 assert.equal(div.attributes[1].name, "attr2");
48 div.setAttribute("attr3", ""); 58 div.setAttribute("attr3", "");
49 div.setAttribute("attr2", "value2"); 59 div.setAttribute("attr2", "value2");
50 assert.equal(div.attributes.length, 3); 60 assert.equal(div.attributes.length, 3);
51 assert.equal(div.attributes[2].name, "attr3"); 61 assert.equal(div.attributes[2].name, "attr3");
52 assert.equal(div.attributes.attr2.value, "value2"); 62 assert.equal(div.attributes.attr2.value, "value2");
53 }); 63 });
54 }); 64 });
55 </script> 65 </script>
56 </html> 66 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698