a simple nodeunit setUp wrapper for testing front code
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib can support 2 arguments Aug 30, 2012
tests bump version, add testing script Aug 30, 2012
LICENSE readme, license Aug 30, 2012
README.md deprecation note Feb 12, 2013
package.json fix idiot bug in package.json, bump version Aug 30, 2012

README.md

NOTE this is totally deprecated in favor of nodeunit-b.

nodeunit-jsdom

being a simple wrapper for nodeunit setUp functions that allows for the testing and mocking of front-end code

usage

    var jsdom_wrapper = require('nodeunit-jsdom')

    exports.test_ui = {
        setUp: jsdom_wrapper(
            '<html><head></head><body><div id="cthulhu"></div></body></html>', [
                '/path/to/jquery.js',
                '/path/to/your/code.js'
            ],
            function(cb) {
                // additional setUp code
                cb()
            }
        ),
        test_ajax_call: function(test) {
            var post_called = false
            this.window.$.post = function() { post_called = true }
            this.window.do_stuff_with_side_effects()
            test.ok(post_called)
            test.done()
        },
        test_dom: function(test) {
            var divs = this.window.$('div')
            test.equal(divs.length, 1)
            test.equal(divs[0].id, 'cthulhu')
            test.done()
        }
    }

tests

cd tests nodeunit test.js

author

nathaniel k smith nathanielksmith@gmail.com

license

BSD