mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-27 17:53:50 +00:00
fix(test): use getDbDateStr() in tests to fix timezone-dependent failures
Replace UTC date strings (toISOString().split('T')[0]) with getDbDateStr()
to match implementation behavior. Fixes 3 CalendarIntegrationService tests
and 1 StartupService test that failed in non-UTC timezones.
This commit is contained in:
parent
b428942a75
commit
fecc62f7d3
2 changed files with 6 additions and 4 deletions
|
|
@ -19,6 +19,7 @@ import { LS } from '../persistence/storage-keys.const';
|
|||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
import { selectSyncConfig } from '../../features/config/store/global-config.reducer';
|
||||
import { selectEnabledIssueProviders } from '../../features/issue/store/issue-provider.selectors';
|
||||
import { getDbDateStr } from '../../util/get-db-date-str';
|
||||
|
||||
describe('StartupService', () => {
|
||||
let service: StartupService;
|
||||
|
|
@ -210,7 +211,7 @@ describe('StartupService', () => {
|
|||
});
|
||||
|
||||
it('should not increment count if same day', () => {
|
||||
const todayStr = new Date().toISOString().split('T')[0];
|
||||
const todayStr = getDbDateStr();
|
||||
(localStorage.getItem as jasmine.Spy).and.callFake((key: string) => {
|
||||
if (key === LS.APP_START_COUNT) return '10';
|
||||
if (key === LS.APP_START_COUNT_LAST_START_DAY) return todayStr;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
import { SnackService } from '../../core/snack/snack.service';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { getDbDateStr } from '../../util/get-db-date-str';
|
||||
|
||||
describe('CalendarIntegrationService', () => {
|
||||
let service: CalendarIntegrationService;
|
||||
|
|
@ -728,7 +729,7 @@ END:VCALENDAR`;
|
|||
describe('constructor', () => {
|
||||
it('should load skipped events from localStorage on init', () => {
|
||||
const skippedIds = ['event-1', 'event-2'];
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const today = getDbDateStr();
|
||||
|
||||
localStorage.setItem(
|
||||
'SUP_CALENDER_EVENTS_SKIPPED_TODAY',
|
||||
|
|
@ -758,7 +759,7 @@ END:VCALENDAR`;
|
|||
|
||||
it('should not load skipped events from different day', () => {
|
||||
const skippedIds = ['event-1', 'event-2'];
|
||||
const yesterday = new Date(Date.now() - 86400000).toISOString().split('T')[0];
|
||||
const yesterday = getDbDateStr(Date.now() - 86400000);
|
||||
|
||||
localStorage.setItem(
|
||||
'SUP_CALENDER_EVENTS_SKIPPED_TODAY',
|
||||
|
|
@ -787,7 +788,7 @@ END:VCALENDAR`;
|
|||
});
|
||||
|
||||
it('should handle invalid JSON in localStorage gracefully', () => {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const today = getDbDateStr();
|
||||
|
||||
localStorage.setItem('SUP_CALENDER_EVENTS_SKIPPED_TODAY', 'invalid json');
|
||||
localStorage.setItem('SUP_CALENDER_EVENTS_LAST_SKIP_DAY', today);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue