mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
fixed rollback on privacy update fail
coverage privacy.spec.js
This commit is contained in:
parent
e3340760f5
commit
52740d8fc3
@ -12,11 +12,21 @@ describe('privacy.vue', () => {
|
||||
beforeEach(() => {
|
||||
mocks = {
|
||||
$t: jest.fn(),
|
||||
$apollo: {
|
||||
mutate: jest.fn()
|
||||
},
|
||||
$toast: {
|
||||
success: jest.fn(),
|
||||
error: jest.fn(),
|
||||
},
|
||||
}
|
||||
store = new Vuex.Store({
|
||||
getters: {
|
||||
'auth/user': () => {
|
||||
return { id: 'u343', name: 'Delete MyAccount', showShoutsPublicly: true }
|
||||
return {
|
||||
id: 'u343',
|
||||
name: 'MyAccount',
|
||||
showShoutsPublicly: true }
|
||||
},
|
||||
},
|
||||
})
|
||||
@ -38,5 +48,22 @@ describe('privacy.vue', () => {
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('.base-card')).toBe(true)
|
||||
})
|
||||
|
||||
it('clicking on submit changes shoutsAllowed to false', async () => {
|
||||
wrapper.find('#allow-shouts').trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
wrapper.find('.base-button').trigger('click')
|
||||
expect(wrapper.vm.shoutsAllowed).toBe(false)
|
||||
})
|
||||
|
||||
it('clicking on submit with a server error shows a toast and shoutsAllowed is still true', async () => {
|
||||
mocks.$apollo.mutate = jest.fn().mockRejectedValue({ message: 'Ouch!' })
|
||||
wrapper.find('#allow-shouts').trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
await wrapper.find('.base-button').trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(mocks.$toast.error).toHaveBeenCalledWith('Ouch!')
|
||||
expect(wrapper.vm.shoutsAllowed).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -52,6 +52,7 @@ export default {
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
this.shoutsAllowed = !this.shoutsAllowed
|
||||
this.$toast.error(error.message)
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user