You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.1 KiB

import test from 'ava';
import jsdom from 'jsdom';
import whenDomReady from '../';
test('callback fires with global window', async t => {
t.plan(1);
whenDomReady(() => t.pass());
});
test('Promise resolves with global window', async t => {
t.plan(1);
whenDomReady().then(() => t.pass());
});
test('callback fires with local document', async t => {
t.plan(1);
const config = {
html: '',
onload: window => whenDomReady(() => t.pass(), window.document)
};
jsdom.env(config);
});
test.cb('Promise resolves with local document', t => {
t.plan(1);
const config = {
html: '',
onload: window => whenDomReady(window.document).then(() => {
t.pass();
t.end();
})
};
jsdom.env(config);
});
test('callback fires if we wait for DOMContentLoaded', async t => {
t.plan(1);
const config = {
html: '',
created: (err, window) => whenDomReady(() => t.pass(), window.document)
};
jsdom.env(config);
});
test.cb('Promise resolves if we wait for DOMContentLoaded', t => {
t.plan(1);
const config = {
html: '',
created: (err, window) => whenDomReady(window.document).then(() => {
t.pass();
t.end();
})
};
jsdom.env(config);
});