forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserSettingsSpec.coffee
More file actions
49 lines (37 loc) · 1.25 KB
/
Copy pathuserSettingsSpec.coffee
File metadata and controls
49 lines (37 loc) · 1.25 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
define [
'compiled/userSettings'
], (userSettings)->
globalObj = this
QUnit.module 'UserSettings',
setup: ->
@_ENV = globalObj.ENV
globalObj.ENV =
current_user_id: 1
context_asset_string: 'course_1'
userSettings.globalEnv = globalObj.ENV
teardown: ->
globalObj.ENV = @_ENV
test '`get` should return what was `set`', ->
userSettings.set('foo', 'bar')
equal userSettings.get('foo'), 'bar'
test 'it should strigify/parse JSON', ->
testObject =
foo: [1, 2, 3]
bar: 'true'
baz: true
userSettings.set('foo', testObject)
deepEqual userSettings.get('foo'), testObject
test 'it should store different things for different users', ->
userSettings.set('foo', 1)
globalObj.ENV.current_user_id = 2
userSettings.set('foo', 2)
equal userSettings.get('foo'), 2
globalObj.ENV.current_user_id = 1
equal userSettings.get('foo'), 1
test 'it should store different things for different contexts', ->
userSettings.contextSet('foo', 1)
globalObj.ENV.context_asset_string = 'course_2'
userSettings.contextSet('foo', 2)
equal userSettings.contextGet('foo'), 2
globalObj.ENV.context_asset_string = 'course_1'
equal userSettings.contextGet('foo'), 1