tests are working again

This commit is contained in:
Moriz Wahl 2021-05-17 16:19:53 +02:00
parent c4440f50e3
commit f7cae0359e
3 changed files with 11 additions and 8 deletions

View File

@ -21,12 +21,14 @@ export default {
data() {
return {
locales: locales,
currentLanguage: {},
}
},
methods: {
async setLocale(locale) {
setLocale(locale) {
this.$i18n.locale = locale
this.$store.commit('language', this.$i18n.locale)
this.currentLanguage = this.getLocaleObject(locale)
localeChanged(locale)
},
async saveLocale(locale) {
@ -52,9 +54,7 @@ export default {
if (lang) return lang.split('-')[0]
return lang
},
},
computed: {
currentLanguage() {
setCurrentLanguage() {
let locale = this.$store.state.language || this.getNavigatorLanguage() || 'en'
let object = this.getLocaleObject(locale)
if (!object) {
@ -62,8 +62,11 @@ export default {
object = this.getLocaleObject(locale)
}
this.setLocale(locale)
return object
this.currentLanguage = object
},
},
created() {
this.setCurrentLanguage()
},
}
</script>

View File

@ -12,9 +12,6 @@ describe('ContentFooter', () => {
locale: 'en',
},
$t: jest.fn((t) => t),
$store: {
commit: jest.fn(),
},
}
const Wrapper = () => {

View File

@ -44,6 +44,9 @@ describe('DashboardLayoutGdd', () => {
const store = new Vuex.Store({
state,
mutations: {
language: jest.fn(),
},
})
const Wrapper = () => {