mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
refactor(planner): the weekday index of a plan day lives with the place opening state
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { resolveOpenNow, resolvePlaceTimeZone, placeWeekdayIndex } from './placeOpenState';
|
||||
import { getWeekdayIndex, resolveOpenNow, resolvePlaceTimeZone, placeWeekdayIndex } from './placeOpenState';
|
||||
import type { OpeningPeriod } from './placeOpenState';
|
||||
|
||||
// Seoul is UTC+9, Paris UTC+2 in summer — far enough apart that a viewer's clock and
|
||||
@@ -56,6 +56,18 @@ describe('placeWeekdayIndex', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getWeekdayIndex', () => {
|
||||
it('FE-PLANNER-OPENSTATE-023: reads a plan day by its own date, Monday first', () => {
|
||||
expect(getWeekdayIndex('2026-07-27', 'Asia/Seoul')).toBe(0);
|
||||
expect(getWeekdayIndex('2026-08-02', null)).toBe(6);
|
||||
});
|
||||
|
||||
it('FE-PLANNER-OPENSTATE-024: a day without a date reads today in the place timezone', () => {
|
||||
expect(getWeekdayIndex(null, 'UTC')).toBe(placeWeekdayIndex(new Date(), 'UTC'));
|
||||
expect(getWeekdayIndex(undefined, null)).toBe(placeWeekdayIndex(new Date(), null));
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveOpenNow', () => {
|
||||
it('FE-PLANNER-OPENSTATE-010: judges the periods in the place timezone, not the viewer one', () => {
|
||||
// Sunday 20:00 UTC → Monday 05:00 in Seoul. The server said closed.
|
||||
|
||||
Reference in New Issue
Block a user