From eb103ac05fa180516cc381439dd1a9d8df7bf794 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Wed, 8 Mar 2017 19:21:26 +0700 Subject: [PATCH] Use window instead of jsdom for type tests --- package.json | 1 + test/types.js | 20 ++++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 6e07a39..fd8068c 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "nyc": "^10.0.0", "rollup": "^0.41.4", "rollup-plugin-babel": "^2.7.1", + "window": "^3.1.1", "xo": "^0.17.1" } } diff --git a/test/types.js b/test/types.js index 58d72e8..d1ec86c 100644 --- a/test/types.js +++ b/test/types.js @@ -1,5 +1,5 @@ import test from 'ava'; -import jsdom from 'jsdom'; +import Window from 'window'; import whenDomReady from '../'; test('whenDomReady is a function', t => { @@ -20,16 +20,12 @@ test('whenDomReady.resume returns a function that returns a promise', t => { t.true(returnValue() instanceof Promise); }); -test.cb('Promise value always resolves to undefined', t => { +test('Promise value always resolves to undefined', async t => { t.plan(2); - const config = { - html: '', - onload: window => { - const promises = []; - promises.push(whenDomReady(() => 'foo', window.document).then(val => t.is(val, undefined))); - promises.push(whenDomReady(window.document).then(val => t.is(val, undefined))); - Promise.all(promises).then(() => t.end()); - } - }; - jsdom.env(config); + const { document } = new Window(); + const promises = [ + whenDomReady(() => 'foo', document).then(val => t.is(val, undefined)), + whenDomReady(document).then(val => t.is(val, undefined)) + ]; + await Promise.all(promises); });