Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit ab88d5f

Browse files
committed
tests(calendar.js) added a test for the calendar attribute and got rid of the other tests with calendar attributes
Signed-off-by: Josh Kurz <josh.kurz@turner.com>
1 parent 6355b83 commit ab88d5f

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

test/calendar.spec.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('uiCalendar', function () {
8585
it('sets names for $locale by default', function() {
8686
spyOn($.fn, 'fullCalendar');
8787
$locale.DATETIME_FORMATS.MONTH[0] = 'enero';
88-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
88+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
8989
scope.$apply();
9090
expect($.fn.fullCalendar.mostRecentCall.args[0].monthNames[0]).toBe('enero');
9191
});
@@ -94,58 +94,58 @@ describe('uiCalendar', function () {
9494
spyOn($.fn, 'fullCalendar');
9595
scope.uiConfig.calendar.monthNames = $locale.DATETIME_FORMATS.MONTH.slice();
9696
scope.uiConfig.calendar.monthNames[0] = 'custom name';
97-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
97+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
9898
scope.$apply();
9999
expect($.fn.fullCalendar.mostRecentCall.args[0].monthNames[0]).toBe('custom name');
100100
});
101101

102102
/* test the calendar's events length */
103103
it('expects to load 4 events to scope', function () {
104104
spyOn($.fn, 'fullCalendar');
105-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
105+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
106106
scope.$apply();
107107
expect($.fn.fullCalendar.mostRecentCall.args[0].eventSources[0].length).toBe(4);
108108
});
109109
/* test to check the title of the first event. */
110110
it('expects to be All Day Event', function () {
111111
spyOn($.fn, 'fullCalendar');
112-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
112+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
113113
scope.$apply();
114114
expect($.fn.fullCalendar.mostRecentCall.args[0].eventSources[0][0].title).toBe('All Day Event');
115115
});
116116
/* test to make sure the event has a url assigned to it. */
117117
it('expects the url to = http://www.angularjs.org', function () {
118118
spyOn($.fn, 'fullCalendar');
119-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
119+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
120120
scope.$apply();
121121
expect($.fn.fullCalendar.mostRecentCall.args[0].eventSources[0][0].url).toBe('http://www.angularjs.org');
122122
expect($.fn.fullCalendar.mostRecentCall.args[0].eventSources[1][0].url).toBe('http://www.atlantacarlocksmith.com');
123123
});
124124
/* test the 3rd events' allDay field. */
125125
it('expects the fourth Events all Day field to equal true', function () {
126126
spyOn($.fn, 'fullCalendar');
127-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
127+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
128128
scope.$apply();
129129
expect($.fn.fullCalendar.mostRecentCall.args[0].eventSources[0][3].allDay).toNotBe(false);
130130
});
131131
/* Tests the height of the calendar. */
132132
it('expects the calendar attribute height to be 200', function () {
133133
spyOn($.fn, 'fullCalendar');
134-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
134+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
135135
scope.$apply();
136136
expect($.fn.fullCalendar.mostRecentCall.args[0].height).toEqual(200);
137137
});
138138
/* Tests the weekends boolean of the calendar. */
139139
it('expects the calendar attribute weekends to be false', function () {
140140
spyOn($.fn, 'fullCalendar');
141-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
141+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
142142
scope.$apply();
143143
expect($.fn.fullCalendar.mostRecentCall.args[0].weekends).toEqual(false);
144144
});
145145
/* Test to make sure that when an event is added to the calendar everything is updated with the new event. */
146146
it('expects the scopes events to increase by 2', function () {
147147
spyOn($.fn, 'fullCalendar');
148-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
148+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
149149
scope.$apply();
150150
expect($.fn.fullCalendar.mostRecentCall.args[0].eventSources[0].length).toEqual(4);
151151
scope.addChild(scope.events);
@@ -155,7 +155,7 @@ describe('uiCalendar', function () {
155155
/* Test to make sure the calendar is updating itself on changes to events length. */
156156
it('expects the calendar to update itself with new events', function () {
157157
spyOn($.fn, 'fullCalendar');
158-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
158+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
159159
scope.$apply();
160160
var clientEventsLength = $.fn.fullCalendar.mostRecentCall.args[0].eventSources[0].length;
161161
expect(clientEventsLength).toEqual(4);
@@ -173,7 +173,7 @@ describe('uiCalendar', function () {
173173
header: {center: 'title'}
174174
}
175175
};
176-
$compile('<div ui-calendar="uiConfig2.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
176+
$compile('<div ui-calendar="uiConfig2.calendar" ng-model="eventSources"></div>')(scope);
177177
scope.$apply();
178178
expect($.fn.fullCalendar.mostRecentCall.args[0].hasOwnProperty('header')).toEqual(true);
179179
var header = $.fn.fullCalendar.mostRecentCall.args[0].header;
@@ -182,7 +182,7 @@ describe('uiCalendar', function () {
182182
/* Test to see if calendar is watching all eventSources for changes. */
183183
it('updates the calendar if any eventSource array contains a delta', function () {
184184
spyOn($.fn, 'fullCalendar');
185-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
185+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
186186
scope.$apply();
187187
var clientEventsLength = $.fn.fullCalendar.mostRecentCall.args[0].eventSources[0].length;
188188
var clientEventsLength2 = $.fn.fullCalendar.mostRecentCall.args[0].eventSources[1].length;
@@ -202,7 +202,7 @@ describe('uiCalendar', function () {
202202
/* Test to see if calendar is updating when a new eventSource is added. */
203203
it('updates the calendar if an eventSource is Added', function () {
204204
spyOn($.fn, 'fullCalendar');
205-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
205+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
206206
scope.$apply();
207207
var clientEventSources = $.fn.fullCalendar.mostRecentCall.args[0].eventSources.length;
208208
expect(clientEventSources).toEqual(2);
@@ -219,7 +219,7 @@ describe('uiCalendar', function () {
219219
/* Test to see if calendar is updating when an eventSource replaces another with an equal length. */
220220
it('updates the calendar if an eventSource has same length as prior eventSource', function () {
221221
spyOn($.fn, 'fullCalendar');
222-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
222+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
223223
scope.$apply();
224224
var clientEventSources = $.fn.fullCalendar.mostRecentCall.args[0].eventSources;
225225
var clientEventsLength = $.fn.fullCalendar.mostRecentCall.args[0].eventSources[0].length;
@@ -240,7 +240,7 @@ describe('uiCalendar', function () {
240240

241241
it('make sure the calendar can work with extended event sources', function () {
242242
spyOn($.fn, 'fullCalendar');
243-
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
243+
$compile('<div ui-calendar="uiConfig.calendar" ng-model="eventSources"></div>')(scope);
244244
scope.$apply();
245245
var clientEventSources = $.fn.fullCalendar.mostRecentCall.args[0].eventSources;
246246
var clientEventsLength = $.fn.fullCalendar.mostRecentCall.args[0].eventSources[0].length;
@@ -250,6 +250,13 @@ describe('uiCalendar', function () {
250250
expect(clientEventSources[2].events[0].title).toEqual('Lunch');
251251
});
252252

253+
it('make sure the calendar sets the myCalendar object to defining scope', function () {
254+
expect(scope.myCalendar).toBe(undefined);
255+
$compile('<div ui-calendar="uiConfig.calendar" calendar="myCalendar" ng-model="eventSources"></div>')(scope);
256+
scope.$apply();
257+
expect(scope.myCalendar).not.toBe(undefined);
258+
});
259+
253260
});
254261

255262
describe('calendarCtrl', function(){

0 commit comments

Comments
 (0)