Skip to content

@balupton /README.md
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JQTest: Server-Side jQuery testing with Node.js, Expresso and CoffeeScript. Test faster, test funner.

JQTest

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

# 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.