diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 12:09:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 12:09:42 +0000 |
commit | 729e3765d5feb762df1ccfbc228a8dd4662aa3f9 (patch) | |
tree | f326420fc64999c6bcc28816ed54f0972fb46459 /spec/frontend/locale | |
parent | 6f7881ee9dcec34141a8f34fc814b56b366d2b48 (diff) | |
download | gitlab-ce-729e3765d5feb762df1ccfbc228a8dd4662aa3f9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/locale')
-rw-r--r-- | spec/frontend/locale/index_spec.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/frontend/locale/index_spec.js b/spec/frontend/locale/index_spec.js new file mode 100644 index 00000000000..346ed5182f4 --- /dev/null +++ b/spec/frontend/locale/index_spec.js @@ -0,0 +1,31 @@ +import { createDateTimeFormat, languageCode } from '~/locale'; + +import { setLanguage } from 'helpers/locale_helper'; + +describe('locale', () => { + afterEach(() => setLanguage(null)); + + 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', () => { + beforeEach(() => setLanguage('en')); + + it('creates an instance of Intl.DateTimeFormat', () => { + const dateFormat = createDateTimeFormat({ year: 'numeric', month: 'long', day: 'numeric' }); + + expect(dateFormat.format(new Date(2015, 6, 3))).toBe('July 3, 2015'); + }); + }); +}); |