debian-mirror-gitlab/spec/frontend/locale/index_spec.js

31 lines
800 B
JavaScript
Raw Normal View History

2020-04-22 19:07:51 +05:30
import { setLanguage } from 'helpers/locale_helper';
2020-10-24 23:57:45 +05:30
import { createDateTimeFormat, languageCode } from '~/locale';
2018-03-17 18:26:18 +05:30
describe('locale', () => {
2020-04-22 19:07:51 +05:30
afterEach(() => setLanguage(null));
2018-03-17 18:26:18 +05:30
describe('languageCode', () => {
it('parses the lang attribute', () => {
setLanguage('ja');
expect(languageCode()).toBe('ja');
});
it('falls back to English', () => {
setLanguage(null);
expect(languageCode()).toBe('en');
});
});
describe('createDateTimeFormat', () => {
2020-04-22 19:07:51 +05:30
beforeEach(() => setLanguage('en'));
2018-03-17 18:26:18 +05:30
it('creates an instance of Intl.DateTimeFormat', () => {
const dateFormat = createDateTimeFormat({ year: 'numeric', month: 'long', day: 'numeric' });
2020-04-22 19:07:51 +05:30
expect(dateFormat.format(new Date(2015, 6, 3))).toBe('July 3, 2015');
2018-03-17 18:26:18 +05:30
});
});
});