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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('md_history.lazy_render_test', function() {
6 function registerTests() {
7 suite('history-lazy-render', function() {
8
9 setup(function() {
10 PolymerTest.clearBody();
11 var template =
12 '<template is="dom-bind" id="bind">' +
13 ' <template is="history-lazy-render" id="lazy">' +
14 ' <h1>' +
15 ' <paper-checkbox checked="{{checked}}"></paper-checkbox>' +
16 ' {{name}}' +
17 ' </h1>' +
18 ' </template>' +
19 '</template>';
20 document.body.innerHTML = template;
21 });
22
23 test('stamps after get()', function() {
24 var lazy = document.getElementById('lazy');
25
26 assertFalse(!!document.body.querySelector('h1'));
27 assertFalse(!!lazy.getIfExists());
28
29 return lazy.get().then(function(inner) {
30 assertEquals('H1', inner.nodeName);
31 assertEquals(inner, document.body.querySelector('h1'));
32 });
33 });
34
35 test('one-way binding works', function() {
36 var bind = document.getElementById('bind');
37 bind.name = 'Wings';
38 var lazy = document.getElementById('lazy');
39
40 return lazy.get().then(function(inner) {
41 assertNotEquals(-1, inner.textContent.indexOf('Wings'));
42 bind.name = 'DC';
43 assertNotEquals(-1, inner.textContent.indexOf('DC'));
44 });
45 });
46
47 test('two-way binding works', function() {
48 var bind = document.getElementById('bind');
49 bind.checked = true;
50
51 var lazy = document.getElementById('lazy');
52
53 return lazy.get().then(function(inner) {
54 var checkbox = document.querySelector('paper-checkbox');
55 assertTrue(checkbox.checked);
56 MockInteractions.tap(checkbox);
57 assertFalse(checkbox.checked);
58 assertFalse(bind.checked);
59 });
60 });
61 });
62 }
63
64 return {
65 registerTests: registerTests,
66 }
67 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698