cldr
Version:
Library for extracting data from CLDR (the Unicode Common Locale Data Repository)
51 lines (43 loc) • 1.57 kB
JavaScript
const expect = require('unexpected');
const cldr = require('../lib/cldr');
describe('extractNumberingSystem', () => {
it('should throw if the numbering system does not exist', () => {
expect(
() => cldr.extractNumberingSystem('foo'),
'to error',
'Unknown numbering system: foo'
);
});
it('should extract a numeric (digits-based) numbering system', () => {
expect(cldr.extractNumberingSystem('fullwide'), 'to equal', {
type: 'numeric',
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
});
});
it('should extract digits with high codepoints', () => {
expect(cldr.extractNumberingSystem('ahom'), 'to equal', {
type: 'numeric',
digits: ['𑜰', '𑜱', '𑜲', '𑜳', '𑜴', '𑜵', '𑜶', '𑜷', '𑜸', '𑜹'],
});
});
it('should extract an algorithmic numbering system without a locale', () => {
expect(cldr.extractNumberingSystem('ethi'), 'to equal', {
type: 'algorithmic',
rules: 'renderEthiopic',
});
});
it('should extract an algorithmic numbering system with a locale', () => {
expect(cldr.extractNumberingSystem('jpan'), 'to equal', {
type: 'algorithmic',
rules: 'renderSpelloutCardinal',
locale: 'ja',
});
});
it('should extract an algorithmic numbering system with a locale and a sublocale', () => {
expect(cldr.extractNumberingSystem('hantfin'), 'to equal', {
type: 'algorithmic',
rules: 'renderSpelloutCardinalFinancial',
locale: 'zh_Hant',
});
});
});