diff --git a/client/selectors/tests/events_test.ts b/client/selectors/tests/events_test.ts index 70cb37b26..cfdd99af2 100644 --- a/client/selectors/tests/events_test.ts +++ b/client/selectors/tests/events_test.ts @@ -67,9 +67,10 @@ describe('selectors', () => { '2017-01-14', '2017-01-15', '2017-01-16', + '2017-01-17', ]); - expect(Object.keys(events).includes('2017-01-17')).toBe(false); + expect(Object.keys(events).includes('2017-01-17')).toBe(true); expect(events['2017-01-14'].events.length).toBe(1); expect(events['2017-01-14'].events[0]._id).toBe('event3'); @@ -176,7 +177,7 @@ describe('selectors', () => { setAdvancedSearchDates(state, '2017-01-16T13:59:59+0000', '2017-01-17T08:00:00+0000'); const events = keyBy(selectors.events.orderedEvents(state), 'date'); - expect(Object.keys(events)).toEqual(['2017-01-16']); + expect(Object.keys(events)).toEqual(['2017-01-16', '2017-01-17']); expect(events['2017-01-16'].events.length).toBe(2); expect(events['2017-01-16'].events[0]._id).toBe('event3'); diff --git a/client/utils/events.ts b/client/utils/events.ts index 12f09d726..2d42eb4e9 100644 --- a/client/utils/events.ts +++ b/client/utils/events.ts @@ -890,11 +890,6 @@ function getEventsByDate(events: Array, startDate: moment.Moment, en // check if search exists // order by date let sortedEvents = events.sort((a, b) => a.dates.start - b.dates.start); - let maxStartDate = sortedEvents[sortedEvents.length - 1].dates.start; - - if (startDate.isAfter(maxStartDate, 'day')) { - maxStartDate = startDate; - } const days = {}; @@ -945,7 +940,7 @@ function getEventsByDate(events: Array, startDate: moment.Moment, en newDate.add(i, 'days'); - if (maxStartDate.isSameOrAfter(newDate, 'day') && newDate.isSameOrBefore(ending, 'day')) { + if (newDate.isSameOrBefore(ending, 'day')) { addEventToDate(event, newDate); } }