Skip to content

Commit 4511cce

Browse files
committed
tests
1 parent b101851 commit 4511cce

File tree

2 files changed

+125
-101
lines changed

2 files changed

+125
-101
lines changed

packages/cubejs-backend-shared/test/time.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
timeSeries,
55
isPredefinedGranularity,
66
timeSeriesFromCustomInterval,
7-
parseLocalDate,
7+
parseUtcIntoLocalDate,
88
utcToLocalTimeZone,
99
addSecondsToLocalTimestamp,
1010
reformatInIsoLocal,
@@ -264,37 +264,37 @@ describe('extractDate', () => {
264264
const timezone = 'Europe/Kiev';
265265

266266
it('should return null if data is empty', () => {
267-
expect(parseLocalDate(null, timezone)).toBeNull();
268-
expect(parseLocalDate(undefined, timezone)).toBeNull();
269-
expect(parseLocalDate([], timezone)).toBeNull();
267+
expect(parseUtcIntoLocalDate(null, timezone)).toBeNull();
268+
expect(parseUtcIntoLocalDate(undefined, timezone)).toBeNull();
269+
expect(parseUtcIntoLocalDate([], timezone)).toBeNull();
270270
});
271271

272272
it('should return null if no valid date is found in data', () => {
273-
expect(parseLocalDate([{}], timezone)).toBeNull();
274-
expect(parseLocalDate([{ someKey: 'invalid date' }], timezone)).toBeNull();
273+
expect(parseUtcIntoLocalDate([{}], timezone)).toBeNull();
274+
expect(parseUtcIntoLocalDate([{ someKey: 'invalid date' }], timezone)).toBeNull();
275275
});
276276

277277
it('should throw an error for unknown timezone', () => {
278278
const input = [{ date: '2025-02-28T12:00:00+03:00' }];
279-
expect(() => parseLocalDate(input, 'Invalid/Timezone'))
279+
expect(() => parseUtcIntoLocalDate(input, 'Invalid/Timezone'))
280280
.toThrowError('Unknown timezone: Invalid/Timezone');
281281
});
282282

283283
it('should parse a date with UTC timezone', () => {
284284
const input = [{ date: '2025-02-28T12:00:00Z' }];
285-
const result = parseLocalDate(input, timezone);
285+
const result = parseUtcIntoLocalDate(input, timezone);
286286
expect(result).toBe('2025-02-28T14:00:00.000');
287287
});
288288

289289
it('should parse a date with an offset timezone', () => {
290290
const input = [{ date: '2025-02-28T12:00:00+03:00' }];
291-
const result = parseLocalDate(input, timezone);
291+
const result = parseUtcIntoLocalDate(input, timezone);
292292
expect(result).toBe('2025-02-28T11:00:00.000');
293293
});
294294

295295
it('should parse a date without timezone as UTC', () => {
296296
const input = [{ date: '2025-02-28 12:00:00' }];
297-
const result = parseLocalDate(input, timezone);
297+
const result = parseUtcIntoLocalDate(input, timezone);
298298
expect(result).toBe('2025-02-28T12:00:00.000');
299299
});
300300

@@ -304,10 +304,10 @@ describe('extractDate', () => {
304304
const input3 = [{ date: '2025-02-28T12:00:00Z' }];
305305
const input4 = [{ date: '2025-02-28T12:00:00+03:00' }];
306306

307-
expect(parseLocalDate(input1, timezone)).toBe('2025-02-28T12:00:00.000');
308-
expect(parseLocalDate(input2, timezone)).toBe('2025-02-28T12:00:00.000');
309-
expect(parseLocalDate(input3, timezone)).toBe('2025-02-28T14:00:00.000');
310-
expect(parseLocalDate(input4, timezone)).toBe('2025-02-28T11:00:00.000');
307+
expect(parseUtcIntoLocalDate(input1, timezone)).toBe('2025-02-28T12:00:00.000');
308+
expect(parseUtcIntoLocalDate(input2, timezone)).toBe('2025-02-28T12:00:00.000');
309+
expect(parseUtcIntoLocalDate(input3, timezone)).toBe('2025-02-28T14:00:00.000');
310+
expect(parseUtcIntoLocalDate(input4, timezone)).toBe('2025-02-28T11:00:00.000');
311311
});
312312
});
313313

0 commit comments

Comments
 (0)