added tests

This commit is contained in:
Ivan Socolsky 2014-12-16 21:02:18 -03:00
parent 9c4eef5912
commit 4e029d3ce0

View File

@ -406,10 +406,11 @@ describe('emailstore test', function() {
});
});
describe.only('resend validation email', function () {
describe('resend validation email', function () {
var email = 'fake@email.com';
var secret = '123';
beforeEach(function() {
leveldb_stub.get.reset();
request.param.onFirstCall().returns(email);
response.json.returnsThis();
response.redirect = sinon.stub();
@ -423,6 +424,23 @@ describe('emailstore test', function() {
plugin.sendVerificationEmail.calledOnce.should.be.true;
plugin.sendVerificationEmail.calledWith(email, secret).should.be.true;
});
it('should resend validation email when pending (old style secret)', function () {
plugin.authorizeRequestWithoutKey = sinon.stub().callsArgWith(1, null, email);
leveldb_stub.get.onFirstCall().callsArgWith(1, null, secret);
plugin.sendVerificationEmail = sinon.spy();
plugin.resendEmail(request, response);
plugin.sendVerificationEmail.calledOnce.should.be.true;
plugin.sendVerificationEmail.calledWith(email, secret).should.be.true;
});
it('should not resend when email is no longer pending', function () {
plugin.authorizeRequestWithoutKey = sinon.stub().callsArgWith(1, null, email);
leveldb_stub.get.onFirstCall().callsArgWith(1, { notFound: true });
plugin.sendVerificationEmail = sinon.spy();
plugin.resendEmail(request, response);
plugin.sendVerificationEmail.should.not.be.called;
});
});
describe('removing items', function() {