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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/sky-element/TemplateBinding.sky ('k') | sky/tests/framework/templates-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tests/framework/templates.sky
diff --git a/sky/tests/framework/templates.sky b/sky/tests/framework/templates.sky
new file mode 100644
index 0000000000000000000000000000000000000000..c0a9fa620891562c66072bf7201977e23436dc02
--- /dev/null
+++ b/sky/tests/framework/templates.sky
@@ -0,0 +1,54 @@
+<sky>
+<import src="/sky/tests//resources/chai.sky" />
+<import src="/sky/tests/resources/mocha.sky" />
+<import src="/sky/tests/resources/test-element.sky" as="TestElement" />
+
+<div id="sandbox"></div>
+
+<script>
+describe("SkyElement templates", function() {
+ var element;
+ var sandbox = document.getElementById("sandbox");
+
+ beforeEach(function() {
+ element = new TestElement();
+ });
+ afterEach(function() {
+ element.remove();
+ });
+
+ it("should stamp when the element is inserted", function() {
+ assert.isNull(element.shadowRoot);
+ sandbox.appendChild(element);
+ assert.instanceOf(element.shadowRoot, ShadowRoot);
+ assert.ok(element.shadowRoot.getElementById("inside"));
+ });
+
+ it("should connect data binding", function(done) {
+ sandbox.appendChild(element);
+ var inside = element.shadowRoot.getElementById("inside");
+ Promise.resolve().then(function() {
+ assert.equal(inside.textContent, 10);
+ assert.equal(inside.attr, 10);
+ element.value = 20;
+ }).then(function() {
+ assert.equal(inside.textContent, 20);
+ assert.equal(inside.attr, 20);
+ done();
+ }).catch(function(e) {
+ done(e);
+ });
+ });
+
+ it("should connect event handlers", function() {
+ sandbox.appendChild(element);
+ var inside = element.shadowRoot.getElementById("inside");
+ inside.dispatchEvent(new CustomEvent("wrong-event"));
+ assert.isNull(element.lastEvent);
+ var event = new CustomEvent("test-event");
+ inside.dispatchEvent(event);
+ assert.equal(element.lastEvent, event);
+ });
+});
+</script>
+</sky>
« 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