Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Feb 4, 2025
1 parent 931141d commit cac63d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/sprinkle-core/app/assets/stores/useTranslator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const useTranslator = defineStore(
date: string,
format: string | object = DateTime.DATETIME_MED_WITH_WEEKDAY
): string {
const dt = DateTime.fromISO(date).setLocale(config.value.dates)
const dt = getDateTime(date)
if (typeof format === 'object') {
return dt.toLocaleString(format)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, beforeEach, test, vi } from 'vitest'
import { setActivePinia, createPinia } from 'pinia'
import { DateTime, Settings } from 'luxon'
import axios from 'axios'
import { useTranslator } from '../../stores/useTranslator'
import type { DictionaryConfig, DictionaryEntries, DictionaryResponse } from '../../interfaces'
import { DateTime } from 'luxon'

const testDictionaryConfig: DictionaryConfig = {
name: 'English',
Expand Down Expand Up @@ -288,6 +288,9 @@ describe('Date Tests', async () => {
await load()

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

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

0 comments on commit cac63d9

Please sign in to comment.