mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
fix: Prever FileReader over URL.createObjectUrl
Apparently, URL.createObjectUrl is not supported in JSDom, see: https://github.com/jsdom/jsdom/issues/1721 With FileReader we have the option to avoid it altogether.
This commit is contained in:
parent
9c98e30bb8
commit
9241305d43
@ -233,10 +233,13 @@ describe('ContributionForm.vue', () => {
|
||||
})
|
||||
|
||||
it('supports adding a teaser image', async () => {
|
||||
const spy = jest.spyOn(FileReader.prototype, 'readAsDataURL').mockImplementation(() => {})
|
||||
expectedParams.variables.imageUpload = imageUpload
|
||||
wrapper.find(ImageUploader).vm.$emit('addHeroImage', imageUpload)
|
||||
await wrapper.find('form').trigger('submit')
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams))
|
||||
expect(spy).toHaveBeenCalledWith(imageUpload)
|
||||
spy.mockReset()
|
||||
})
|
||||
|
||||
it('content is valid with just a link', async () => {
|
||||
|
||||
@ -194,8 +194,15 @@ export default {
|
||||
this.$refs.contributionForm.update('content', value)
|
||||
},
|
||||
addHeroImage(file) {
|
||||
this.formData.image = null
|
||||
if (file) {
|
||||
const reader = new FileReader()
|
||||
reader.onload = ({ target }) => {
|
||||
this.formData.image = target.result
|
||||
}
|
||||
this.imageUpload = file
|
||||
this.formData.image = file ? URL.createObjectURL(file) : null
|
||||
reader.readAsDataURL(file)
|
||||
}
|
||||
},
|
||||
addImageAspectRatio(aspectRatio) {
|
||||
this.formData.imageAspectRatio = aspectRatio
|
||||
|
||||
@ -66,7 +66,7 @@ describe('PostTeaser', () => {
|
||||
}
|
||||
|
||||
it('has no validation errors', () => {
|
||||
const spy = jest.spyOn(global.console, 'error');
|
||||
const spy = jest.spyOn(global.console, 'error')
|
||||
Wrapper()
|
||||
expect(spy).not.toBeCalled()
|
||||
spy.mockReset()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user