Skip to content

Commit

Permalink
Use the Sinon default sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Dec 17, 2018
1 parent ad26b2f commit 02b4bef
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/referee-sinon.test.js
Expand Up @@ -4,8 +4,6 @@ var sinon = require("sinon");
var referee = require("@sinonjs/referee");
var formatio = require("@sinonjs/formatio");

var sandbox = sinon.createSandbox();

var assert = referee.assert;
var refute = referee.refute;
var expect = referee.expect;
Expand Down Expand Up @@ -35,7 +33,7 @@ function requiresSpy(assertion) {

describe("referee-sinon", function () {
afterEach(function () {
sandbox.restore();
sinon.restore();
});

describe("sinon", function () {
Expand Down Expand Up @@ -80,7 +78,7 @@ describe("referee-sinon", function () {

describe("assertions", function () {
it("formats assert messages through referee", function () {
sandbox.stub(referee, "format").returns("I'm the object");
sinon.stub(referee, "format").returns("I'm the object");
var message;
var spy = sinon.spy();
spy({ id: 42 });
Expand Down Expand Up @@ -122,7 +120,7 @@ describe("referee-sinon", function () {
it("doesn't pass undefined to [].slice (IE8 doesn't like that)", function () {
var spy = sinon.spy();
spy("foo");
sandbox.spy(Array.prototype, "slice");
sinon.spy(Array.prototype, "slice");

assert.calledWith(spy, "foo");
assert.calledWithExactly(Array.prototype.slice, 1);
Expand Down Expand Up @@ -593,7 +591,7 @@ describe("referee-sinon", function () {
it("fails when not called with spy", requiresSpy("threw"));

it("passes when spy threw", function () {
var spy = sandbox.stub().throws();
var spy = sinon.stub().throws();
try {
spy();
// eslint-disable-next-line no-empty
Expand All @@ -615,7 +613,7 @@ describe("referee-sinon", function () {
});

it("works with spy calls", function () {
var spy = sandbox.stub().throws();
var spy = sinon.stub().throws();
try {
spy();
// eslint-disable-next-line no-empty
Expand All @@ -628,7 +626,7 @@ describe("referee-sinon", function () {
it("fails when not called with spy", requiresSpy("alwaysThrew"));

it("passes when spy always threw", function () {
var spy = sandbox.stub().throws();
var spy = sinon.stub().throws();
try {
spy();
// eslint-disable-next-line no-empty
Expand Down Expand Up @@ -698,15 +696,15 @@ describe("referee-sinon", function () {

describe("expectations", function () {
it("toHaveBeenCalledWithMatch", function () {
var stub = sandbox.stub(assert, "calledWithMatch");
var stub = sinon.stub(assert, "calledWithMatch");

expect().toHaveBeenCalledWithMatch();

assert.calledOnce(stub);
});

it("toHaveAlwaysBeenCalledWithMatch", function () {
var stub = sandbox.stub(assert, "alwaysCalledWithMatch");
var stub = sinon.stub(assert, "alwaysCalledWithMatch");

expect().toHaveAlwaysBeenCalledWithMatch();

Expand All @@ -716,7 +714,7 @@ describe("referee-sinon", function () {

describe("sinon assert failures", function () {
it("delegates to referee.assert.fail", function () {
sandbox.stub(referee, "fail");
sinon.stub(referee, "fail");

try {
assert.calledOnce(sinon.spy());
Expand All @@ -743,7 +741,7 @@ describe("referee-sinon", function () {

describe("sinon mock expectation failures", function () {
it("delegates to referee.assert.fail", function () {
sandbox.stub(referee, "fail");
sinon.stub(referee, "fail");

try {
sinon.mock().never()();
Expand Down

0 comments on commit 02b4bef

Please sign in to comment.