-
-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export enhanced sandbox as sinon api
- Loading branch information
Showing
5 changed files
with
112 additions
and
47 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,64 @@ | ||
"use strict"; | ||
|
||
exports.assert = require("./sinon/assert"); | ||
exports.match = require("./sinon/match"); | ||
exports.spy = require("./sinon/spy"); | ||
exports.spyCall = require("./sinon/call"); | ||
exports.stub = require("./sinon/stub"); | ||
exports.mock = require("./sinon/mock"); | ||
|
||
var behavior = require("./sinon/behavior"); | ||
var createSandbox = require("./sinon/create-sandbox"); | ||
var deprecated = require("./sinon/util/core/deprecated"); | ||
var extend = require("./sinon/util/core/extend"); | ||
var fakeTimers = require("./sinon/util/fake_timers"); | ||
var format = require("./sinon/util/core/format"); | ||
var nise = require("nise"); | ||
var Sandbox = require("./sinon/sandbox"); | ||
exports.sandbox = new Sandbox(); | ||
exports.createSandbox = require("./sinon/create-sandbox"); | ||
var stub = require("./sinon/stub"); | ||
|
||
exports.expectation = require("./sinon/mock-expectation"); | ||
exports.createStubInstance = require("./sinon/stub").createStubInstance; | ||
var apiMethods = { | ||
createSandbox: createSandbox, | ||
assert: require("./sinon/assert"), | ||
match: require("./sinon/match"), | ||
spy: require("./sinon/spy"), | ||
spyCall: require("./sinon/call"), | ||
stub: require("./sinon/stub"), | ||
mock: require("./sinon/mock"), | ||
|
||
exports.defaultConfig = require("./sinon/util/core/default-config"); | ||
expectation: require("./sinon/mock-expectation"), | ||
createStubInstance: require("./sinon/stub").createStubInstance, | ||
defaultConfig: require("./sinon/util/core/default-config"), | ||
|
||
var fakeTimers = require("./sinon/util/fake_timers"); | ||
exports.useFakeTimers = fakeTimers.useFakeTimers; | ||
exports.clock = fakeTimers.clock; | ||
exports.timers = fakeTimers.timers; | ||
setFormatter: format.setFormatter, | ||
|
||
var nise = require("nise"); | ||
exports.xhr = nise.fakeXhr.xhr; | ||
exports.FakeXMLHttpRequest = nise.fakeXhr.FakeXMLHttpRequest; | ||
exports.useFakeXMLHttpRequest = nise.fakeXhr.useFakeXMLHttpRequest; | ||
// fake timers | ||
useFakeTimers: fakeTimers.useFakeTimers, | ||
clock: fakeTimers.clock, | ||
timers: fakeTimers.timers, | ||
|
||
exports.fakeServer = nise.fakeServer; | ||
exports.fakeServerWithClock = nise.fakeServerWithClock; | ||
|
||
exports.createFakeServer = nise.fakeServer.create.bind(nise.fakeServer); | ||
exports.createFakeServerWithClock = nise.fakeServerWithClock.create.bind(nise.fakeServerWithClock); | ||
// fake XHR | ||
xhr: nise.fakeXhr.xhr, | ||
FakeXMLHttpRequest: nise.fakeXhr.FakeXMLHttpRequest, | ||
useFakeXMLHttpRequest: nise.fakeXhr.useFakeXMLHttpRequest, | ||
|
||
var behavior = require("./sinon/behavior"); | ||
// fake server | ||
fakeServer: nise.fakeServer, | ||
fakeServerWithClock: nise.fakeServerWithClock, | ||
createFakeServer: nise.fakeServer.create.bind(nise.fakeServer), | ||
createFakeServerWithClock: nise.fakeServerWithClock.create.bind(nise.fakeServerWithClock), | ||
|
||
exports.addBehavior = function (name, fn) { | ||
behavior.addBehavior(exports.stub, name, fn); | ||
addBehavior: function (name, fn) { | ||
behavior.addBehavior(stub, name, fn); | ||
} | ||
}; | ||
|
||
var format = require("./sinon/util/core/format"); | ||
exports.setFormatter = format.setFormatter; | ||
var legacySandboxAPI = { | ||
sandbox: { | ||
create: deprecated.wrap( | ||
createSandbox, | ||
// eslint-disable-next-line max-len | ||
"`sandbox.create()` is deprecated. Use default sandbox at `sinon.sandbox` or create new sandboxes with `sinon.createSandbox()`" | ||
) | ||
} | ||
}; | ||
|
||
var sandbox = new Sandbox(); | ||
|
||
var api = extend(sandbox, legacySandboxAPI, apiMethods); | ||
|
||
module.exports = api; |
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