forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWikiPageIndexItemViewSpec.coffee
More file actions
85 lines (69 loc) · 2.08 KB
/
Copy pathWikiPageIndexItemViewSpec.coffee
File metadata and controls
85 lines (69 loc) · 2.08 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
define [
'compiled/models/WikiPage'
'compiled/views/wiki/WikiPageIndexItemView'
], (WikiPage, WikiPageIndexItemView) ->
QUnit.module 'WikiPageIndexItemView'
test 'model.view maintained by item view', ->
model = new WikiPage
view = new WikiPageIndexItemView
model: model
strictEqual model.view, view, 'model.view is set to the item view'
view.render()
strictEqual model.view, view, 'model.view is set to the item view'
test 'detach/reattach the publish icon view', ->
model = new WikiPage
view = new WikiPageIndexItemView
model: model
view.render()
$previousEl = view.$el.find('> *:first-child')
view.publishIconView.$el.data('test-data', 'test-is-good')
view.render()
equal $previousEl.parent().length, 0, 'previous content removed'
equal view.publishIconView.$el.data('test-data'), 'test-is-good', 'test data preserved (by detach)'
test 'delegate useAsFrontPage to the model', ->
model = new WikiPage
front_page: false
published: true
view = new WikiPageIndexItemView
model: model
stub = @stub(model, 'setFrontPage')
view.useAsFrontPage()
ok stub.calledOnce
QUnit.module 'WikiPageIndexItemView:JSON'
testRights = (subject, options) ->
test "#{subject}", ->
model = new WikiPage
view = new WikiPageIndexItemView
model: model
contextName: options.contextName
WIKI_RIGHTS: options.WIKI_RIGHTS
json = view.toJSON()
for key of options.CAN
strictEqual json.CAN[key], options.CAN[key], "CAN.#{key}"
testRights 'CAN (manage course)',
contextName: 'courses'
WIKI_RIGHTS:
read: true
manage: true
CAN:
MANAGE: true
PUBLISH: true
testRights 'CAN (manage group)',
contextName: 'groups'
WIKI_RIGHTS:
read: true
manage: true
CAN:
MANAGE: true
PUBLISH: false
testRights 'CAN (read)',
contextName: 'courses'
WIKI_RIGHTS:
read: true
CAN:
MANAGE: false
PUBLISH: false
testRights 'CAN (null)',
CAN:
MANAGE: false
PUBLISH: false