Skip to content

Commit

Permalink
Merge pull request #74 from stalniy/refactor/reset
Browse files Browse the repository at this point in the history
refactor(spy): removes reset method
  • Loading branch information
keithamus authored Jun 15, 2017
2 parents 2fe7e55 + 27cbb16 commit 2f403a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 46 deletions.
23 changes: 7 additions & 16 deletions lib/spy.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,14 @@ module.exports = function (chai, _) {
s += " }";
return s;
};

proxy.__spy = {
calls: []
, called: false
, name: name
};

/**
* # proxy.reset (function)
*
* Resets spy's state object parameters for instantiation and reuse
* @returns proxy spy object
*/
proxy.reset = function() {
this.__spy = {
calls: []
, called: false
, name: name
};
return this;
}

return proxy.reset();
return proxy;
}

/**
Expand Down
30 changes: 0 additions & 30 deletions test/spies.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,36 +501,6 @@ describe('Chai Spies', function () {
});
});

describe('reset method', function () {
it('should reset spy object values to defaults when called', function() {
var name = 'proxy';
var spy = chai.spy(name);

spy();
spy.should.have.been.called();
spy.__spy.called.should.be.true;
spy.__spy.calls.should.have.length(1);
spy.__spy.name.should.be.equal(name);

spy.reset();

spy.should.not.have.been.called();
spy.__spy.called.should.be.false;
spy.__spy.calls.should.have.length(0);
spy.__spy.name.should.be.equal(name);
});

it('should setup spy with default values when spy is instantiated', function() {
var name = 'proxy';
var spy = chai.spy(name);

spy.should.be.spy;
spy.__spy.called.should.be.false;
spy.__spy.calls.should.have.length(0);
spy.__spy.name.should.be.equal(name);
});
});

describe('spy restore', function () {
var array;

Expand Down

0 comments on commit 2f403a9

Please sign in to comment.