|
|
@ -1,4 +1,5 @@ |
|
|
|
import test from 'ava'; |
|
|
|
import jsdom from 'jsdom'; |
|
|
|
import whenDomReady from '../'; |
|
|
|
|
|
|
|
test('whenDomReady is a function', t => { |
|
|
@ -18,3 +19,17 @@ test('whenDomReady.resume returns a function that returns a promise', t => { |
|
|
|
t.is(typeof returnValue, 'function'); |
|
|
|
t.true(returnValue() instanceof Promise); |
|
|
|
}); |
|
|
|
|
|
|
|
test.cb('Promise value always resolves to undefined', 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); |
|
|
|
}); |
|
|
|