From e2c339cb2ca245bbcb58dbd9ab89704053fdc79d Mon Sep 17 00:00:00 2001 From: valdrinkoshi Date: Tue, 13 Mar 2018 13:47:36 -0700 Subject: [PATCH] fix timing --- test/paper-dialog.html | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/test/paper-dialog.html b/test/paper-dialog.html index b5f637a..84465ad 100644 --- a/test/paper-dialog.html +++ b/test/paper-dialog.html @@ -103,17 +103,17 @@ dialog.addEventListener('animationend', spy); dialog.open(); dialog.addEventListener('iron-overlay-opened', function() { - // Wait a RAF so that `animationend` can propagate up and be captured by `spy`. + // Wait for `animationend` to propagate up. requestAnimationFrame(function() { assert.equal(spy.callCount, 0, 'no open animation'); dialog.close(); - dialog.addEventListener('iron-overlay-closed', function() { - // Wait a RAF so that `animationend` can propagate up and be captured by `spy`. - requestAnimationFrame(function() { - assert.equal(spy.callCount, 0, 'no close animation'); - done(); - }); - }); + }); + }); + dialog.addEventListener('iron-overlay-closed', function() { + // Wait for `animationend` to propagate up. + requestAnimationFrame(function() { + assert.equal(spy.callCount, 0, 'no close animation'); + done(); }); }); }); @@ -123,14 +123,14 @@ dialog.addEventListener('animationend', spy); dialog.open(); dialog.addEventListener('iron-overlay-opened', function() { - // Wait a RAF so that `animationend` can propagate up and be captured by `spy`. + // Wait for `animationend` to propagate up. requestAnimationFrame(function() { assert.equal(spy.callCount, 1, 'open animation ok'); dialog.close(); }); }); dialog.addEventListener('iron-overlay-closed', function() { - // Wait a RAF so that `animationend` can propagate up and be captured by `spy`. + // Wait for `animationend` to propagate up. requestAnimationFrame(function() { assert.equal(spy.callCount, 2, 'close animation ok'); done(); @@ -144,7 +144,7 @@ dialog.addEventListener('animationend', spy); dialog.open(); dialog.addEventListener('iron-overlay-opened', function() { - // Wait a RAF so that `animationend` can propagate up and be captured by `spy`. + // Wait for `animationend` to propagate up. requestAnimationFrame(function() { assert.equal(spy.callCount, 0, 'open animation ok'); done(); @@ -155,12 +155,18 @@ test('should remove animation classes when done animating', function(done) { dialog.open(); dialog.addEventListener('iron-overlay-opened', function() { - assert.isFalse(dialog.classList.contains(dialog.entryAnimation), 'no entry animation class'); - dialog.close(); + // Classes are updated after the event is fired. + setTimeout(function() { + assert.isFalse(dialog.classList.contains(dialog.entryAnimation), 'no entry animation class'); + dialog.close(); + }); }); dialog.addEventListener('iron-overlay-closed', function() { - assert.isFalse(dialog.classList.contains(dialog.exitAnimation), 'no exit animation class'); - done(); + // Classes are updated after the event is fired. + setTimeout(function() { + assert.isFalse(dialog.classList.contains(dialog.exitAnimation), 'no exit animation class'); + done(); + }); }); });