Przeglądaj źródła

tests for dynamic timezone

Adam Shaw 9 lat temu
rodzic
commit
be2c2eaf10
2 zmienionych plików z 45 dodań i 0 usunięć
  1. 21 0
      tests/automated/events-function.js
  2. 24 0
      tests/automated/timezone.js

+ 21 - 0
tests/automated/events-function.js

@@ -86,6 +86,27 @@ describe('events as a function', function() {
 		$('#cal').fullCalendar(options);
 	});
 
+	it('requests correctly when timezone changed dynamically', function(done) {
+		var callCnt = 0;
+
+		options.timezone = 'America/Chicago';
+		options.events = function(start, end, timezone, callback) {
+			callCnt++;
+			if (callCnt === 1) {
+				expect(timezone).toEqual('America/Chicago');
+				setTimeout(function() {
+					$('#cal').fullCalendar('option', 'timezone', 'UTC');
+				}, 0);
+			}
+			else if (callCnt === 2) {
+				expect(timezone).toEqual('UTC');
+				done();
+			}
+		};
+
+		$('#cal').fullCalendar(options);
+	});
+
 	it('requests correctly with event source extended form', function(done) {
 		var eventSource = {
 			className: 'customeventclass',

+ 24 - 0
tests/automated/timezone.js

@@ -130,4 +130,28 @@ describe('timezone', function() {
 		expect(zonedEvent.start.format()).toEqual('2014-05-10T14:00:00+11:00');
 	}
 
+
+	it('can be set dynamically', function(done) {
+		var callCnt = 0;
+		var rootEl;
+
+		options.timezone = false;
+		options.eventAfterAllRender = function() {
+			callCnt++;
+			if (callCnt === 1) {
+				expectNoTimezone();
+				rootEl = $('.fc-view > *:first');
+				expect(rootEl.length).toBe(1);
+				$('#cal').fullCalendar('option', 'timezone', 'UTC'); // will cause second call...
+			}
+			else if (callCnt === 2) {
+				expectUtcTimezone();
+				expect($('.fc-view > *:first')[0]).toBe(rootEl[0]); // ensure didn't rerender whole calendar
+				done();
+			}
+		};
+
+		$('#cal').fullCalendar(options);
+	});
+
 });