Skip to content

Commit

Permalink
Verify options are passed down
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Oct 25, 2023
1 parent ea2af1d commit 351d630
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/sinon/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,20 @@ function createAssertObject(opts) {
}

module.exports = createAssertObject();
module.exports.createAssertObject = createAssertObject;
Object.defineProperty(module.exports, "createAssertObject", {
get() {
return createAssertObject;
},
});

// allow for easy mocking
module.exports.mock = {};
Object.defineProperty(module.exports.mock, "createAssertObject", {
get() {
return createAssertObject;
},
set(newImpl) {
// eslint-disable-next-line no-func-assign
createAssertObject = newImpl;
},
});
31 changes: 31 additions & 0 deletions test/create-sandbox-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";

const sinonAssert = require("../lib/sinon/assert");
const createSandbox = require("../lib/sinon/create-sandbox");

describe("create-sandbox", function () {
it("passes on options to the creation of the assert object", function () {
// Arrange
const sb = createSandbox();
const spy = sb.spy();
sb.replace.usingAccessor(sinonAssert.mock, "createAssertObject", spy);

// Act
createSandbox({
assertOptions: {
shouldLimitAssertionLogs: true,
assertionLogLimit: 1234,
},
});

// Assert
sb.assert.calledWith(
spy,
sb.match({
shouldLimitAssertionLogs: true,
assertionLogLimit: 1234,
}),
);
sb.restore();
});
});

0 comments on commit 351d630

Please sign in to comment.