mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Test that if the saveLocale Method is called the mocked apollo call is send.
This commit is contained in:
parent
ac91c59a59
commit
154b56ce57
@ -3,6 +3,16 @@ import LanguageSwitch from './LanguageSwitch'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const updateUserInfosQueryMock = jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
updateUserInfos: {
|
||||
sessionId: 1234,
|
||||
email: 'he@ho.he',
|
||||
locale: 'de',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
describe('LanguageSwitch', () => {
|
||||
let wrapper
|
||||
|
||||
@ -20,6 +30,9 @@ describe('LanguageSwitch', () => {
|
||||
$i18n: {
|
||||
locale: 'en',
|
||||
},
|
||||
$apollo: {
|
||||
query: updateUserInfosQueryMock,
|
||||
},
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
@ -91,5 +104,33 @@ describe('LanguageSwitch', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('calls the API', () => {
|
||||
it("with locale 'en'", () => {
|
||||
wrapper.vm.saveLocale('en')
|
||||
expect(updateUserInfosQueryMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
variables: {
|
||||
sessionId: 1234,
|
||||
email: 'he@ho.he',
|
||||
locale: 'en',
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it("with locale 'de'", () => {
|
||||
wrapper.vm.saveLocale('de')
|
||||
expect(updateUserInfosQueryMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
variables: {
|
||||
sessionId: 1234,
|
||||
email: 'he@ho.he',
|
||||
locale: 'de',
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user