From 975efd5fb1ae18305da9f74a1ab9c27c8eb26743 Mon Sep 17 00:00:00 2001 From: ParamagicDev Date: Sat, 25 Sep 2021 16:52:16 -0400 Subject: [PATCH] fix test suite --- test/js/remoteWatcher/remoteWatcher.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/js/remoteWatcher/remoteWatcher.test.ts b/test/js/remoteWatcher/remoteWatcher.test.ts index 2a23b348..b348fc83 100644 --- a/test/js/remoteWatcher/remoteWatcher.test.ts +++ b/test/js/remoteWatcher/remoteWatcher.test.ts @@ -1,13 +1,11 @@ import { assert } from '@esm-bundle/chai' +import { nextFrame } from '@open-wc/testing' import mrujs from '../../../src' -async function nextEventLoopTick (): Promise { - return await new Promise(resolve => setTimeout(() => resolve(), 0)) -} - describe('RemoteWatcher', () => { it('Should auto attach to remote forms + links', async () => { mrujs.start() + await nextFrame() const remoteForm = document.createElement('form') remoteForm.classList.add('remote') remoteForm.setAttribute('data-remote', 'true') @@ -24,7 +22,8 @@ describe('RemoteWatcher', () => { remoteLink.setAttribute('data-remote', 'true') // We need to wait for next event loop to be able to let the mutation observer fire. - await nextEventLoopTick() + await nextFrame() + await nextFrame() document.querySelectorAll('.remote').forEach((el) => assert(el.getAttribute('data-turbo') === 'false')) document.querySelectorAll('.not-remote').forEach((el) => assert(el.getAttribute('data-turbo') == null))