public
Last active

JQTest: Server-Side jQuery testing with Node.js, Expresso and CoffeeScript. Test faster, test funner.

  • Download Gist
README.md
Markdown

JQTest

Server-Side jQuery testing with Node.js, Expresso and CoffeeScript. Test faster, test funner.

jqtest.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
# Server-Side jQuery testing with Node.js
# Copyright 2011 Benjamin Lupton
# MIT Licensed
# https://gist.github.com/1191942
 
# -------------------------------------
# Requires
 
fs = require('fs')
assert = require('assert')
jquery = require('jquery')
cwd = process.cwd();
 
# -------------------------------------
# Helpers
 
appendScript = (scriptPath) ->
scriptPath = "#{cwd}/#{scriptPath}";
scriptContents = fs.readFileSync(scriptPath).toString()
return this.append "<script>#{scriptContents}</script>"
 
createjQuery = ->
$ = jquery.create();
$.fn.appendScript = appendScript
return $
 
createjQueryWith = (scripts,html) ->
$ = createjQuery();
$body = $('body')
scripts = [scripts] unless scripts instanceof Array
$body.appendScript script for script in scripts
$body.append html if html
return $
 
# -------------------------------------
# Export
 
module.exports = {
fs,assert,jquery
appendScript
createjQuery
createjQueryWith
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.