sinon.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. var behavior = require("./sinon/behavior");
  3. var createSandbox = require("./sinon/create-sandbox");
  4. var deprecated = require("./sinon/util/core/deprecated");
  5. var extend = require("./sinon/util/core/extend");
  6. var fakeTimers = require("./sinon/util/fake-timers");
  7. var format = require("./sinon/util/core/format");
  8. var nise = require("nise");
  9. var Sandbox = require("./sinon/sandbox");
  10. var stub = require("./sinon/stub");
  11. var apiMethods = {
  12. createSandbox: createSandbox,
  13. assert: require("./sinon/assert"),
  14. match: require("@sinonjs/samsam").createMatcher,
  15. spyCall: require("./sinon/call"),
  16. expectation: require("./sinon/mock-expectation"),
  17. createStubInstance: require("./sinon/stub").createStubInstance,
  18. defaultConfig: require("./sinon/util/core/default-config"),
  19. setFormatter: format.setFormatter,
  20. // fake timers
  21. timers: fakeTimers.timers,
  22. // fake XHR
  23. xhr: nise.fakeXhr.xhr,
  24. FakeXMLHttpRequest: nise.fakeXhr.FakeXMLHttpRequest,
  25. // fake server
  26. fakeServer: nise.fakeServer,
  27. fakeServerWithClock: nise.fakeServerWithClock,
  28. createFakeServer: nise.fakeServer.create.bind(nise.fakeServer),
  29. createFakeServerWithClock: nise.fakeServerWithClock.create.bind(nise.fakeServerWithClock),
  30. addBehavior: function(name, fn) {
  31. behavior.addBehavior(stub, name, fn);
  32. }
  33. };
  34. var legacySandboxAPI = {
  35. sandbox: {
  36. create: deprecated.wrap(
  37. createSandbox,
  38. // eslint-disable-next-line max-len
  39. "`sandbox.create()` is deprecated. Use default sandbox at `sinon.sandbox` or create new sandboxes with `sinon.createSandbox()`"
  40. )
  41. }
  42. };
  43. var sandbox = new Sandbox();
  44. var api = extend(sandbox, legacySandboxAPI, apiMethods);
  45. module.exports = api;