Skip to content

Commit 0682868

Browse files
committed
fix: mark session as ongoing as soon as they start
... not after they have started
1 parent e57655c commit 0682868

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/ongoingSessions.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,21 @@ describe('ongoingSessions()', () => {
3737
'1545@Main hall': `You can have sessions at the same time, too!`,
3838
})
3939
})
40+
41+
it('should not highlight the last session on the next day', () => {
42+
const now = new Date('2022-03-12T08:00:00+01:00')
43+
expect(ongoingSessions(makeSchedule(now), now)).toEqual({})
44+
})
45+
46+
it('should not mark the first session before begin', () => {
47+
const now = new Date('2022-03-11T08:59:59.999+01:00')
48+
expect(ongoingSessions(makeSchedule(now), now)).toEqual({})
49+
})
50+
51+
it('should mark sessions exactly when they start', () => {
52+
const now = new Date('2022-03-11T09:00:00+01:00')
53+
expect(ongoingSessions(makeSchedule(now), now)).toEqual({
54+
900: 'Arrival & Breakfast',
55+
})
56+
})
4057
})

src/ongoingSessions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export const ongoingSessions = (
3232
// Filter out future sessions
3333
.filter(
3434
([timeWithTrack, session]) =>
35-
timeWithTrackToUTC(timeWithTrack, schedule).getTime() < now.getTime(),
35+
timeWithTrackToUTC(timeWithTrack, schedule).getTime() <=
36+
now.getTime(),
3637
)
3738
// Check of next is ongoing
3839
.filter(([timeWithTrack], i, sessions) => {

0 commit comments

Comments
 (0)