Skip to content

Commit

Permalink
Rebased #5681 for #5664. 2
Browse files Browse the repository at this point in the history
  • Loading branch information
laosb committed Aug 17, 2016
1 parent 0e12dc8 commit 0eba714
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions packages/accounts-password/password_tests.js
Expand Up @@ -410,6 +410,13 @@ if (Meteor.isClient) (function () {
"email", [
createUserStep,
logoutStep,
// Create user error without callback should not throw error
function (test, expect) {
this.newUsername = 'adalovelace' + this.randomSuffix;
Accounts.createUser(
{ username: this.newUsername, password: '' }
);
},
// Attempting to create another user with an email that only differs in
// case should fail
function (test, expect) {
Expand Down Expand Up @@ -468,6 +475,14 @@ if (Meteor.isClient) (function () {
test.equal(Meteor.user().username, self.username);
}));
},
// change password with bad old password, but no callback so no error
function (test, expect) {
Accounts.changePassword('wrong', 'doesntmatter');
},
// change password with blank new password, but no callback so no error
function (test, expect) {
Accounts.changePassword(this.password, '');
},
// change password with good old password.
function (test, expect) {
Accounts.changePassword(this.password, this.password2,
Expand Down Expand Up @@ -544,6 +559,74 @@ if (Meteor.isClient) (function () {
}, 10 * 1000, 100);
}
]);


testAsyncMulti("passwords - forgotPassword client return error when empty email", [
function (test, expect) {
// setup
this.email = '';
},
// forgotPassword called on client with blank email
function (test, expect) {
Accounts.forgotPassword(
{ email: this.email }, expect(function (error) {
test.isTrue(error);
}));
},
// forgotPassword called on client with blank email, no callback so no error
function (test, expect) {
Accounts.forgotPassword({ email: this.email });
},
]);

testAsyncMulti("passwords - verifyEmail client return error when empty token", [
function (test, expect) {
// setup
this.token = '';
},
// verifyEmail called on client with blank token
function (test, expect) {
Accounts.verifyEmail(
this.token, expect(function (error) {
test.isTrue(error);
}));
},
// verifyEmail called on client with blank token, no callback so no error
function (test, expect) {
Accounts.verifyEmail(this.token);
},
]);

testAsyncMulti("passwords - resetPassword errors", [
function (test, expect) {
// setup
this.token = '';
this.newPassword = 'nonblankpassword';
},
// resetPassword called on client with blank token
function (test, expect) {
Accounts.resetPassword(
this.token, this.newPassword, expect(function (error) {
test.isTrue(error);
}));
},
function (test, expect) {
// setup
this.token = 'nonblank-token';
this.newPassword = '';
},
// resetPassword called on client with blank password
function (test, expect) {
Accounts.resetPassword(
this.token, this.newPassword, expect(function (error) {
test.isTrue(error);
}));
},
// resetPassword called on client with blank password, no callback so no error
function (test, expect) {
Accounts.resetPassword(this.token, this.newPassword);
},
]);


testAsyncMulti("passwords - new user hooks", [
Expand Down

0 comments on commit 0eba714

Please sign in to comment.