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

Side by Side Diff: sky/tests/lowlevel/query-selector.html

Issue 685623002: Move the tests from .html to .sky (Closed) Base URL: https://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
« no previous file with comments | « sky/tests/lowlevel/hello-world.sky ('k') | sky/tests/lowlevel/query-selector.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
2 <link rel="import" href="../resources/mocha.html" />
3 <link rel="import" href="../resources/chai.html" />
4 <div id="tests">
5 <div id="id1">
6 <div class="class2"></div>
7 </div>
8 <tag-name-3 class="class7" id="tag1"></tag-name-3>
9 <tag-name-3 class="class7" id="tag2"></tag-name-3>
10 <span class="class2">
11 <span class="class5" id="id5"></span>
12 </span>
13 <div id="id5"></div>
14 <tag-name-6 class="class6" id="id6">
15 <tag-name-3 class="class7" id="tag2"></tag-name-3>
16 </tag-name-6>
17 </div>
18 <script>
19 function query(selector) { return document.querySelector(selector); }
20 function queryAll(selector) { return document.querySelectorAll(selector); }
21
22 describe("querySelector", function() {
23 it("should find elements by class name", function() {
24 assert.ok(query(".class2"));
25 assert.equal(query(".class2").classList.toString(), "class2");
26 assert.equal(queryAll(".class2").length, 2);
27 assert.equal(queryAll(".class2")[0].classList.toString(), "class2");
28 assert.equal(queryAll(".class2")[1].classList.toString(), "class2");
29 assert.notEqual(queryAll(".class2")[0], queryAll(".class2")[1]);
30 });
31 it("should find elements by id", function() {
32 assert.ok(query("#id5"));
33 assert.equal(query("#id5").id, "id5");
34 assert.equal(query("#id5").classList.toString(), "class5");
35 // FIXME(sky): Do we still want to allow multiple id stuff like this?
36 assert.equal(queryAll("#id5").length, 2);
37 assert.equal(queryAll("#id5")[0], query("#id5"));
38 assert.notEqual(queryAll("#id5")[1], query("#id5"));
39 assert.equal(queryAll("#id5")[1].id, "id5");
40 });
41 it("should find elements by tag name", function() {
42 assert.ok(query("tag-name-6"));
43 assert.equal(query("tag-name-6").tagName, "tag-name-6");
44 assert.equal(query("tag-name-6").classList.toString(), "class6");
45 var context = query("#tests");
46 assert.equal(context.querySelectorAll("span").length, 2);
47 });
48 it("should find an element by compound selector", function() {
49 assert.ok(query("tag-name-6.class6#id6"));
50 assert.equal(query("tag-name-6.class6#id6").id, "id6");
51 assert.equal(query("tag-name-6.class6#id6").classList.toString(), "class6");
52 assert.equal(query("tag-name-6.class6#id6").tagName, "tag-name-6");
53 });
54 it("should find all elements by compound selector", function() {
55 assert.ok(queryAll("tag-name-3.class7"));
56 assert.equal(queryAll("tag-name-3.class7").length, 3);
57 assert.equal(queryAll("tag-name-3.class7")[0].id, "tag1");
58 assert.equal(queryAll("tag-name-3.class7")[1].id, "tag2");
59 });
60 });
61 </script>
62 </html>
OLDNEW
« no previous file with comments | « sky/tests/lowlevel/hello-world.sky ('k') | sky/tests/lowlevel/query-selector.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698