mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Add test for upload error, update variable name
This commit is contained in:
parent
aff2b4aaf0
commit
7796483a46
@ -151,6 +151,7 @@ describe('ContributionForm.vue', () => {
|
||||
|
||||
describe('handles errors', () => {
|
||||
beforeEach(async () => {
|
||||
jest.useFakeTimers()
|
||||
wrapper = Wrapper()
|
||||
postTitleInput = wrapper.find('.ds-input')
|
||||
postTitleInput.setValue('this is a title for a post')
|
||||
@ -158,11 +159,31 @@ describe('ContributionForm.vue', () => {
|
||||
// second submission causes mutation to reject
|
||||
await wrapper.find('form').trigger('submit')
|
||||
})
|
||||
|
||||
it('shows an error toaster when apollo mutation rejects', async () => {
|
||||
await wrapper.find('form').trigger('submit')
|
||||
await mocks.$apollo.mutate
|
||||
expect(mocks.$toast.error).toHaveBeenCalledWith('Not Authorised!')
|
||||
})
|
||||
|
||||
const message = 'File upload failed'
|
||||
const fileError = { status: 'error' }
|
||||
|
||||
it('defaults to error false', () => {
|
||||
expect(wrapper.vm.error).toEqual(false)
|
||||
})
|
||||
|
||||
it('shows an error toaster when verror is called', () => {
|
||||
wrapper.vm.verror(fileError, message)
|
||||
expect(mocks.$toast.error).toHaveBeenCalledWith(fileError.status, message)
|
||||
})
|
||||
|
||||
it('changes error status from false to true to false', () => {
|
||||
wrapper.vm.verror(fileError, message)
|
||||
expect(wrapper.vm.error).toEqual(true)
|
||||
jest.runAllTimers()
|
||||
expect(wrapper.vm.error).toEqual(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -14,14 +14,14 @@
|
||||
<div class="dz-message">
|
||||
<div
|
||||
:class="{
|
||||
'hc-attachments-upload-area-post': createOrUpdate,
|
||||
'hc-attachments-upload-area-post': createAndUpdate,
|
||||
'hc-attachments-upload-area-update-post': contribution,
|
||||
}"
|
||||
>
|
||||
<slot></slot>
|
||||
<div
|
||||
:class="{
|
||||
'hc-drag-marker-post': createOrUpdate,
|
||||
'hc-drag-marker-post': createAndUpdate,
|
||||
'hc-drag-marker-update-post': contribution,
|
||||
}"
|
||||
>
|
||||
@ -113,7 +113,7 @@ export default {
|
||||
previewTemplate: this.template(),
|
||||
},
|
||||
error: false,
|
||||
createOrUpdate: true,
|
||||
createAndUpdate: true,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user