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

Side by Side Diff: sky/tests/framework/templates.sky

Issue 812713005: Add declarataive event handlers. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add tests and fix binding Created 6 years 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
(Empty)
1 <sky>
2 <import src="/sky/tests//resources/chai.sky" />
3 <import src="/sky/tests/resources/mocha.sky" />
4 <import src="/sky/tests/resources/test-element.sky" as="TestElement" />
5
6 <div id="sandbox"></div>
7
8 <script>
9 describe("SkyElement templates", function() {
10 var element;
11 var sandbox = document.getElementById("sandbox");
12
13 beforeEach(function() {
14 element = new TestElement();
15 });
16 afterEach(function() {
17 element.remove();
18 });
19
20 it("should stamp when the element is inserted", function() {
21 assert.isNull(element.shadowRoot);
22 sandbox.appendChild(element);
23 assert.instanceOf(element.shadowRoot, ShadowRoot);
24 assert.ok(element.shadowRoot.getElementById("inside"));
25 });
26
27 it("should connect data binding", function(done) {
28 sandbox.appendChild(element);
29 var inside = element.shadowRoot.getElementById("inside");
30 Promise.resolve().then(function() {
31 assert.equal(inside.textContent, 10);
32 assert.equal(inside.attr, 10);
33 element.value = 20;
34 }).then(function() {
35 assert.equal(inside.textContent, 20);
36 assert.equal(inside.attr, 20);
37 done();
38 }).catch(function(e) {
39 done(e);
40 });
41 });
42
43 it("should connect event handlers", function() {
44 sandbox.appendChild(element);
45 var inside = element.shadowRoot.getElementById("inside");
46 inside.dispatchEvent(new CustomEvent("wrong-event"));
47 assert.isNull(element.lastEvent);
48 var event = new CustomEvent("test-event");
49 inside.dispatchEvent(event);
50 assert.equal(element.lastEvent, event);
51 });
52 });
53 </script>
54 </sky>
OLDNEW
« no previous file with comments | « sky/framework/sky-element/TemplateBinding.sky ('k') | sky/tests/framework/templates-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698