Add showRequiredError and showSignupRationale alerts and tests to CreateAccountModal

This commit is contained in:
Scott Erickson 2016-03-10 11:37:31 -08:00
parent a59e96f277
commit 84cdf1e2ce
2 changed files with 24 additions and 6 deletions

View file

@ -7,8 +7,11 @@
span.glyphicon.glyphicon-remove
.auth-form-content
if view.options.showRequiredError
#required-error-alert.alert.alert-success
span(data-i18n="signup.required")
if view.options.showSignupRationale
.alert.alert-info
#signup-rationale-alert.alert.alert-info
span(data-i18n="play_level.victory_sign_up_poke")
#email-password-row.row

View file

@ -5,8 +5,8 @@ describe 'CreateAccountModal', ->
modal = null
beforeEach ->
modal = new CreateAccountModal()
initModal = (options) ->
modal = new CreateAccountModal(options)
modal.render()
modal.render = _.noop
jasmine.demoModal(modal)
@ -20,8 +20,21 @@ describe 'CreateAccountModal', ->
afterEach ->
modal.stopListening()
describe 'constructed with showRequiredError is true', ->
it 'shows a modal explaining to login first', ->
initModal({showRequiredError: true})
expect(modal.$('#required-error-alert').length).toBe(1)
describe 'constructed with showSignupRationale is true', ->
it 'shows a modal explaining signup rationale', ->
initModal({showSignupRationale: true})
expect(modal.$('#signup-rationale-alert').length).toBe(1)
describe 'clicking the save button', ->
beforeEach ->
initModal()
it 'fails if nothing is in the form, showing errors for email and password', ->
modal.$('form').each (i, el) -> el.reset()
modal.$('form:first').submit()
@ -84,6 +97,7 @@ describe 'CreateAccountModal', ->
signupButton = null
beforeEach ->
initModal()
application.gplusHandler.trigger 'render-login-buttons'
signupButton = modal.$('#gplus-signup-btn')
expect(signupButton.attr('disabled')).toBeFalsy()
@ -152,6 +166,7 @@ describe 'CreateAccountModal', ->
signupButton = null
beforeEach ->
initModal()
Backbone.Mediator.publish 'auth:facebook-api-loaded', {}
signupButton = modal.$('#facebook-signup-btn')
expect(signupButton.attr('disabled')).toBeFalsy()