forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntrySpec.coffee
More file actions
40 lines (35 loc) · 1.04 KB
/
Copy pathEntrySpec.coffee
File metadata and controls
40 lines (35 loc) · 1.04 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
define [
'compiled/models/Entry'
'helpers/fakeENV'
], (Entry, fakeENV) ->
QUnit.module 'Entry',
setup: ->
fakeENV.setup()
@user_id = 1
@server = sinon.fakeServer.create()
ENV.DISCUSSION = {
CURRENT_USER:
id: @user_id
DELETE_URL: 'discussions/:id/'
PERMISSIONS:
CAN_ATTACH: true
CAN_MANAGE_OWN: true
}
@entry = new Entry(id: 1, message: 'a comment, wooper', user_id: @user_id)
teardown: ->
fakeENV.teardown()
@server.restore()
# sync
test 'should persist replies locally, and call provided onComplete callback', ->
@server.respondWith([200, {}, ''])
replies = [new Entry(id: 2, message: 'a reply', parent_id: 1)]
@entry.set('replies', replies)
@setSpy = @spy(@entry, 'set')
onCompleteCallback = @spy()
@entry.sync('update', @entry, {
complete: onCompleteCallback
})
@server.respond()
ok @setSpy.calledWith('replies', [])
ok @setSpy.calledWith('replies', replies)
ok onCompleteCallback.called