Chromium Code Reviews| 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')); |
|
calamity
2016/08/16 07:00:01
Lol.
tsergeant
2016/08/16 07:56:44
Acknowledged.
|
| + }); |
| + }); |
| + |
| + 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, |
| + } |
| +}); |