Created
February 5, 2016 18:20
-
-
Save quidmonkey/0beca1ff49158624feac to your computer and use it in GitHub Desktop.
How Do I Mock the DOM with Ava?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jQuery from 'jquery'; | |
export const attachEvents = someStr => { | |
jQuery(document).ready(e => { | |
// do something cool with someStr | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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