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

Unified Diff: chrome/test/data/webui/md_history/lazy_render_test.js

Issue 2230003002: MD History: Add lazy-render element for simple lazy initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months 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
Index: chrome/test/data/webui/md_history/lazy_render_test.js
diff --git a/chrome/test/data/webui/md_history/lazy_render_test.js b/chrome/test/data/webui/md_history/lazy_render_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..341394d5e0d898418b8e0f374be9a9b6fe3e22be
--- /dev/null
+++ b/chrome/test/data/webui/md_history/lazy_render_test.js
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('md_history.lazy_render_test', function() {
+ function registerTests() {
+ suite('history-lazy-render', function() {
+
+ setup(function() {
+ PolymerTest.clearBody();
+ var template =
+ '<template is="dom-bind" id="bind">' +
+ ' <template is="history-lazy-render" id="lazy">' +
+ ' <h1>' +
+ ' <paper-checkbox checked="{{checked}}"></paper-checkbox>' +
+ ' {{name}}' +
+ ' </h1>' +
+ ' </template>' +
+ '</template>';
+ document.body.innerHTML = template;
+ });
+
+ test('stamps after get()', function() {
+ var lazy = document.getElementById('lazy');
+
+ assertFalse(!!document.body.querySelector('h1'));
+ assertFalse(!!lazy.getIfExists());
+
+ return lazy.get().then(function(inner) {
+ assertEquals('H1', inner.nodeName);
+ assertEquals(inner, document.body.querySelector('h1'));
+ });
+ });
+
+ test('one-way binding works', function() {
+ var bind = document.getElementById('bind');
+ bind.name = 'Wings';
+ var lazy = document.getElementById('lazy');
+
+ return lazy.get().then(function(inner) {
+ assertNotEquals(-1, inner.textContent.indexOf('Wings'));
+ bind.name = 'DC';
+ assertNotEquals(-1, inner.textContent.indexOf('DC'));
+ });
+ });
+
+ test('two-way binding works', function() {
+ var bind = document.getElementById('bind');
+ bind.checked = true;
+
+ var lazy = document.getElementById('lazy');
+
+ return lazy.get().then(function(inner) {
+ var checkbox = document.querySelector('paper-checkbox');
+ assertTrue(checkbox.checked);
+ MockInteractions.tap(checkbox);
+ assertFalse(checkbox.checked);
+ assertFalse(bind.checked);
+ });
+ });
+ });
+ }
+
+ return {
+ registerTests: registerTests,
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698