All files / src/lib format.cases.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 0/0
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33              2x 2x   2x               2x             2x              
// Expected output of the format helpers, shared by the Node (format.test.ts)
// and Workers (format.server.test.ts) tests: Intl data comes from each
// runtime's ICU, so both are checked.
import type { Locale } from '#/paraglide/runtime.js'
 
// Intl separates digit groups and the euro sign with no-break spaces, and
// writes negative amounts with a minus sign (U+2212).
const nbsp = ' '
const minus = '−'
 
export const moneyCases: [Locale, number, string][] = [
  ['fi', 123456, `1${nbsp}234,56${nbsp}€`],
  ['sv', 123456, `1${nbsp}234,56${nbsp}€`],
  ['en', 123456, '€1,234.56'],
  ['fi', -5, `${minus}0,05${nbsp}€`],
  ['fi', 0, `0,00${nbsp}€`],
]
 
export const dateCases: [Locale, string, string][] = [
  ['fi', '2026-03-05', '5.3.2026'],
  ['sv', '2026-03-05', '5.3.2026'],
  ['en', '2026-03-05', '05/03/2026'],
  ['fi', '2026-12-31', '31.12.2026'],
]
 
export const areaCases: [Locale, number, string][] = [
  ['fi', 485, `48,5${nbsp}m²`],
  ['sv', 485, `48,5${nbsp}m²`],
  ['en', 485, `48.5${nbsp}m²`],
  ['fi', 490, `49${nbsp}m²`],
  ['fi', 12005, `1200,5${nbsp}m²`],
]