codecombat/test/app/views/teachers/InviteToClassroomModal.spec.coffee

30 lines
1 KiB
CoffeeScript
Raw Normal View History

2016-06-09 13:24:47 -04:00
InviteToClassroomModal = require 'views/courses/InviteToClassroomModal'
User = require 'models/User'
factories = require 'test/app/factories'
describe 'InviteToClassroomModal', ->
modal = null
beforeEach (done) ->
window.me = @teacher = factories.makeUser()
@classroom = factories.makeClassroom({ code: "wordsouphere", codeCamel: "WordSoupHere", ownerID: @teacher.id })
modal = new InviteToClassroomModal({ @classroom })
jasmine.demoModal(modal)
modal.render()
_.defer done
describe 'Invite by email', ->
beforeEach (done) ->
@emails = ['test@example.com', 'test2@example.com']
modal.$('#invite-emails-textarea').val(@emails.join('\n'))
modal.$('#send-invites-btn').click()
_.defer done
it 'sends the request', (done) ->
request = jasmine.Ajax.requests.mostRecent()
expect(request.url).toBe("/db/classroom/#{@classroom.id}/invite-members")
expect(request.method).toBe("POST")
expect(request.data()['emails[]']).toEqual(@emails)
_.defer done