UNPKG

@rockpack/localazer

Version:

This module can help you organize localization in your React application

55 lines (54 loc) 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("./utils"); describe('getDefault use cases', function () { test('check getDefault "en" language without locale data', function () { var lang = 'en'; expect(utils_1.getDefault(lang)) .toEqual({ // eslint-disable-next-line @typescript-eslint/camelcase locale_data: { messages: { '': { domain: 'messages', lang: lang, // eslint-disable-next-line @typescript-eslint/camelcase plural_forms: 'nplurals=2; plural=(n != 1);' } } } }); }); test('check getDefault "en" language with locale data', function () { var lang = 'ru'; var localeData = { domain: 'messages', // eslint-disable-next-line @typescript-eslint/camelcase locale_data: { messages: { '': { domain: 'messages', // eslint-disable-next-line @typescript-eslint/camelcase plural_forms: 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);', lang: 'ru' }, 'Alarm!': ['Ахтунг!'], 'Hello world': ['Привет мир'], '%d click': ['%d клик', '%d кликов', '%d кликов'], 'Sort By': ['Сортировать по'], Latest: ['По последнему'], 'Most Popular': ['Самый популярный'], 'Most Viewed': ['Самый просматриваемый'], 'Most Commented': ['Самый комментируемый'], 'USER\u0004Your name is %s and surname is %s': ['Ваше имя %s ваша фамилия %s'] } } }; expect(utils_1.getDefault(lang, localeData)) .toEqual(localeData); }); }); test('detect browser default language from languages array', function () { expect(utils_1.detectBrowserLanguage()) .toBe('en-US'); });