Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(spy): removes reset method #74

Merged
merged 1 commit into from
Jun 15, 2017
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
23 changes: 7 additions & 16 deletions lib/spy.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,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 @@ -484,36 +484,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