| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('md_history.lazy_render_test', function() { | 5 cr.define('md_history.lazy_render_test', function() { |
| 6 function registerTests() { | 6 function registerTests() { |
| 7 suite('history-lazy-render', function() { | 7 suite('history-lazy-render', function() { |
| 8 | 8 |
| 9 setup(function() { | 9 setup(function() { |
| 10 PolymerTest.clearBody(); | 10 PolymerTest.clearBody(); |
| 11 var template = | 11 var template = |
| 12 '<template is="dom-bind" id="bind">' + | 12 '<template is="dom-bind" id="bind">' + |
| 13 ' <template is="history-lazy-render" id="lazy">' + | 13 ' <template is="history-lazy-render" id="lazy">' + |
| 14 ' <h1>' + | 14 ' <h1>' + |
| 15 ' <paper-checkbox checked="{{checked}}"></paper-checkbox>' + | 15 ' <history-side-bar selected-page="{{selectedPage}}">' + |
| 16 ' </history-side-bar>' + |
| 16 ' {{name}}' + | 17 ' {{name}}' + |
| 17 ' </h1>' + | 18 ' </h1>' + |
| 18 ' </template>' + | 19 ' </template>' + |
| 19 '</template>'; | 20 '</template>'; |
| 20 document.body.innerHTML = template; | 21 document.body.innerHTML = template; |
| 21 }); | 22 }); |
| 22 | 23 |
| 23 test('stamps after get()', function() { | 24 test('stamps after get()', function() { |
| 24 var lazy = document.getElementById('lazy'); | 25 var lazy = document.getElementById('lazy'); |
| 25 | 26 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 return lazy.get().then(function(inner) { | 41 return lazy.get().then(function(inner) { |
| 41 assertNotEquals(-1, inner.textContent.indexOf('Wings')); | 42 assertNotEquals(-1, inner.textContent.indexOf('Wings')); |
| 42 bind.name = 'DC'; | 43 bind.name = 'DC'; |
| 43 assertNotEquals(-1, inner.textContent.indexOf('DC')); | 44 assertNotEquals(-1, inner.textContent.indexOf('DC')); |
| 44 }); | 45 }); |
| 45 }); | 46 }); |
| 46 | 47 |
| 47 test('two-way binding works', function() { | 48 test('two-way binding works', function() { |
| 48 var bind = document.getElementById('bind'); | 49 var bind = document.getElementById('bind'); |
| 49 bind.checked = true; | 50 bind.selectedPage = 'totally real page'; |
| 50 | 51 |
| 51 var lazy = document.getElementById('lazy'); | 52 var lazy = document.getElementById('lazy'); |
| 52 | 53 |
| 53 return lazy.get().then(function(inner) { | 54 return lazy.get().then(function(inner) { |
| 54 var checkbox = document.querySelector('paper-checkbox'); | 55 var sideBar = document.querySelector('history-side-bar'); |
| 55 assertTrue(checkbox.checked); | 56 assertEquals(bind.selectedPage, sideBar.selectedPage); |
| 56 MockInteractions.tap(checkbox); | 57 |
| 57 assertFalse(checkbox.checked); | 58 sideBar.selectedPage = 'different page'; |
| 58 assertFalse(bind.checked); | 59 assertEquals(bind.selectedPage, sideBar.selectedPage); |
| 59 }); | 60 }); |
| 60 }); | 61 }); |
| 61 }); | 62 }); |
| 62 } | 63 } |
| 63 | 64 |
| 64 return { | 65 return { |
| 65 registerTests: registerTests, | 66 registerTests: registerTests, |
| 66 } | 67 } |
| 67 }); | 68 }); |
| OLD | NEW |