mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add test for LocaleSwitch
This commit is contained in:
parent
01eb25eca6
commit
35428fbaaa
68
webapp/components/LocaleSwitch/LocaleSwitch.spec.js
Normal file
68
webapp/components/LocaleSwitch/LocaleSwitch.spec.js
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import { mount, createLocalVue } from '@vue/test-utils'
|
||||||
|
import Styleguide from '@human-connection/styleguide'
|
||||||
|
import Vuex from 'vuex'
|
||||||
|
import VTooltip from 'v-tooltip'
|
||||||
|
import LocaleSwitch from './LocaleSwitch.vue'
|
||||||
|
import { mutations } from '~/store/editor'
|
||||||
|
|
||||||
|
const localVue = createLocalVue()
|
||||||
|
|
||||||
|
localVue.use(Vuex)
|
||||||
|
localVue.use(Styleguide)
|
||||||
|
localVue.use(VTooltip)
|
||||||
|
|
||||||
|
describe('LocaleSwitch.vue', () => {
|
||||||
|
let wrapper
|
||||||
|
let mocks
|
||||||
|
let computed
|
||||||
|
let deutschLanguageItem
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mocks = {
|
||||||
|
$i18n: {
|
||||||
|
locale: () => 'de',
|
||||||
|
set: jest.fn(),
|
||||||
|
},
|
||||||
|
$t: jest.fn(),
|
||||||
|
setPlaceholderText: jest.fn(),
|
||||||
|
}
|
||||||
|
computed = {
|
||||||
|
current: () => {
|
||||||
|
return { code: 'en' }
|
||||||
|
},
|
||||||
|
routes: () => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: 'English',
|
||||||
|
path: 'en',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Deutsch',
|
||||||
|
path: 'de',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
|
const store = new Vuex.Store({
|
||||||
|
mutations: {
|
||||||
|
'editor/SET_PLACEHOLDER_TEXT': mutations.SET_PLACEHOLDER_TEXT,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const Wrapper = () => {
|
||||||
|
return mount(LocaleSwitch, { mocks, localVue, store, computed })
|
||||||
|
}
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
wrapper.find('.locale-menu').trigger('click')
|
||||||
|
deutschLanguageItem = wrapper.findAll('li').at(1)
|
||||||
|
deutschLanguageItem.trigger('click')
|
||||||
|
})
|
||||||
|
|
||||||
|
it("changes a user's locale", () => {
|
||||||
|
expect(mocks.$i18n.set).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -92,7 +92,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions } from 'vuex'
|
import { mapGetters, mapActions } from 'vuex'
|
||||||
import LocaleSwitch from '~/components/LocaleSwitch'
|
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
|
||||||
import SearchInput from '~/components/SearchInput.vue'
|
import SearchInput from '~/components/SearchInput.vue'
|
||||||
import Modal from '~/components/Modal'
|
import Modal from '~/components/Modal'
|
||||||
import NotificationMenu from '~/components/notifications/NotificationMenu'
|
import NotificationMenu from '~/components/notifications/NotificationMenu'
|
||||||
|
|||||||
@ -73,7 +73,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LocaleSwitch from '~/components/LocaleSwitch'
|
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user