Skip to content

Instantly share code, notes, and snippets.

@vadimdemedes
Forked from quidmonkey/foo.js
Last active February 5, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadimdemedes/46f75d250837e6f74bf9 to your computer and use it in GitHub Desktop.
Save vadimdemedes/46f75d250837e6f74bf9 to your computer and use it in GitHub Desktop.
How Do I Mock the DOM with Ava?
import jQuery from 'jquery';
export const attachEvents = someStr => {
jQuery(document).ready(e => {
// do something cool with someStr
});
};
import test from 'ava';
import { jsdom } from 'jsdom';
global.document = jsdom();
global.window = document.defaultView;
import { attachEvents } from './foo'
test('test:attachEvents', t => {
const ret = attachEvents('mockStr');
t.true(ret);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment