Skip to content

Commit

Permalink
refactor: Make 'nise' the default dependency of the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Oct 24, 2023
1 parent 8e7f602 commit 44529c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/create-sinon-api.js
Expand Up @@ -7,15 +7,17 @@ const fakeTimers = require("./sinon/util/fake-timers");
const Sandbox = require("./sinon/sandbox");
const stub = require("./sinon/stub");
const promise = require("./sinon/promise");
const nise = require("nise");
const assert = require("assert");

/**
* @param {object} opts injection point to override the default XHR lib in testing
* @param {object} opts.sinonXhrLib
* @returns {object} a configured sandbox
*/
module.exports = function createApi({ sinonXhrLib }) {
assert(sinonXhrLib, "No XHR lib passed in");
module.exports = function createApi(opts = { sinonXhrLib: nise }) {
assert(opts?.sinonXhrLib, "No XHR lib passed in");
const { sinonXhrLib } = opts;

const apiMethods = {
createSandbox: createSandbox,
Expand Down
3 changes: 1 addition & 2 deletions lib/sinon.js
@@ -1,6 +1,5 @@
"use strict";

const nise = require("nise");
const createApi = require("./create-sinon-api");

module.exports = createApi({ sinonXhrLib: nise });
module.exports = createApi();

0 comments on commit 44529c8

Please sign in to comment.