Skip to content

Instantly share code, notes, and snippets.

@nickstenning
Created February 1, 2012 16:53
Show Gist options
  • Save nickstenning/1718004 to your computer and use it in GitHub Desktop.
Save nickstenning/1718004 to your computer and use it in GitHub Desktop.
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