forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollaborationsSpec.coffee
More file actions
57 lines (50 loc) · 2.11 KB
/
Copy pathCollaborationsSpec.coffee
File metadata and controls
57 lines (50 loc) · 2.11 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
define ['collaborations', 'jquery', 'jquery.ajaxJSON'], (collaborations, $) ->
oldAjaxJSON = null
QUnit.module "Collaborations",
setup: ->
oldAjaxJSON = $.ajaxJSON
link= $("<a></a>")
link.addClass("delete_collaboration_link")
link.attr('href', "http://test.com")
dialog = $('<div id=delete_collaboration_dialog></div>').data('collaboration', link)
dialog.dialog
width: 550
height: 500
resizable: false
dom = $("<div></div>")
dom.append(dialog)
$("#fixtures").append(dom)
teardown: ->
$("#delete_collaboration_dialog").remove()
$("#fixtures").empty()
$.ajaxJSON = oldAjaxJSON
test "shows a flash message when deletion is complete", ->
@spy($, 'screenReaderFlashMessage')
e = {
originalEvent: MouseEvent,
type: "click",
timeStamp: 1433863761376,
jQuery17209791898143012077: true
}
$.ajaxJSON = (url, method, data, callback)->
responseData = {}
callback.call(responseData)
collaborations.Events.onDelete(e)
equal $.screenReaderFlashMessage.callCount, 1
test "returns a collaboration url", ->
url = collaborations.Util.collaborationUrl(1)
equal url, window.location.toString() + "/1"
test "it calls updateCollaboration when a service id is in the data parameter", ->
@stub(collaborations.Events, 'updateCollaboration')
collaborations.Events.onExternalContentReady({}, {service_id: 1, contentItems: {}})
equal collaborations.Events.updateCollaboration.callCount, 1
test "it calls createCollaboration", ->
@stub(collaborations.Events, 'createCollaboration')
collaborations.Events.onExternalContentReady({}, {contentItems: {}})
equal collaborations.Events.createCollaboration.callCount, 1
test "it makes an ajax request to the correct update endpoint", ->
dom = $('<div class="collaboration_1"><a class="title" href="http://url/"></a></div>')
$("#fixtures").append(dom)
$.ajaxJSON = (url, method, data, callback)->
equal url, 'http://url/'
collaborations.Events.onExternalContentReady({}, {service_id: 1, contentItems: {}})