forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommonEventSpec.coffee
More file actions
122 lines (106 loc) · 3.41 KB
/
Copy pathCommonEventSpec.coffee
File metadata and controls
122 lines (106 loc) · 3.41 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
define [
'compiled/calendar/CommonEvent'
'compiled/calendar/commonEventFactory'
'helpers/fakeENV'
], (CommonEvent, commonEventFactory, fakeENV) ->
QUnit.module "CommonEvent",
setup: ->
teardown: ->
test 'CommonEvent: should prevent assignment-due events from wrapping to the next day', ->
event = commonEventFactory
assignment:
due_at: '2016-02-25T23:30:00Z'
,
['course_1']
equal event.end.date(), 26
equal event.end.hours(), 0
equal event.end.minutes(), 0
test 'CommonEvent: should expand assignments to occupy 30 minutes so they are readable', ->
event = commonEventFactory
assignment:
due_at: '2016-02-25T23:59:00Z'
,
['course_1']
equal event.start.date(), 25
equal event.start.hours(), 23
equal event.start.minutes(), 30
equal event.end.date(), 26
equal event.end.hours(), 0
equal event.end.minutes(), 0
test 'CommonEvent: should leave events with defined end times alone', ->
event = commonEventFactory
title: 'Not an assignment'
start_at: '2016-02-25T23:30:00Z'
end_at: '2016-02-26T00:30:00Z'
,
['course_1']
equal event.end.date(), 26
equal event.end.hours(), 0
equal event.end.minutes(), 30
test 'CommonEvent: isOnCalendar', ->
event = commonEventFactory
title: 'blah',
start_at: '2016-02-25T23:30:00Z',
all_context_codes: 'course_1,course_23'
,
['course_1', 'course_23']
ok event.isOnCalendar('course_1')
ok event.isOnCalendar('course_23')
notOk event.isOnCalendar('course_2')
test 'commonEventFactory: finds a context for multi-context events', ->
event = commonEventFactory
title:"Another Dang Thing"
start_at:"2016-10-02T10:00:00Z"
type:"event"
effective_context_code:"course_2,course_4"
context_code:"user_2"
all_context_codes:"course_2,course_4"
parent_event_id:"172"
appointment_group_id:"2"
appointment_group_url:"http://localhost:3000/api/v1/appointment_groups/2"
own_reservation:true
,
[{asset_string: 'course_2'}]
notOk event == null
QUnit.module 'CommonEvent#iconType',
setup: ->
fakeENV.setup({
CALENDAR: {
BETTER_SCHEDULER: true
}
})
teardown: ->
fakeENV.teardown()
test 'Returns "calendar-add" for non-filled groups', ->
event = commonEventFactory
title: 'some title'
start_at: '2016-12-01T12:30:00Z'
appointment_group_url: 'http://some_url'
,
['course_1']
ok event.iconType() == 'calendar-add'
test 'Returns "calendar-reserved" for filled groups', ->
event = commonEventFactory
title: 'some title'
start_at: '2016-12-01T12:30:00Z'
appointment_group_url: 'http://some_url'
child_events: [{}]
,
['course_1']
ok event.iconType() == 'calendar-reserved'
test 'Returns "calendar-reserved" when the appointmentGroupEventStatus is "Reserved"', ->
event = commonEventFactory
title: 'some title'
start_at: '2016-12-01T12:30:00Z'
appointment_group_url: 'http://some_url'
,
['course_1']
event.appointmentGroupEventStatus = "Reserved"
ok event.iconType() == 'calendar-reserved'
test 'Returns "calendar-month" for other situations', ->
event = commonEventFactory
title: 'some title'
start_at: '2016-12-01T12:30:00Z'
,
['course_1']
ok event.iconType() == 'calendar-month'