Skip to content

Commit 341b40a

Browse files
committed
refactor: improve timezone handling and comments in ObservationItem tests
1 parent 862241a commit 341b40a

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/components/__tests__/ObservationItem.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import ObservationItem from '../ObservationItem';
55
import { UnitObservation } from '../../types';
66

77
describe('ObservationItem Component', () => {
8-
// Set Finnish locale for these tests and restore original after
98
beforeAll(() => {
109
// @ts-ignore
1110
import('moment/locale/fi');
@@ -20,7 +19,7 @@ describe('ObservationItem Component', () => {
2019
unit: 1,
2120
id: 123,
2221
property: 'ski_trail_maintenance',
23-
time: '2024-01-15T14:30:00.000Z',
22+
time: '2024-01-15T14:30:00.000',
2423
expiration_time: null,
2524
name: { fi: 'Hyväksi todettu' },
2625
quality: 'good',
@@ -100,8 +99,7 @@ describe('ObservationItem Component', () => {
10099
it('displays formatted time correctly', () => {
101100
render(<ObservationItem observation={mockObservation} />);
102101

103-
// Check that Finnish time format is displayed (actual moment.js formatting with Finnish locale)
104-
expect(screen.getByText(new RegExp('ma 15.1.2024 klo 16.30.00'))).toBeInTheDocument();
102+
expect(screen.getByText(new RegExp('ma 15.1.2024 klo 14.30.00'))).toBeInTheDocument();
105103
});
106104

107105
describe('Short descriptions mapping', () => {

test/setupTests.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ import 'core-js/stable';
22
import '@testing-library/jest-dom';
33

44
// Set up environment variables for testing
5-
process.env.API_URL = 'https://test-api.example.com/api';
5+
process.env.API_URL = 'https://test-api.example.com/api';
6+
7+
// Set timezone to ensure consistent test results across environments
8+
process.env.TZ = 'Europe/Helsinki';

0 commit comments

Comments
 (0)