@@ -99,7 +99,7 @@ describe('uiCalendar', function () {
99
99
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . weekends ) . toEqual ( false ) ;
100
100
} ) ;
101
101
/* Test to make sure that when an event is added to the calendar everything is updated with the new event. */
102
- it ( 'expects that when events are added to the calendar the fullcalendar will call its addEvents method' , function ( ) {
102
+ it ( 'expects that when events are added to the calendar the fullcalendar will call its renderEvent method' , function ( ) {
103
103
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ) . toEqual ( 4 ) ;
104
104
expect ( $ . fn . fullCalendar . callCount ) . toEqual ( 1 ) ;
105
105
scope . addChild ( scope . events ) ;
@@ -111,89 +111,65 @@ describe('uiCalendar', function () {
111
111
expect ( $ . fn . fullCalendar . callCount ) . toEqual ( 3 ) ;
112
112
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ) . toEqual ( 'renderEvent' ) ;
113
113
} ) ;
114
- /* Test to make sure the calendar is calling the removeEvent function. */
115
- it ( 'expects the calendar to call removeEvents when some event is removed' , function ( ) {
116
- var clientCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ;
117
- expect ( clientCalls ) . toEqual ( 4 ) ;
118
- //remove an event from the scope.
119
- scope . remove ( scope . events , 0 ) ;
120
- scope . $apply ( ) ;
121
- //events should auto update inside the calendar.
122
- clientCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
123
- expect ( clientCalls ) . toEqual ( 'removeEvents' ) ;
124
- } ) ;
125
- /* Test to see if calendar is watching all eventSources for changes. */
126
- it ( 'updates the calendar if any eventSource array contains a delta' , function ( ) {
127
- var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ;
128
- var clientEventsLength2 = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 1 ] . length ;
129
- var callCount = $ . fn . fullCalendar . callCount ;
130
- expect ( calendarCalls ) . toEqual ( 4 ) ;
131
- expect ( clientEventsLength2 ) . toEqual ( 4 ) ;
132
- expect ( callCount ) . toEqual ( 1 ) ;
114
+ /* Test to see if calendar is calling removeEvents when an event is removed */
115
+ it ( 'removes the correct event from the event source.' , function ( ) {
133
116
//remove an event from the scope.
134
117
scope . remove ( scope . events2 , 0 ) ;
135
118
scope . $apply ( ) ;
136
119
//events should auto update inside the calendar.
137
- calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
138
- callCount = $ . fn . fullCalendar . callCount ;
139
- expect ( calendarCalls ) . toEqual ( 'removeEvents' ) ;
120
+ var fullCalendarParam = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
121
+ var callCount = $ . fn . fullCalendar . callCount ;
122
+ expect ( fullCalendarParam ) . toEqual ( 'removeEvents' ) ;
140
123
expect ( callCount ) . toEqual ( 2 ) ;
141
124
scope . remove ( scope . events , 0 ) ;
142
125
scope . $apply ( ) ;
143
- calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
126
+ fullCalendarParam = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
144
127
callCount = $ . fn . fullCalendar . callCount ;
145
- expect ( calendarCalls ) . toEqual ( 'removeEvents' ) ;
128
+ expect ( fullCalendarParam ) . toEqual ( 'removeEvents' ) ;
146
129
expect ( callCount ) . toEqual ( 3 ) ;
147
130
} ) ;
148
131
/* Test to see if calendar is updating when a new eventSource is added. */
149
132
it ( 'updates the calendar if an eventSource is Added' , function ( ) {
150
- var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources . length ;
151
- expect ( calendarCalls ) . toEqual ( 2 ) ;
152
- //add new source to calendar
153
133
scope . addSource ( scope . events4 ) ;
154
134
scope . $apply ( ) ;
155
135
//eventSources should auto update inside the calendar.
156
- calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
157
- expect ( calendarCalls ) . toEqual ( 'rerenderEvents' ) ;
136
+ var fullCalendarParam = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
137
+ expect ( fullCalendarParam ) . toEqual ( 'rerenderEvents' ) ;
158
138
} ) ;
159
139
/* Test to see if calendar is updating when an eventSource replaces another with an equal length. */
160
140
it ( 'updates the calendar if an eventSource has same length as prior eventSource' , function ( ) {
161
- var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources ;
162
- var callCount = $ . fn . fullCalendar . callCount ;
163
- expect ( calendarCalls [ 0 ] . length ) . toEqual ( 4 ) ;
164
- expect ( calendarCalls . length ) . toEqual ( 2 ) ;
165
- expect ( calendarCalls [ 1 ] [ 0 ] . title ) . toEqual ( 'All Day Event 2' ) ;
166
- expect ( callCount ) . toEqual ( 1 ) ;
167
141
//replace source with one that has the same length
168
142
scope . eventSources . splice ( 1 , 1 , scope . events3 ) ;
169
143
scope . $apply ( ) ;
170
144
//eventSources should update inside the calendar
171
- callCount = $ . fn . fullCalendar . callCount ;
172
- calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
173
- expect ( calendarCalls ) . toEqual ( 'rerenderEvents' ) ;
145
+ var callCount = $ . fn . fullCalendar . callCount ;
146
+ var fullCalendarParam = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
147
+ expect ( fullCalendarParam ) . toEqual ( 'rerenderEvents' ) ;
174
148
//fullcalendar has called 3 of its own events at this time. Remove, Add, and Rerender
175
149
expect ( callCount ) . toEqual ( 4 ) ;
176
150
//remove an event to prove autobinding still works
177
151
scope . remove ( scope . events , 0 ) ;
178
152
scope . $apply ( ) ;
179
- calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
180
- expect ( calendarCalls ) . toEqual ( 'removeEvents' ) ;
153
+ fullCalendarParam = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
154
+ callCount = $ . fn . fullCalendar . callCount ;
155
+ expect ( fullCalendarParam ) . toEqual ( 'removeEvents' ) ;
156
+ expect ( callCount ) . toEqual ( 5 ) ;
181
157
} ) ;
182
158
183
159
it ( 'make sure the calendar can work with extended event sources' , function ( ) {
184
- var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources ;
185
160
scope . eventSources . push ( scope . calEventsExt ) ;
186
161
scope . $apply ( ) ;
187
- calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
188
- expect ( calendarCalls ) . toEqual ( 'rerenderEvents' ) ;
162
+ var fullCalendarParam = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
163
+ expect ( fullCalendarParam ) . toEqual ( 'rerenderEvents' ) ;
189
164
} ) ;
190
165
191
166
it ( 'make sure that if we just change the title of the event that it updates itself' , function ( ) {
192
- var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources ;
193
167
scope . events [ 0 ] . title = 'change title' ;
194
168
scope . $apply ( ) ;
195
- calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
196
- expect ( calendarCalls ) . toEqual ( 'updateEvent' ) ;
169
+ var fullCalendarParam = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
170
+ var fullCalendarParam1 = $ . fn . fullCalendar . mostRecentCall . args [ 1 ] ;
171
+ expect ( fullCalendarParam ) . toEqual ( 'updateEvent' ) ;
172
+ expect ( fullCalendarParam1 ) . toEqual ( scope . events [ 0 ] ) ;
197
173
} ) ;
198
174
199
175
} ) ;
0 commit comments