mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
test(frontend): make date assertions machine-independent
Three tests encoded the machine's timezone or locale into their expectations and fail on any box east of UTC (observed on UTC+12/13; CI's UTC and US-locale dev machines never see it): - dateTimeUtils isSame: compared 10:00Z/11:00Z on the 15th as 'same day', but isSame works on local calendar days and no UTC instant falls on the same date in every timezone (at UTC+13 those are 23:00 on the 15th and 00:00 on the 16th). Use timezone-less datetimes, which mean the same calendar day everywhere. - RecordingUtils toDateString: formatted a UTC-noon instant and expected the UTC date, but toDateString renders local time (UTC+12 renders the next day). Construct the Date with local components. - SeriesModalUtils getEpisodeAirdate: the code renders the viewer's locale via toLocaleDateString() by design, but the test hardcoded the en-US shape (it tolerated the timezone day-shift with /1[4|5]/ yet not the day/month order). Compute the expectation with the same API so the test asserts the wiring, not a specific locale. No production code changes.
This commit is contained in:
parent
ab8e3f93c6
commit
8cb1dab5ce
3 changed files with 6 additions and 6 deletions
|
|
@ -132,14 +132,14 @@ describe('dateTimeUtils', () => {
|
|||
|
||||
describe('isSame', () => {
|
||||
it('should return true when dates are same day', () => {
|
||||
const date1 = '2024-01-15T10:00:00Z';
|
||||
const date2 = '2024-01-15T11:00:00Z';
|
||||
const date1 = '2024-01-15 10:00:00';
|
||||
const date2 = '2024-01-15 11:00:00';
|
||||
expect(dateTimeUtils.isSame(date1, date2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when dates are different days', () => {
|
||||
const date1 = '2024-01-15T10:00:00Z';
|
||||
const date2 = '2024-01-16T10:00:00Z';
|
||||
const date1 = '2024-01-15 10:00:00';
|
||||
const date2 = '2024-01-16 10:00:00';
|
||||
expect(dateTimeUtils.isSame(date1, date2)).toBe(false);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ describe('SeriesModalUtils', () => {
|
|||
it('should format valid air date', () => {
|
||||
const episode = { air_date: '2024-01-15' };
|
||||
const formatted = getEpisodeAirdate(episode);
|
||||
expect(formatted).toMatch(/1\/1[4|5]\/2024/);
|
||||
expect(formatted).toBe(new Date('2024-01-15').toLocaleDateString());
|
||||
});
|
||||
|
||||
it('should return N/A for missing air date', () => {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ describe('RecordingUtils', () => {
|
|||
|
||||
describe('toDateString', () => {
|
||||
it('formats a Date to YYYY-MM-DD', () => {
|
||||
const d = new Date('2024-06-15T12:00:00Z');
|
||||
const d = new Date(2024, 5, 15, 12, 0, 0);
|
||||
const result = toDateString(d);
|
||||
expect(result).toBe('2024-06-15');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue