2014-07-30 17:53:14 -04:00
|
|
|
moduleFor("controller:create-account", "controller:create-account", {
|
2014-08-14 12:51:16 -04:00
|
|
|
needs: ['controller:modal', 'controller:login']
|
2014-07-30 17:53:14 -04:00
|
|
|
});
|
2013-11-19 14:15:05 -05:00
|
|
|
|
|
|
|
test('basicUsernameValidation', function() {
|
2014-07-30 17:53:14 -04:00
|
|
|
var subject = this.subject;
|
|
|
|
|
2013-11-19 14:15:05 -05:00
|
|
|
var testInvalidUsername = function(username, expectedReason) {
|
2014-07-30 17:53:14 -04:00
|
|
|
var controller = subject();
|
2013-11-19 14:15:05 -05:00
|
|
|
controller.set('accountUsername', username);
|
|
|
|
equal(controller.get('basicUsernameValidation.failed'), true, 'username should be invalid: ' + username);
|
|
|
|
equal(controller.get('basicUsernameValidation.reason'), expectedReason, 'username validation reason: ' + username + ', ' + expectedReason);
|
|
|
|
};
|
|
|
|
|
|
|
|
testInvalidUsername('', undefined);
|
|
|
|
testInvalidUsername('x', I18n.t('user.username.too_short'));
|
2014-06-09 15:27:37 -04:00
|
|
|
testInvalidUsername('123456789012345678901', I18n.t('user.username.too_long'));
|
2013-11-19 14:15:05 -05:00
|
|
|
|
2014-07-30 17:53:14 -04:00
|
|
|
var controller = subject();
|
2013-11-19 14:15:05 -05:00
|
|
|
controller.set('accountUsername', 'porkchops');
|
|
|
|
controller.set('prefilledUsername', 'porkchops');
|
|
|
|
equal(controller.get('basicUsernameValidation.ok'), true, 'Prefilled username is valid');
|
|
|
|
equal(controller.get('basicUsernameValidation.reason'), I18n.t('user.username.prefilled'), 'Prefilled username is valid');
|
|
|
|
});
|