diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index 8d68de7d3..f7f306fc3 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -14,39 +14,43 @@ describe('ContributionForm.vue', () => { let expectedParams let deutschOption let cancelBtn + let mocks const postTitle = 'this is a title for a post' const postContent = 'this is a post' const computed = { locale: () => 'English' } - const mocks = { - $t: jest.fn(), - $apollo: { - mutate: jest - .fn() - .mockResolvedValueOnce({ - data: { - CreatePost: { - title: postTitle, - slug: 'this-is-a-title-for-a-post', - content: postContent, - contentExcerpt: postContent, - language: 'en', + + beforeEach(() => { + mocks = { + $t: jest.fn(), + $apollo: { + mutate: jest + .fn() + .mockResolvedValueOnce({ + data: { + CreatePost: { + title: postTitle, + slug: 'this-is-a-title-for-a-post', + content: postContent, + contentExcerpt: postContent, + language: 'en', + }, }, - }, - }) - .mockRejectedValue({ message: 'Not Authorised!' }), - }, - $toast: { - error: jest.fn(), - success: jest.fn(), - }, - $i18n: { - locale: () => 'en', - }, - $router: { - back: jest.fn(), - push: jest.fn(), - }, - } + }) + .mockRejectedValue({ message: 'Not Authorised!' }), + }, + $toast: { + error: jest.fn(), + success: jest.fn(), + }, + $i18n: { + locale: () => 'en', + }, + $router: { + back: jest.fn(), + push: jest.fn(), + }, + } + }) describe('mount', () => { const Wrapper = () => { @@ -55,6 +59,7 @@ describe('ContributionForm.vue', () => { beforeEach(() => { wrapper = Wrapper() + wrapper.setData({ form: { languageOptions: [{ label: 'Deutsch', value: 'de' }] } }) }) describe('CreatePost', () => { diff --git a/webapp/components/ContributionForm/index.vue b/webapp/components/ContributionForm/index.vue index d56cb11e3..8e19944e4 100644 --- a/webapp/components/ContributionForm/index.vue +++ b/webapp/components/ContributionForm/index.vue @@ -48,6 +48,7 @@ import gql from 'graphql-tag' import HcEditor from '~/components/Editor' import orderBy from 'lodash/orderBy' +import locales from '~/locales' export default { components: { @@ -92,7 +93,7 @@ export default { computed: { locale() { let locale - locale = process.env.locales.find(this.returnLocaleName) + locale = locales.find(this.returnLocaleName) return locale.name }, }, @@ -141,7 +142,7 @@ export default { } }, availableLocales() { - orderBy(process.env.locales, 'name').map(locale => { + orderBy(locales, 'name').map(locale => { this.form.languageOptions.push({ label: locale.name, value: locale.code }) }) },