image upload: fixed tests

This commit is contained in:
Moriz Wahl 2021-02-08 16:50:50 +01:00
parent 650e83f4c2
commit 001515f92a
2 changed files with 4 additions and 11 deletions

View File

@ -151,6 +151,7 @@ describe('ContributionForm.vue', () => {
aspectRatio: null, aspectRatio: null,
sensitive: false, sensitive: false,
upload: imageUpload, upload: imageUpload,
type: null,
} }
const spy = jest const spy = jest
.spyOn(FileReader.prototype, 'readAsDataURL') .spyOn(FileReader.prototype, 'readAsDataURL')

View File

@ -25,19 +25,11 @@ describe('ImageUploader.vue', () => {
describe('handles errors', () => { describe('handles errors', () => {
beforeEach(() => jest.useFakeTimers()) beforeEach(() => jest.useFakeTimers())
const message = 'File upload failed' const unSupportedFileMessage = 'message'
const fileError = { status: 'error' }
const unSupportedFileMessage =
'Please upload an image of file format : JPG , JPEG , PNG or GIF'
it('shows an error toaster when verror is called', () => {
wrapper.vm.onDropzoneError(fileError, message)
expect(mocks.$toast.error).toHaveBeenCalledWith(fileError.status, message)
})
it('shows an error toaster when unSupported file is uploaded', () => { it('shows an error toaster when unSupported file is uploaded', () => {
wrapper.vm.onUnSupportedFormat(fileError.status, unSupportedFileMessage) wrapper.vm.onUnSupportedFormat(unSupportedFileMessage)
expect(mocks.$toast.error).toHaveBeenCalledWith(fileError.status, unSupportedFileMessage) expect(mocks.$toast.error).toHaveBeenCalledWith(unSupportedFileMessage)
}) })
}) })
}) })