forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoogleDocsTreeViewSpec.coffee
More file actions
44 lines (34 loc) · 1.51 KB
/
Copy pathGoogleDocsTreeViewSpec.coffee
File metadata and controls
44 lines (34 loc) · 1.51 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
define ['jquery', 'compiled/views/GoogleDocsTreeView'], ($, GoogleDocsTreeView) ->
file1 = { name: 'File 1', extension: 'tst', document_id: '12345', alternate_url: {href: '#'}}
fileData = { files: [file1] }
folderData = { folders: [ { name: 'Folder 1', files: [file1] } ] }
QUnit.module 'GoogleDocsTreeView'
test 'renders a top level file', ()->
tree = new GoogleDocsTreeView({model: fileData})
tree.render()
equal tree.$el.html().match(/>File 1<\/span>/).length, 1
test 'gives the file link a title', ()->
tree = new GoogleDocsTreeView({model: fileData})
tree.render()
equal tree.$el.html().match(/title="View in Separate Window"/).length, 1
test 'renders a folder', ()->
tree = new GoogleDocsTreeView({model: folderData})
tree.render()
equal tree.$el.html().match(/<li class="folder.*\n\s+Folder 1/).length, 1
test 'gives a nested file link a title', ()->
tree = new GoogleDocsTreeView({model: folderData})
tree.render()
equal tree.$el.html().match(/title="View in Separate Window"/).length, 1
test 'activateFile triggers an event', ()->
tree = new GoogleDocsTreeView({model: fileData})
tree.on 'activate-file', (file_id)->
equal file_id, file1.document_id
tree.render()
tree.$('li.file').click()
test 'activateFolder delegates through to clicking the sign', ()->
expect 1
tree = new GoogleDocsTreeView({model: folderData})
tree.render()
tree.$(".sign").on 'click', ()->
ok 'got clicked'
tree.$('li.folder').click()