Browse Source

Use window instead of jsdom for type tests

pull/13/head
Luke Childs 8 years ago
parent
commit
eb103ac05f
  1. 1
      package.json
  2. 20
      test/types.js

1
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"
}
}

20
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);
});

Loading…
Cancel
Save