Skip to content

Commit

Permalink
Ensure error checking logic is in place for all REST calls, expand fo…
Browse files Browse the repository at this point in the history
…rmatting for consistency with existing instances.

 - strongloop#944
  • Loading branch information
greaterweb committed Jan 5, 2015
1 parent 5adde28 commit 2438e86
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions test/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ describe('User', function() {
.expect(200)
.send(validCredentialsEmailVerifiedOverREST)
.end(function(err, res) {
if (err) {
return done(err);
}
assert(!res.body.emailVerified);
done();
});
Expand Down Expand Up @@ -204,7 +207,9 @@ describe('User', function() {
.expect(200)
.send(validCredentials)
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
var accessToken = res.body;

assert(accessToken.userId);
Expand Down Expand Up @@ -237,6 +242,9 @@ describe('User', function() {
.expect(400)
.send(incompleteCredentials)
.end(function(err, res) {
if (err) {
return done(err);
}
done();
});
});
Expand All @@ -249,6 +257,9 @@ describe('User', function() {
.expect(400)
.send(validCredentials)
.end(function(err, res) {
if (err) {
return done(err);
}
done();
});
});
Expand All @@ -260,7 +271,9 @@ describe('User', function() {
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
var token = res.body;
expect(token.user, 'body.user').to.not.equal(undefined);
expect(token.user, 'body.user')
Expand All @@ -276,7 +289,9 @@ describe('User', function() {
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
var token = res.body;
expect(token.user, 'body.user').to.not.equal(undefined);
expect(token.user, 'body.user')
Expand Down Expand Up @@ -332,7 +347,9 @@ describe('User', function() {
.expect(200)
.send(validCredentialsEmailVerified)
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
var accessToken = res.body;

assertGoodToken(accessToken);
Expand All @@ -349,6 +366,9 @@ describe('User', function() {
.expect(401)
.send(validCredentials)
.end(function(err, res) {
if (err) {
return done(err);
}
done();
});
});
Expand Down Expand Up @@ -538,7 +558,9 @@ describe('User', function() {
.expect(200)
.send({email: 'foo@bar.com', password: 'bar'})
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
var accessToken = res.body;

assert(accessToken.userId);
Expand Down Expand Up @@ -650,7 +672,9 @@ describe('User', function() {
.expect(200)
.send({email: 'bar@bat.com', password: 'bar'})
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
});
});

Expand Down Expand Up @@ -681,7 +705,9 @@ describe('User', function() {
.expect(200)
.send({email: 'bar@bat.com', password: 'bar'})
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
});
});

Expand Down Expand Up @@ -764,7 +790,9 @@ describe('User', function() {
+ '&redirect=' + encodeURIComponent(options.redirect))
.expect(400)
.end(function(err, res) {
if (err) return done(err);
if (err) {
return done(err);
}
assert(res.body.error);
done();
});
Expand Down

0 comments on commit 2438e86

Please sign in to comment.