mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-10-29 21:59:48 +00:00
The header rule takes the current year as the end of the range, as upstream's does; 581 sources still ended at 2025, which failed lint. Lint never ran to completion here, so this went unseen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/util authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
|
|
|
import { getSeparator } from './getSeparator.js';
|
|
|
|
describe('getSeparator', (): void => {
|
|
const normalizeSeparator = (separator: string) =>
|
|
separator === '\u202F' ? ' ' : separator;
|
|
|
|
const testLocales = [
|
|
{ decimal: '.', locale: 'en', thousand: ',' },
|
|
{ decimal: '.', locale: 'en-gb', thousand: ',' },
|
|
{ decimal: ',', locale: 'sl', thousand: '.' },
|
|
{ decimal: ',', locale: 'sl-si', thousand: '.' },
|
|
{ decimal: ',', locale: 'it-it', thousand: '.' },
|
|
{ decimal: '.', locale: 'ja-jp', thousand: ',' },
|
|
{ decimal: '.', locale: 'hi-IN', thousand: ',' },
|
|
{ decimal: '.', locale: undefined, thousand: ',' } // Fallback test
|
|
];
|
|
|
|
testLocales.forEach(({ decimal, locale, thousand }) => {
|
|
it(`uses ${locale || 'system default'} locale`, (): void => {
|
|
expect(
|
|
getSeparator(locale)
|
|
).toEqual({ decimal, thousand });
|
|
});
|
|
});
|
|
|
|
it('falls back for invalid locale', (): void => {
|
|
expect(
|
|
getSeparator('invalid-locale')
|
|
).toEqual({ decimal: '.', thousand: ',' }); // Default fallback
|
|
});
|
|
|
|
it('matches system locale dynamically', (): void => {
|
|
const n = 1000.1;
|
|
const expected = {
|
|
decimal: n.toLocaleString().substring(5, 6),
|
|
thousand: n.toLocaleString().substring(1, 2)
|
|
};
|
|
|
|
expect(getSeparator()).toEqual(expected);
|
|
});
|
|
|
|
it('handles locales with unique separators', (): void => {
|
|
const result = getSeparator('fr-FR');
|
|
|
|
expect(normalizeSeparator(result.thousand)).toBe(' ');
|
|
expect(result.decimal).toBe(',');
|
|
});
|
|
});
|