mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Tweak invalid class code behavior, fix hide modal button test
This commit is contained in:
parent
ebc98f988f
commit
a59e96f277
3 changed files with 20 additions and 14 deletions
|
@ -87,7 +87,7 @@
|
|||
span(data-i18n="signup.optional")
|
||||
| ):
|
||||
.input-border
|
||||
input#school-input.input-large.form-control(name="classCode", value=view.previousFormInputs.classCode || '', tabindex=5)
|
||||
input#class-code-input.input-large.form-control(name="classCode", value=view.previousFormInputs.classCode || '', tabindex=5)
|
||||
|
||||
.col-md-6
|
||||
.form-group.checkbox
|
||||
|
|
|
@ -104,7 +104,8 @@ module.exports = class CreateAccountModal extends ModalView
|
|||
|
||||
onClassroomFetchError: ->
|
||||
@$('#signup-button').text($.i18n.t('signup.sign_up')).attr('disabled', false)
|
||||
forms.setErrorToProperty(@$el, 'classCode', 'Classroom code not found. Please check with your instructor.')
|
||||
forms.setErrorToProperty(@$el, 'classCode', "#{@classCode} is not a valid code. Please verify the code is typed correctly.")
|
||||
@$('#class-code-input').val('')
|
||||
|
||||
createUser: ->
|
||||
options = {}
|
||||
|
|
|
@ -58,20 +58,25 @@ describe 'CreateAccountModal', ->
|
|||
expect(request.url).toBe('/db/classroom?code=qwerty')
|
||||
|
||||
it 'has not hidden the close-modal button', ->
|
||||
expect(modal.$('#close-modal').css('display')).toBe('block')
|
||||
expect(modal.$('#close-modal').css('display')).not.toBe('none')
|
||||
|
||||
it 'continues with signup if the Classroom exists', ->
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
request.respondWith({status: 200, responseText: JSON.stringify({})})
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
expect(request.url).toBe('/db/user')
|
||||
expect(request.method).toBe('POST')
|
||||
describe 'the Classroom exists', ->
|
||||
it 'continues with signup', ->
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
request.respondWith({status: 200, responseText: JSON.stringify({})})
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
expect(request.url).toBe('/db/user')
|
||||
expect(request.method).toBe('POST')
|
||||
|
||||
it 'fails and shows an error if the Classroom does not exist', ->
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
request.respondWith({status: 404, responseText: JSON.stringify({})})
|
||||
expect(jasmine.Ajax.requests.all().length).toBe(1)
|
||||
expect(modal.$el.has('.has-error').length).toBeTruthy()
|
||||
describe 'the Classroom does not exist', ->
|
||||
it 'shows an error and clears the field', ->
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
console.log 'school input?', modal.$('#class-code-input').val()
|
||||
request.respondWith({status: 404, responseText: JSON.stringify({})})
|
||||
expect(jasmine.Ajax.requests.all().length).toBe(1)
|
||||
expect(modal.$el.has('.has-error').length).toBeTruthy()
|
||||
console.log 'school input?', modal.$('#class-code-input').val()
|
||||
expect(modal.$('#class-code-input').val()).toBe('')
|
||||
|
||||
|
||||
describe 'clicking the gplus button', ->
|
||||
|
|
Loading…
Reference in a new issue