Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
fix(users): test for usernameOrEmail (#1582)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil authored and lirantal committed Oct 19, 2016
1 parent 0773991 commit ae63889
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion modules/users/tests/e2e/users.e2e.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Users E2E Tests:', function () {
expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Email address is invalid.');
});

it('Should report missing username or email', function () {
it('Should report missing username', function () {
browser.get('http://localhost:3001/authentication/signup');
// Enter First Name
element(by.model('vm.credentials.firstName')).sendKeys(user1.firstName);
Expand Down
47 changes: 35 additions & 12 deletions modules/users/tests/server/user.server.routes.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('User CRUD tests', function () {
});
});

it('should be able to login with username and email successfully and logout successfully', function (done) {
it('should be able to login with username successfully and logout successfully', function (done) {
// Login with username
agent.post('/api/auth/signin')
.send(credentials)
Expand Down Expand Up @@ -119,18 +119,41 @@ describe('User CRUD tests', function () {
signoutRes.text.should.equal('Moved Temporarily. Redirecting to /');
}

// Login with username
agent.post('/api/auth/signin')
.send(credentials)
.expect(200)
.end(function (signinErr, signinRes) {
// Handle signin error
if (signinErr) {
return done(signinErr);
}
return done();
});
});
});

return done();
});
it('should be able to login with email successfully and logout successfully', function (done) {
// Login with username
agent.post('/api/auth/signin')
.send(credentialsEmail)
.expect(200)
.end(function (signinErr, signinRes) {
// Handle signin error
if (signinErr) {
return done(signinErr);
}

// Logout
agent.get('/api/auth/signout')
.expect(302)
.end(function (signoutErr, signoutRes) {
if (signoutErr) {
return done(signoutErr);
}

signoutRes.redirect.should.equal(true);

// NodeJS v4 changed the status code representation so we must check
// before asserting, to be comptabile with all node versions.
if (semver.satisfies(process.versions.node, '>=4.0.0')) {
signoutRes.text.should.equal('Found. Redirecting to /');
} else {
signoutRes.text.should.equal('Moved Temporarily. Redirecting to /');
}

return done();
});
});
});
Expand Down

0 comments on commit ae63889

Please sign in to comment.