<commit_before>import test from 'ava';
import jsdom from 'jsdom';
import whenDomReady from '../';

test.cb('callback fires with global document', t => {
	t.plan(1);
	whenDomReady(() => {
		t.pass();
		t.end();
	});
});

test('Promise resolves with global document', async t => {
	t.plan(1);
	await whenDomReady().then(() => t.pass());
});

test.cb('callback fires with local document', t => {
	t.plan(1);
	const config = {
		html: '',
		onload: window => whenDomReady(() => {
			t.pass();
			t.end();
		}, 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 run after 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 run after DOMContentLoaded', t => {
	t.plan(1);
	const config = {
		html: '',
		created: (err, window) => whenDomReady(window.document).then(() => {
			t.pass();
			t.end();
		})
	};
	jsdom.env(config);
});

test('Promise chain helper passes value through', async t => {
	t.plan(1);<commit_msg>Fix already loaded callback test to work with new callback functionality<commit_after>import test from 'ava';
import jsdom from 'jsdom';
import whenDomReady from '../';

test.cb('callback fires with global document', t => {
	t.plan(1);
	whenDomReady(() => {
		t.pass();
		t.end();
	});
});

test('Promise resolves with global document', async t => {
	t.plan(1);
	await whenDomReady().then(() => t.pass());
});

test.cb('callback fires with local document', t => {
	t.plan(1);
	const config = {
		html: '',
		onload: window => whenDomReady(() => {
			t.pass();
			t.end();
		}, 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.cb('callback fires if we run after DOMContentLoaded', t => {
	t.plan(1);
	const config = {
		html: '',
		created: (err, window) => whenDomReady(() => {
			t.pass();
			t.end();
		}, window.document)
	};
	jsdom.env(config);
});

test.cb('Promise resolves if we run after DOMContentLoaded', t => {
	t.plan(1);
	const config = {
		html: '',
		created: (err, window) => whenDomReady(window.document).then(() => {
			t.pass();
			t.end();
		})
	};
	jsdom.env(config);
});

test('Promise chain helper passes value through', async t => {
	t.plan(1);
{'fraction_non_alphanumeric': 0.20962962962962964, 'fraction_numerical': 0.005185185185185185, 'mean_word_length': 3.7137870855148343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1591326', 'n_tokens_mistral': 1015, 'n_tokens_neox': 961, 'n_words': 235}