diff --git a/test/test.EmailStore.js b/test/test.EmailStore.js index 086808d3..2d6c09d8 100644 --- a/test/test.EmailStore.js +++ b/test/test.EmailStore.js @@ -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() {