Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/sinon/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ function createAssertObject(opts) {
});

const assert = {
failException: "AssertError",

fail: function fail(message) {
let msg = message;
if (cleanedAssertOptions.shouldLimitAssertionLogs) {
Expand All @@ -58,7 +56,7 @@ function createAssertObject(opts) {
);
}
const error = new Error(msg);
error.name = this.failException || assert.failException;
error.name = "AssertError";

throw error;
},
Expand Down
22 changes: 0 additions & 22 deletions test/assert-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ describe("assert", function () {
});

describe(".fail", function () {
beforeEach(function () {
this.exceptionName = sinonAssert.failException;
});

afterEach(function () {
sinonAssert.failException = this.exceptionName;
});

it("can be configured to limit the error message length", function () {
const customAssert = sinonAssert.createAssertObject({
shouldLimitAssertionLogs: true,
Expand All @@ -87,17 +79,6 @@ describe("assert", function () {
},
);
});

it("throws configured exception type", function () {
sinonAssert.failException = "CustomError";

assert.exception(
function () {
sinonAssert.fail("Some message");
},
{ name: "CustomError" },
);
});
});

describe("with stubs", function () {
Expand Down Expand Up @@ -1352,7 +1333,6 @@ describe("assert", function () {
sinonAssert.expose(test);

assert.isFunction(test.fail);
assert.isString(test.failException);
assert.isFunction(test.assertCalled);
assert.isFunction(test.assertCalledOn);
assert.isFunction(test.assertCalledWith);
Expand All @@ -1367,7 +1347,6 @@ describe("assert", function () {
includeFail: false,
});

assert.equals(typeof failException, "undefined");
/*eslint-disable no-undef*/
assert.isFunction(assertCalled);
assert.isFunction(assertCalledOn);
Expand Down Expand Up @@ -1401,7 +1380,6 @@ describe("assert", function () {
sinonAssert.expose(test, { prefix: "" });

assert.isFunction(test.fail);
assert.isString(test.failException);
assert.isFunction(test.called);
assert.isFunction(test.calledOn);
assert.isFunction(test.calledWith);
Expand Down
27 changes: 0 additions & 27 deletions test/sandbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1965,31 +1965,4 @@ describe("Sandbox", function () {
refute.equals(getter, spy.get);
});
});

describe(".assert", function () {
it("allows rebinding of .fail on a per-sandbox level", function () {
const sandboxA = createSandbox();
const sandboxB = createSandbox();

sandboxA.assert.failException = "CustomErrorA";
sandboxB.assert.failException = "CustomErrorB";

assert.exception(
function () {
sandboxA.assert.fail("Some message");
},
{ name: "CustomErrorA" },
);

assert.exception(
function () {
sandboxB.assert.fail("Some message");
},
{ name: "CustomErrorB" },
);

sandboxA.restore();
sandboxB.restore();
});
});
});