mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add error handling component tests
This commit is contained in:
parent
55458abbff
commit
f53d091691
@ -26,12 +26,15 @@ describe('DisableModal.vue', () => {
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {},
|
||||
success: jest.fn(),
|
||||
error: jest.fn(),
|
||||
},
|
||||
$t: jest.fn(),
|
||||
$apollo: {
|
||||
mutate: jest.fn().mockResolvedValue(),
|
||||
mutate: jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ enable: 'u4711' })
|
||||
.mockRejectedValue({ message: 'Not Authorised!' }),
|
||||
},
|
||||
location: {
|
||||
reload: jest.fn(),
|
||||
@ -151,6 +154,10 @@ describe('DisableModal.vue', () => {
|
||||
await wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('calls mutation', () => {
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalled()
|
||||
})
|
||||
@ -174,6 +181,18 @@ describe('DisableModal.vue', () => {
|
||||
expect(wrapper.emitted().close).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('handles errors', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
// second submission causes mutation to reject
|
||||
wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
it('shows an error toaster when mutation rejects', async () => {
|
||||
await expect(mocks.$toast.error).toHaveBeenCalledWith('Not Authorised!')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -23,12 +23,15 @@ describe('ReleaseModal.vue', () => {
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {},
|
||||
success: jest.fn(),
|
||||
error: jest.fn(),
|
||||
},
|
||||
$t: jest.fn(),
|
||||
$apollo: {
|
||||
mutate: jest.fn().mockResolvedValue(),
|
||||
mutate: jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ enable: 'u4711' })
|
||||
.mockRejectedValue({ message: 'Not Authorised!' }),
|
||||
},
|
||||
location: {
|
||||
reload: jest.fn(),
|
||||
@ -146,6 +149,10 @@ describe('ReleaseModal.vue', () => {
|
||||
wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('calls mutation', () => {
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalled()
|
||||
})
|
||||
@ -169,6 +176,18 @@ describe('ReleaseModal.vue', () => {
|
||||
expect(wrapper.emitted().close).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('handles errors', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
// second submission causes mutation to reject
|
||||
wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
it('shows an error toaster when mutation rejects', async () => {
|
||||
await expect(mocks.$toast.error).toHaveBeenCalledWith('Not Authorised!')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user