Skip to content

Instantly share code, notes, and snippets.

@quidmonkey
Created February 5, 2016 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save quidmonkey/0beca1ff49158624feac to your computer and use it in GitHub Desktop.
Save quidmonkey/0beca1ff49158624feac 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';
import { attachEvents } from './foo'
global.document = jsdom();
global.window = document.defaultView;
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