Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 16:37:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 16:37:47 +0300
commitaee0a117a889461ce8ced6fcf73207fe017f1d99 (patch)
tree891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/frontend/vue_shared/translate_spec.js
parent8d46af3258650d305f53b819eabf7ab18d22f59e (diff)
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/frontend/vue_shared/translate_spec.js')
-rw-r--r--spec/frontend/vue_shared/translate_spec.js87
1 files changed, 30 insertions, 57 deletions
diff --git a/spec/frontend/vue_shared/translate_spec.js b/spec/frontend/vue_shared/translate_spec.js
index 42aa28a6309..30417161968 100644
--- a/spec/frontend/vue_shared/translate_spec.js
+++ b/spec/frontend/vue_shared/translate_spec.js
@@ -1,9 +1,9 @@
-import { mount, createLocalVue } from '@vue/test-utils';
+import { mount } from '@vue/test-utils';
+import Vue from 'vue';
import locale from '~/locale';
import Translate from '~/vue_shared/translate';
-const localVue = createLocalVue();
-localVue.use(Translate);
+Vue.use(Translate);
describe('Vue translate filter', () => {
const createTranslationMock = (key, ...translations) => {
@@ -26,16 +26,13 @@ describe('Vue translate filter', () => {
const translation = 'singular_translated';
createTranslationMock(key, translation);
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ __('${key}') }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe(translation);
});
@@ -45,16 +42,13 @@ describe('Vue translate filter', () => {
const translationPlural = 'plural_multiple translation';
createTranslationMock(key, 'plural_singular translation', translationPlural);
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ n__('${key}', 'plurals', 2) }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe(translationPlural);
});
@@ -67,31 +61,25 @@ describe('Vue translate filter', () => {
});
it('and n === 1', () => {
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ n__('${key}', '%d days', 1) }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe('1 singular translated');
});
it('and n > 1', () => {
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ n__('${key}', '%d days', 2) }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe('2 plural translated');
});
@@ -107,31 +95,25 @@ describe('Vue translate filter', () => {
});
it('and using two parameters', () => {
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ s__('Context', 'Foobar') }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe(expectation);
});
it('and using the pipe syntax', () => {
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ s__('${key}') }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe(expectation);
});
@@ -141,9 +123,8 @@ describe('Vue translate filter', () => {
const translation = 'multiline string translated';
createTranslationMock('multiline string', translation);
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ __(\`
multiline
@@ -151,9 +132,7 @@ describe('Vue translate filter', () => {
\`) }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe(translation);
});
@@ -163,9 +142,8 @@ describe('Vue translate filter', () => {
createTranslationMock('multiline string', 'multiline string singular', translation);
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ n__(
\`
@@ -180,9 +158,7 @@ describe('Vue translate filter', () => {
) }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe(translation);
});
@@ -192,9 +168,8 @@ describe('Vue translate filter', () => {
createTranslationMock('Context| multiline string', translation);
- const wrapper = mount(
- {
- template: `
+ const wrapper = mount({
+ template: `
<span>
{{ s__(
\`
@@ -205,9 +180,7 @@ describe('Vue translate filter', () => {
) }}
</span>
`,
- },
- { localVue },
- );
+ });
expect(wrapper.text()).toBe(translation);
});