Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 suite('cr-drawer', function() { | |
|
dpapad
2017/01/12 22:38:57
BTW, thanks for adding tests!
tsergeant
2017/01/12 22:53:51
No problem! I figured the existing test is pretty
| |
| 6 var drawer; | |
| 7 | |
| 8 setup(function() { | |
| 9 PolymerTest.clearBody(); | |
| 10 document.body.innerHTML = ` | |
| 11 <dialog is="cr-drawer" id="drawer"> | |
| 12 <div class="drawer-header">Test</div> | |
| 13 <div class="drawer-content">Test content</div> | |
| 14 </dialog> | |
| 15 `; | |
| 16 | |
| 17 drawer = document.getElementById('drawer'); | |
| 18 }); | |
| 19 | |
| 20 test('open and close', function(done) { | |
| 21 drawer.openDrawer(); | |
| 22 assertTrue(drawer.open); | |
| 23 | |
| 24 listenOnce(drawer, 'transitionend', function() { | |
| 25 listenOnce(drawer, 'close', function() { | |
| 26 assertFalse(drawer.open); | |
| 27 done(); | |
| 28 }); | |
| 29 | |
| 30 // Clicking the content does not close the drawer. | |
| 31 MockInteractions.tap(document.querySelector('.drawer-content')); | |
| 32 assertFalse(drawer.classList.contains('closing')); | |
| 33 | |
| 34 drawer.dispatchEvent(new MouseEvent('click', { | |
| 35 bubbles: true, | |
| 36 cancelable: true, | |
| 37 clientX: 300, // Must be larger than the drawer width (256px). | |
| 38 clientY: 300, | |
| 39 })); | |
| 40 | |
| 41 // Clicking outside the drawer does close it. | |
| 42 assertTrue(drawer.classList.contains('closing')); | |
| 43 }); | |
| 44 }); | |
| 45 }); | |
| OLD | NEW |