Created
February 1, 2012 16:53
-
-
Save nickstenning/1718004 to your computer and use it in GitHub Desktop.
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
| fs = require 'fs' | |
| jsdom = require 'jsdom' | |
| src = """ | |
| <html> | |
| <head></head> | |
| <body></body> | |
| </html> | |
| """ | |
| document = jsdom.jsdom(src) | |
| window = document.createWindow() | |
| req = (fname) -> | |
| src = fs.readFileSync(fname, 'utf8') | |
| window.run(src, fname) | |
| # Update this to reflect a path to jQuery 1.7 | |
| req(__dirname + '/../../lib/vendor/jquery.js') | |
| class window.TestCase | |
| constructor: -> | |
| @el = window.$('<div><a id="clickMe" class="foo"></a></div>') | |
| @el.on('click', '.foo', => this.methodByClass()) | |
| @el.on('click', 'a', => this.methodByTagName()) | |
| @el.on('click', '#clickMe', => this.methodById()) | |
| methodById: -> console.log 'methodById' | |
| methodByClass: -> console.log 'methodByClass' | |
| methodByTagName: -> console.log 'methodByTagName' | |
| window.tc = new window.TestCase() | |
| window.tc.el.find('#clickMe').click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment