Skip to content

Commit cac63d9

Browse files
committed
Fix test
1 parent 931141d commit cac63d9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/sprinkle-core/app/assets/stores/useTranslator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const useTranslator = defineStore(
6565
date: string,
6666
format: string | object = DateTime.DATETIME_MED_WITH_WEEKDAY
6767
): string {
68-
const dt = DateTime.fromISO(date).setLocale(config.value.dates)
68+
const dt = getDateTime(date)
6969
if (typeof format === 'object') {
7070
return dt.toLocaleString(format)
7171
} else {

packages/sprinkle-core/app/assets/tests/stores/useTranslator.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { describe, expect, beforeEach, test, vi } from 'vitest'
22
import { setActivePinia, createPinia } from 'pinia'
3+
import { DateTime, Settings } from 'luxon'
34
import axios from 'axios'
45
import { useTranslator } from '../../stores/useTranslator'
56
import type { DictionaryConfig, DictionaryEntries, DictionaryResponse } from '../../interfaces'
6-
import { DateTime } from 'luxon'
77

88
const testDictionaryConfig: DictionaryConfig = {
99
name: 'English',
@@ -288,6 +288,9 @@ describe('Date Tests', async () => {
288288
await load()
289289

290290
// Assert basic translate method
291+
// Force the default timezone, so the test is consistent regardless of
292+
// the timezone of the runner
293+
Settings.defaultZone = 'America/New_York'
291294
expect($tdate('2025-02-02T14:42:12.000000Z')).toBe('Sun, Feb 2, 2025, 9:42 AM')
292295
expect($tdate('2025-02-02T14:42:12.000000Z', 'DDD')).toBe('February 2, 2025')
293296
expect($tdate('2025-02-02T14:42:12.000000Z', DateTime.DATETIME_MED)).toBe(
@@ -308,6 +311,9 @@ describe('Date Tests', async () => {
308311
await load()
309312

310313
// Assert basic translate method
314+
// Force the default timezone, so the test is consistent regardless of
315+
// the timezone of the runner
316+
Settings.defaultZone = 'America/New_York'
311317
expect($tdate('2025-02-02T14:42:12.000000Z')).toBe('dim. 2 févr. 2025, 09:42')
312318
expect($tdate('2025-02-02T14:42:12.000000Z', 'DDD')).toBe('2 février 2025')
313319
expect($tdate('2025-02-02T14:42:12.000000Z', DateTime.DATETIME_MED)).toBe(

0 commit comments

Comments
 (0)