2014-05-04 14:30:17 -04:00
|
|
|
module("controller:create-account");
|
2013-11-19 14:15:05 -05:00
|
|
|
|
|
|
|
test('basicUsernameValidation', function() {
|
|
|
|
var testInvalidUsername = function(username, expectedReason) {
|
2014-05-04 14:30:17 -04:00
|
|
|
var controller = controllerFor('create-account');
|
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'));
|
|
|
|
testInvalidUsername('1234567890123456', I18n.t('user.username.too_long'));
|
|
|
|
|
2014-05-04 14:30:17 -04:00
|
|
|
var controller = controllerFor('create-account');
|
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');
|
|
|
|
});
|