@@ -81,72 +81,25 @@ describe('uiCalendar', function () {
81
81
} ) ) ;
82
82
83
83
describe ( 'compiling this directive and checking for events inside the calendar' , function ( ) {
84
-
85
- it ( 'sets names for $locale by default' , function ( ) {
84
+
85
+ beforeEach ( function ( ) {
86
86
spyOn ( $ . fn , 'fullCalendar' ) ;
87
- $locale . DATETIME_FORMATS . MONTH [ 0 ] = 'enero' ;
88
87
$compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
89
88
scope . $apply ( ) ;
90
- expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . monthNames [ 0 ] ) . toBe ( 'enero' ) ;
91
- } ) ;
92
-
93
- it ( 'allows overriding names for $locale' , function ( ) {
94
- spyOn ( $ . fn , 'fullCalendar' ) ;
95
- scope . uiConfig . calendar . monthNames = $locale . DATETIME_FORMATS . MONTH . slice ( ) ;
96
- scope . uiConfig . calendar . monthNames [ 0 ] = 'custom name' ;
97
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
98
- scope . $apply ( ) ;
99
- expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . monthNames [ 0 ] ) . toBe ( 'custom name' ) ;
100
89
} ) ;
101
90
102
- /* test the calendar's events length */
103
- it ( 'expects to load 4 events to scope' , function ( ) {
104
- spyOn ( $ . fn , 'fullCalendar' ) ;
105
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
106
- scope . $apply ( ) ;
91
+ /* test the calendar's initial setup */
92
+ it ( 'expects the calendar to be set up with the correct options and events' , function ( ) {
107
93
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ) . toBe ( 4 ) ;
108
- } ) ;
109
- /* test to check the title of the first event. */
110
- it ( 'expects to be All Day Event' , function ( ) {
111
- spyOn ( $ . fn , 'fullCalendar' ) ;
112
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
113
- scope . $apply ( ) ;
114
94
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] [ 0 ] . title ) . toBe ( 'All Day Event' ) ;
115
- } ) ;
116
- /* test to make sure the event has a url assigned to it. */
117
- it ( 'expects the url to = http://www.angularjs.org' , function ( ) {
118
- spyOn ( $ . fn , 'fullCalendar' ) ;
119
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
120
- scope . $apply ( ) ;
121
95
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] [ 0 ] . url ) . toBe ( 'http://www.angularjs.org' ) ;
122
96
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 1 ] [ 0 ] . url ) . toBe ( 'http://www.atlantacarlocksmith.com' ) ;
123
- } ) ;
124
- /* test the 3rd events' allDay field. */
125
- it ( 'expects the fourth Events all Day field to equal true' , function ( ) {
126
- spyOn ( $ . fn , 'fullCalendar' ) ;
127
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
128
- scope . $apply ( ) ;
129
97
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] [ 3 ] . allDay ) . toNotBe ( false ) ;
130
- } ) ;
131
- /* Tests the height of the calendar. */
132
- it ( 'expects the calendar attribute height to be 200' , function ( ) {
133
- spyOn ( $ . fn , 'fullCalendar' ) ;
134
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
135
- scope . $apply ( ) ;
136
98
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . height ) . toEqual ( 200 ) ;
137
- } ) ;
138
- /* Tests the weekends boolean of the calendar. */
139
- it ( 'expects the calendar attribute weekends to be false' , function ( ) {
140
- spyOn ( $ . fn , 'fullCalendar' ) ;
141
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
142
- scope . $apply ( ) ;
143
99
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . weekends ) . toEqual ( false ) ;
144
100
} ) ;
145
101
/* Test to make sure that when an event is added to the calendar everything is updated with the new event. */
146
102
it ( 'expects that when events are added to the calendar the fullcalendar will call its addEvents method' , function ( ) {
147
- spyOn ( $ . fn , 'fullCalendar' ) ;
148
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
149
- scope . $apply ( ) ;
150
103
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ) . toEqual ( 4 ) ;
151
104
expect ( $ . fn . fullCalendar . callCount ) . toEqual ( 1 ) ;
152
105
scope . addChild ( scope . events ) ;
@@ -158,11 +111,8 @@ describe('uiCalendar', function () {
158
111
expect ( $ . fn . fullCalendar . callCount ) . toEqual ( 3 ) ;
159
112
expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ) . toEqual ( 'renderEvent' ) ;
160
113
} ) ;
161
- /* Test to make sure the calendar is updating itself on changes to events length. */
162
- it ( 'expects the calendar to update itself with new events' , function ( ) {
163
- spyOn ( $ . fn , 'fullCalendar' ) ;
164
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
165
- scope . $apply ( ) ;
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 ( ) {
166
116
var clientCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ;
167
117
expect ( clientCalls ) . toEqual ( 4 ) ;
168
118
//remove an event from the scope.
@@ -172,25 +122,8 @@ describe('uiCalendar', function () {
172
122
clientCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
173
123
expect ( clientCalls ) . toEqual ( 'removeEvents' ) ;
174
124
} ) ;
175
- /* Test to make sure header options can be overwritten */
176
- it ( 'overwrites default header options' , function ( ) {
177
- spyOn ( $ . fn , 'fullCalendar' ) ;
178
- scope . uiConfig2 = {
179
- calendar :{
180
- header : { center : 'title' }
181
- }
182
- } ;
183
- $compile ( '<div ui-calendar="uiConfig2.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
184
- scope . $apply ( ) ;
185
- expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . hasOwnProperty ( 'header' ) ) . toEqual ( true ) ;
186
- var header = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . header ;
187
- expect ( header ) . toEqual ( { center : 'title' } ) ;
188
- } ) ;
189
125
/* Test to see if calendar is watching all eventSources for changes. */
190
126
it ( 'updates the calendar if any eventSource array contains a delta' , function ( ) {
191
- spyOn ( $ . fn , 'fullCalendar' ) ;
192
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
193
- scope . $apply ( ) ;
194
127
var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ;
195
128
var clientEventsLength2 = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 1 ] . length ;
196
129
var callCount = $ . fn . fullCalendar . callCount ;
@@ -214,9 +147,6 @@ describe('uiCalendar', function () {
214
147
} ) ;
215
148
/* Test to see if calendar is updating when a new eventSource is added. */
216
149
it ( 'updates the calendar if an eventSource is Added' , function ( ) {
217
- spyOn ( $ . fn , 'fullCalendar' ) ;
218
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
219
- scope . $apply ( ) ;
220
150
var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources . length ;
221
151
expect ( calendarCalls ) . toEqual ( 2 ) ;
222
152
//add new source to calendar
@@ -228,9 +158,6 @@ describe('uiCalendar', function () {
228
158
} ) ;
229
159
/* Test to see if calendar is updating when an eventSource replaces another with an equal length. */
230
160
it ( 'updates the calendar if an eventSource has same length as prior eventSource' , function ( ) {
231
- spyOn ( $ . fn , 'fullCalendar' ) ;
232
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
233
- scope . $apply ( ) ;
234
161
var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources ;
235
162
var callCount = $ . fn . fullCalendar . callCount ;
236
163
expect ( calendarCalls [ 0 ] . length ) . toEqual ( 4 ) ;
@@ -254,22 +181,19 @@ describe('uiCalendar', function () {
254
181
} ) ;
255
182
256
183
it ( 'make sure the calendar can work with extended event sources' , function ( ) {
257
- spyOn ( $ . fn , 'fullCalendar' ) ;
258
- $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
259
- scope . $apply ( ) ;
260
184
var calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources ;
261
- var clientEventsLength = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . eventSources [ 0 ] . length ;
262
185
scope . eventSources . push ( scope . calEventsExt ) ;
263
186
scope . $apply ( ) ;
264
187
calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
265
188
expect ( calendarCalls ) . toEqual ( 'rerenderEvents' ) ;
266
189
} ) ;
267
190
268
- it ( 'make sure the calendar sets the myCalendar object to defining scope ' , function ( ) {
269
- expect ( scope . myCalendar ) . toBe ( undefined ) ;
270
- $compile ( '<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>' ) ( scope ) ;
191
+ 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
+ scope . events [ 0 ] . title = 'change title' ;
271
194
scope . $apply ( ) ;
272
- expect ( scope . myCalendar ) . not . toBe ( undefined ) ;
195
+ calendarCalls = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] ;
196
+ expect ( calendarCalls ) . toEqual ( 'updateEvent' ) ;
273
197
} ) ;
274
198
275
199
} ) ;
@@ -385,4 +309,53 @@ describe('uiCalendar', function () {
385
309
386
310
} ) ;
387
311
312
+ describe ( 'Testing the ability to add calendars to the scope' , function ( ) {
313
+
314
+ beforeEach ( function ( ) {
315
+ spyOn ( $ . fn , 'fullCalendar' ) ;
316
+ expect ( scope . myCalendar ) . toBe ( undefined ) ;
317
+ $compile ( '<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>' ) ( scope ) ;
318
+ scope . $apply ( ) ;
319
+ } ) ;
320
+
321
+ it ( 'make sure the calendar sets the myCalendar object to the defining scope' , function ( ) {
322
+ expect ( scope . myCalendar ) . not . toBe ( undefined ) ;
323
+ } ) ;
324
+ } ) ;
325
+
326
+ describe ( 'Local variable config testing and option overriding' , function ( ) {
327
+
328
+ it ( 'sets names for $locale by default' , function ( ) {
329
+ spyOn ( $ . fn , 'fullCalendar' ) ;
330
+ $locale . DATETIME_FORMATS . MONTH [ 0 ] = 'enero' ;
331
+ $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
332
+ scope . $apply ( ) ;
333
+ expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . monthNames [ 0 ] ) . toBe ( 'enero' ) ;
334
+ } ) ;
335
+
336
+ it ( 'allows overriding names for $locale' , function ( ) {
337
+ spyOn ( $ . fn , 'fullCalendar' ) ;
338
+ scope . uiConfig . calendar . monthNames = $locale . DATETIME_FORMATS . MONTH . slice ( ) ;
339
+ scope . uiConfig . calendar . monthNames [ 0 ] = 'custom name' ;
340
+ $compile ( '<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
341
+ scope . $apply ( ) ;
342
+ expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . monthNames [ 0 ] ) . toBe ( 'custom name' ) ;
343
+ } ) ;
344
+
345
+ /* Test to make sure header options can be overwritten */
346
+ it ( 'overwrites default header options' , function ( ) {
347
+ spyOn ( $ . fn , 'fullCalendar' ) ;
348
+ scope . uiConfig2 = {
349
+ calendar :{
350
+ header : { center : 'title' }
351
+ }
352
+ } ;
353
+ $compile ( '<div ui-calendar="uiConfig2.calendar" ng-model="eventSources"></div>' ) ( scope ) ;
354
+ scope . $apply ( ) ;
355
+ expect ( $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . hasOwnProperty ( 'header' ) ) . toEqual ( true ) ;
356
+ var header = $ . fn . fullCalendar . mostRecentCall . args [ 0 ] . header ;
357
+ expect ( header ) . toEqual ( { center : 'title' } ) ;
358
+ } ) ;
359
+ } ) ;
360
+
388
361
} ) ;
0 commit comments