forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectContentDialogSpec.coffee
More file actions
71 lines (63 loc) · 2.31 KB
/
Copy pathSelectContentDialogSpec.coffee
File metadata and controls
71 lines (63 loc) · 2.31 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
61
62
63
64
65
66
67
68
69
70
71
define [
'select_content_dialog',
'jquery',
'helpers/fakeENV'
], (SelectContentDialog, $, fakeENV) ->
fixtures = null
clickEvent = {}
QUnit.module "SelectContentDialog",
setup: ->
fixtures = document.getElementById('fixtures')
fixtures.innerHTML = '<div id="context_external_tools_select">
<div class="tools"><div id="test-tool" class="tool resource_selection"></div></div></div>'
$l = $(document.getElementById('test-tool'))
clickEvent = {
originalEvent: MouseEvent,
type: "click",
timeStamp: 1433863761376,
jQuery17209791898143012077: true,
preventDefault: ()->
}
$l.data('tool', {
placements: {
resource_selection: {}
}
})
teardown: ->
$(window).off('beforeunload')
clickEvent = {}
fixtures.innerHTML = ""
test "it creates a confirm alert before closing the modal", ()->
l = document.getElementById('test-tool')
@stub(window, "confirm").returns(true)
SelectContentDialog.Events.onContextExternalToolSelect.bind(l)(clickEvent)
$dialog = $("#resource_selection_dialog")
$dialog.dialog('close')
ok window.confirm.called
test "it includes the tab-helper element", () ->
$dialog = $("#resource_selection_dialog")
ok $($dialog).find('#tab-helper').length
test 'tab-helper element is not visible after it has been blurred', ->
$dialog = $("#resource_selection_dialog")
$tabHelper = $($dialog).find('#tab-helper')
$($tabHelper).focus()
$($tabHelper).blur()
equal $($tabHelper).height(), 0
test 'tab-helper element is visible when focused', ->
$dialog = $("#resource_selection_dialog")
$tabHelper = $($dialog).find('#tab-helper')
$($tabHelper).focus()
equal $($tabHelper).height(), 35
test "it removes the confim alert if a selection is passed back", ()->
l = document.getElementById('test-tool')
@mock(window).expects("confirm").never()
SelectContentDialog.Events.onContextExternalToolSelect.bind(l)(clickEvent)
$dialog = $("#resource_selection_dialog")
selectionEvent = $.Event( "selection", { contentItems: [{
"@type": 'LtiLinkItem',
url: 'http://canvas.instructure.com/test',
placementAdvice: {
presentationDocumentTarget: ""
}
}] } )
$dialog.trigger(selectionEvent)