Created
March 2, 2012 14:10
-
-
Save jfromaniello/1958582 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
/*global sinon, QUnit, test*/ | |
sinon.assert.fail = function (msg) { | |
QUnit.ok(false, msg); | |
}; | |
sinon.assert.pass = function (assertion) { | |
QUnit.ok(true, assertion); | |
}; | |
sinon.config = { | |
injectIntoThis: true, | |
injectInto: null, | |
properties: ["spy", "stub", "mock", "clock", "sandbox"], | |
useFakeTimers: false, | |
useFakeServer: true | |
}; | |
//sandbox per test | |
(function (global) { | |
var qModule = QUnit.module; | |
var setup = function () { $.extend(this, sinon.sandbox.create(sinon.config)); }; | |
var teardown = function () { this.verifyAndRestore(); } | |
QUnit.module = global.module = function (name, lifecycle) { | |
lifecycle = lifecycle || {}; | |
var newlc = {}; | |
newlc.setup = function(){ | |
setup.bind(this)(); | |
lifecycle.setup && lifecycle.setup.bind(this)(); | |
}; | |
newlc.teardown = function(){ | |
teardown.bind(this)(); | |
lifecycle.teardown && lifecycle.teardown.bind(this)(); | |
}; | |
qModule(name, newlc); | |
}; | |
}(this)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment