mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-11-10 09:17:06 +00:00
Initial rebrand: @polkadot -> @pezkuwi (14 packages)
- Package namespace: @polkadot/* -> @pezkuwi/* - Repository: polkadot-js/common -> pezkuwichain/pezkuwi-common - Author: Pezkuwi Team <team@pezkuwichain.io> Core packages: - @pezkuwi/util (utilities) - @pezkuwi/util-crypto (crypto primitives) - @pezkuwi/keyring (account management) - @pezkuwi/networks (chain metadata) - @pezkuwi/hw-ledger (Ledger hardware wallet) - @pezkuwi/x-* (10 polyfill packages) Total: 14 packages Upstream: polkadot-js/common v14.0.1
This commit is contained in:
commit
ec06da0ebc
687 files changed
+48096
No files matched your search
@@ -0,0 +1,53 @@
|
||||
// Copyright 2017-2025 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/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(',');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user