This repository has been archived by the owner on Jun 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't directly depend on components to wire
Change API from magical side-effect require to exporting a function that accepts the modules to wire together. The module now has no dependencies, instead you pass in the components to wire up. This also allows using a specific instance of e.g. stack-filter.
- Loading branch information
Showing
3 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,45 @@ | ||
((typeof define === "function" && define.amd && function (m) { | ||
define(["sinon", "buster-test", "stack-filter", "formatio"], m); | ||
define(m); | ||
}) || (typeof module === "object" && | ||
typeof require === "function" && function (m) { | ||
module.exports = m( | ||
require("sinon"), | ||
require("buster-test"), | ||
require("stack-filter"), | ||
require("formatio") | ||
); | ||
module.exports = m(); | ||
}) || function (m) { | ||
m(this.sinon, this.buster, this.stackFilter, this.formatio); | ||
this.busterSinon = m(); | ||
} | ||
)(function (sinon, bt, stackFilter, formatio) { | ||
stackFilter.filters.push("lib/sinon"); | ||
)(function () { | ||
return function (sinon, bt, stackFilter, formatio) { | ||
stackFilter.filters.push("lib/sinon"); | ||
|
||
bt.testRunner.onCreate(function (runner) { | ||
runner.on("test:setUp", function (test) { | ||
var config = sinon.getConfig(sinon.config); | ||
config.useFakeServer = false; | ||
var sandbox = sinon.sandbox.create(); | ||
sandbox.inject(test.testCase); | ||
bt.testRunner.onCreate(function (runner) { | ||
runner.on("test:setUp", function (test) { | ||
var config = sinon.getConfig(sinon.config); | ||
config.useFakeServer = false; | ||
var sandbox = sinon.sandbox.create(); | ||
sandbox.inject(test.testCase); | ||
|
||
test.testCase.useFakeTimers = function () { | ||
return sandbox.useFakeTimers.apply(sandbox, arguments); | ||
}; | ||
test.testCase.useFakeTimers = function () { | ||
return sandbox.useFakeTimers.apply(sandbox, arguments); | ||
}; | ||
|
||
test.testCase.useFakeServer = function () { | ||
return sandbox.useFakeServer.apply(sandbox, arguments); | ||
}; | ||
test.testCase.useFakeServer = function () { | ||
return sandbox.useFakeServer.apply(sandbox, arguments); | ||
}; | ||
|
||
test.testCase.sandbox = sandbox; | ||
var testFunc = test.func; | ||
}); | ||
test.testCase.sandbox = sandbox; | ||
var testFunc = test.func; | ||
}); | ||
|
||
runner.on("test:tearDown", function (test) { | ||
try { | ||
test.testCase.sandbox.verifyAndRestore(); | ||
} catch (e) { | ||
runner.assertionFailure(e); | ||
} | ||
}); | ||
runner.on("test:tearDown", function (test) { | ||
try { | ||
test.testCase.sandbox.verifyAndRestore(); | ||
} catch (e) { | ||
runner.assertionFailure(e); | ||
} | ||
}); | ||
|
||
sinon.expectation.pass = function () { | ||
runner.assertionPass(); | ||
}; | ||
}); | ||
sinon.expectation.pass = function () { | ||
runner.assertionPass(); | ||
}; | ||
}); | ||
}; | ||
}); |
This file contains 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
This file contains 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