Skip to content

Commit f63fe43

Browse files
Ambrozywdevfx
andauthored
Scheduler: fix jest timezones (#30526)
Co-authored-by: Vladimir Bushmanov <[email protected]> Co-authored-by: wdevfx <[email protected]>
1 parent 04e4b9c commit f63fe43

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/devextreme/js/__internal/scheduler/__tests__/performance.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('scheduler', () => {
3434
height: 600,
3535
});
3636
await timezoneUtils.cacheTimeZones();
37+
timezoneUtils.getMachineTimezoneName();
3738

3839
expect(container.classList).toContain('dx-scheduler');
3940

@@ -46,6 +47,6 @@ describe('scheduler', () => {
4647
nextButton.click();
4748
expect(navigator.querySelector('.dx-scheduler-navigator-caption')?.textContent).toBe('20-26 January 2025');
4849

49-
expect(Intl.DateTimeFormat).toHaveBeenCalledTimes(timeZone ? 0 : 1);
50+
expect(Intl.DateTimeFormat).toHaveBeenCalledTimes(0);
5051
});
5152
});

packages/devextreme/js/__internal/scheduler/workspaces/view_model/utils/view_generator_utils.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @timezone Etc/GMT-2
3+
*/
4+
// NOTE: We use this utils for calculating weeks count in month view
5+
// The Scheduler cells already converted to "grid time" format
6+
// That's why we use locale (machine timezone) dependent dates here
7+
// Plus set specific timezone for test run
8+
19
import { describe, expect } from '@jest/globals';
210
import each from 'jest-each';
311

packages/devextreme/jsdom-with-timezone.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ const JSDOMEnvironment = require('jest-environment-jsdom').TestEnvironment;
33
module.exports = class TimezoneAwareJSDOMEnvironment extends JSDOMEnvironment {
44
constructor(config, context) {
55
// eslint-disable-next-line spellcheck/spell-checker
6-
process.env.TZ = context.docblockPragmas.timezone || process.env.TZ || 'UTC';
6+
const { timezone } = context.docblockPragmas;
7+
if(timezone) {
8+
process.env.TZ = timezone;
9+
}
710

811
super(config, context);
912
}

0 commit comments

Comments
 (0)