forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpDialogSpec.coffee
More file actions
60 lines (50 loc) · 1.92 KB
/
Copy pathhelpDialogSpec.coffee
File metadata and controls
60 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
define [
'jquery'
'compiled/helpDialog'
'helpers/fakeENV'
'vendor/jquery.ba-tinypubsub'
], ($,helpDialog,fakeENV)->
# more tests are in spec/selenium/help_dialog_spec.rb
QUnit.module 'HelpDialog',
setup: ->
fakeENV.setup({
help_link_name: 'Links'
})
helpDialog.animateDuration = 0
@server = sinon.fakeServer.create()
@server.respondWith '/help_links', '[]'
@server.respondWith '/api/v1/courses.json', '[]'
teardown: ->
fakeENV.teardown()
@server.restore()
# if we don't close it after each test, subsequent tests get messed up.
if helpDialog.$dialog?
helpDialog.$dialog.dialog('close')
helpDialog.$dialog = null
# reset the shared object
helpDialog.dialogInited = false
helpDialog.teacherFeedbackInited = false
$(".ui-dialog").remove()
$('[id^=ui-id-]').remove()
$("#help-dialog").remove()
$("#fixtures").empty()
test 'init', ->
$tester = $('<a class="help_dialog_trigger" />').appendTo('#fixtures')
helpDialog.initTriggers()
$tester.click()
ok $('.ui-dialog-content').is(':visible'), "help dialog appears when you click 'help' link"
equal $('.ui-dialog-title:contains("Links")').length, 1
$tester.remove()
test 'teacher feedback', ->
helpDialog.open()
@server.respond()
helpDialog.switchTo "#teacher_feedback"
ok helpDialog.$dialog.find('#teacher-feedback-body').is(':visible'), "textarea shows up"
test 'focus management', ->
helpDialog.open()
@server.respond()
helpDialog.switchTo "#create_ticket"
equal document.activeElement, helpDialog.$dialog.find('#error_subject')[0], 'focuses first input'
ok !helpDialog.$dialog.find('#help-dialog-options').is(':visible'), 'out of view screen is hidden'
helpDialog.switchTo "#help-dialog-options"
ok helpDialog.$dialog.find('#help-dialog-options').is(':visible'), 'menu screen appears again'