forked from stormpath/express-stormpath
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request stormpath#584 from stormpath/fix/registration-fiel…
…d-validation Fix field validation
- Loading branch information
Showing
2 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,11 @@ describe('validateAccount', function () { | |
confirmPassword: { | ||
enabled: true, | ||
required: true | ||
}, | ||
color: { | ||
enabled: true, | ||
required: true, | ||
label: 'Color' | ||
} | ||
} | ||
} | ||
|
@@ -42,7 +47,26 @@ describe('validateAccount', function () { | |
surname: 'Degges', | ||
email: '[email protected]', | ||
password: 'FASRbaBjkrqJSNVlUrV2ZyUy5iUX8UEZ3TW3nejX', | ||
confirmPassword: 'FASRbaBjkrqJSNVlUrV2ZyUy5iUX8UEZ3TW3nejX' | ||
confirmPassword: 'FASRbaBjkrqJSNVlUrV2ZyUy5iUX8UEZ3TW3nejX', | ||
customData: { | ||
color: 'purple' | ||
} | ||
}; | ||
|
||
helpers.validateAccount(accountData, config, function (errors) { | ||
assert.equal(errors, null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should support custom data properties on the root object', function (done) { | ||
var accountData = { | ||
givenName: 'Randall', | ||
surname: 'Degges', | ||
email: '[email protected]', | ||
password: 'FASRbaBjkrqJSNVlUrV2ZyUy5iUX8UEZ3TW3nejX', | ||
confirmPassword: 'FASRbaBjkrqJSNVlUrV2ZyUy5iUX8UEZ3TW3nejX', | ||
color: 'purple' | ||
}; | ||
|
||
helpers.validateAccount(accountData, config, function (errors) { | ||
|
@@ -57,7 +81,10 @@ describe('validateAccount', function () { | |
surname: 'Degges', | ||
email: '[email protected]', | ||
password: 'woot', | ||
confirmPassword: 'woothi' | ||
confirmPassword: 'woothi', | ||
customData: { | ||
color: 'purple' | ||
} | ||
}; | ||
|
||
helpers.validateAccount(accountData, config, function (errors) { | ||
|
@@ -70,12 +97,31 @@ describe('validateAccount', function () { | |
it('should return the right number of errors if errors are present', function (done) { | ||
var accountData = { | ||
givenName: 'Randall', | ||
surname: 'Degges' | ||
surname: 'Degges', | ||
customData: { | ||
color: 'purple' | ||
} | ||
}; | ||
|
||
helpers.validateAccount(accountData, config, function (errors) { | ||
assert.equal(errors.length, 3); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should correctly validate required fields by also looking into custom data', function (done) { | ||
var accountData = { | ||
givenName: 'Randall', | ||
surname: 'Degges', | ||
email: '[email protected]', | ||
password: 'FASRbaBjkrqJSNVlUrV2ZyUy5iUX8UEZ3TW3nejX', | ||
confirmPassword: 'FASRbaBjkrqJSNVlUrV2ZyUy5iUX8UEZ3TW3nejX' | ||
}; | ||
|
||
helpers.validateAccount(accountData, config, function (errors) { | ||
assert.equal(errors.length, 1); | ||
assert.equal(errors[0].message, 'Color required.'); | ||
done(); | ||
}); | ||
}); | ||
}); |