Browse Source

fixes #3843 - bug with listview events going out-of-range

Adam Shaw 8 years ago
parent
commit
1aa6e2fad5
2 changed files with 45 additions and 2 deletions
  1. 1 0
      src/list/ListView.js
  2. 44 2
      tests/legacy/ListView.js

+ 1 - 0
src/list/ListView.js

@@ -106,6 +106,7 @@ var ListView = FC.ListView = View.extend({
 				// and mutate the latest seg to the be the end.
 				if (
 					!seg.isEnd && !footprint.isAllDay &&
+					dayIndex + 1 < dayRanges.length &&
 					footprint.unzonedRange.endMs < dayRanges[dayIndex + 1].startMs + this.nextDayThreshold
 				) {
 					seg.endMs = footprint.unzonedRange.endMs;

+ 44 - 2
tests/legacy/ListView.js

@@ -162,6 +162,9 @@ describe('ListView rendering', function() {
 		describe('when multi-day', function() {
 			beforeEach(function() {
 				options.nextDayThreshold = '00:00';
+			});
+
+			it('renders partial and full days', function() {
 				options.events = [
 					{
 						title: 'event 1',
@@ -169,21 +172,60 @@ describe('ListView rendering', function() {
 						end: '2016-08-17T11:00'
 					}
 				];
+				$('#cal').fullCalendar(options);
+
+				var events = getEventInfo();
+
+				expect(events.length).toBe(3);
+				expect(events[0].title).toBe('event 1');
+				expect(events[0].timeText).toBe('7:00am - 12:00am');
+				expect(events[1].title).toBe('event 1');
+				expect(events[1].timeText).toBe('all-day');
+				expect(events[2].title).toBe('event 1');
+				expect(events[2].timeText).toBe('12:00am - 11:00am');
 			});
 
-			it('renders partial and full days', function() {
+			it('truncates an out-of-range start', function() {
+				options.events = [
+					{
+						title: 'event 1',
+						start: '2016-08-13T07:00',
+						end: '2016-08-16T11:00'
+					}
+				];
 				$('#cal').fullCalendar(options);
 
 				var events = getEventInfo();
 
 				expect(events.length).toBe(3);
 				expect(events[0].title).toBe('event 1');
-				expect(events[0].timeText).toBe('7:00am - 12:00am');
+				expect(events[0].timeText).toBe('all-day');
 				expect(events[1].title).toBe('event 1');
 				expect(events[1].timeText).toBe('all-day');
 				expect(events[2].title).toBe('event 1');
 				expect(events[2].timeText).toBe('12:00am - 11:00am');
 			});
+
+			it('truncates an out-of-range start', function() {
+				options.events = [
+					{
+						title: 'event 1',
+						start: '2016-08-18T07:00',
+						end: '2016-08-21T11:00'
+					}
+				];
+				$('#cal').fullCalendar(options);
+
+				var events = getEventInfo();
+
+				expect(events.length).toBe(3);
+				expect(events[0].title).toBe('event 1');
+				expect(events[0].timeText).toBe('7:00am - 12:00am');
+				expect(events[1].title).toBe('event 1');
+				expect(events[1].timeText).toBe('all-day');
+				expect(events[2].title).toBe('event 1');
+				expect(events[2].timeText).toBe('all-day');
+			});
 		});
 
 		it('renders same days when equal to nextDayThreshold', function() {