summaryrefslogtreecommitdiff
path: root/spec/frontend/locale/index_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/locale/index_spec.js')
-rw-r--r--spec/frontend/locale/index_spec.js31
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');
+ });
+ });
+});