it('should fail login with invalid password on POST /api/auth/login', function (done) { User.authenticate.restore(); sinon.stub(User, 'authenticate') .withArgs('b@b', '123123') .callsArgWith(2, null, null, codes.AUTH_PWD_MISMATCH); //<-- request(app) .post('/api/auth/login') .send({email: 'b@b', password: '******'}) .set(typeAcceptHeaders) .expect(200) .expect({error: 'Wrong email or password'}, done); });
it('should fail login with unverified email on POST /api/auth/login & re-send email', function (done) { User.authenticate.restore(); sinon.stub(User, 'authenticate') .withArgs('b@b', '123123') .callsArgWith(2, null, {email: 'b@b', name: {full: 'John Snow'}}, codes.AUTH_NOT_VERIFIED); //<-- // TODO - doesn't work! /*sinon.stub(mailer, 'send') .withArgs('b@b') .calledOnce.should.equal(true);*/ request(app) .post('/api/auth/login') .send({email: 'b@b', password: '******'}) .set(typeAcceptHeaders) .expect(200) .expect({error: 'verify-email'}, done); });
after(function () { User.authenticate.restore(); });