diff --git a/packages/storage/__tests__/providers/s3/utils/md5.native.test.ts b/packages/storage/__tests__/providers/s3/utils/md5.native.test.ts index aea1eab7743..ec70d0a8e14 100644 --- a/packages/storage/__tests__/providers/s3/utils/md5.native.test.ts +++ b/packages/storage/__tests__/providers/s3/utils/md5.native.test.ts @@ -69,23 +69,23 @@ describe('calculateContentMd5 (native)', () => { mockMd5.mockReset(); }); - it('calculates MD5 for content type: string', async () => { - await calculateContentMd5(stringContent); - const [mockMd5Instance] = mockMd5.mock.instances; - expect(mockMd5Instance.update.mock.calls[0][0]).toBe(stringContent); - expect(mockToBase64).toHaveBeenCalled(); - }); - it.each([ + { type: 'string', content: stringContent }, { type: 'ArrayBuffer view', content: new Uint8Array() }, { type: 'ArrayBuffer', content: new ArrayBuffer(8) }, - { type: 'Blob', content: new Blob([stringContent]) }, ])('calculates MD5 for content type: $type', async ({ content }) => { + await calculateContentMd5(content); + const [mockMd5Instance] = mockMd5.mock.instances; + expect(mockMd5Instance.update.mock.calls[0][0]).toBe(content); + expect(mockToBase64).toHaveBeenCalled(); + }); + + it('calculates MD5 for content type: blob', async () => { Object.defineProperty(global, 'FileReader', { writable: true, value: jest.fn(() => mockSuccessfulFileReader), }); - await calculateContentMd5(content); + await calculateContentMd5(new Blob([stringContent])); const [mockMd5Instance] = mockMd5.mock.instances; expect(mockMd5Instance.update.mock.calls[0][0]).toBe(fileReaderResult); expect(mockSuccessfulFileReader.readAsArrayBuffer).toHaveBeenCalled(); diff --git a/packages/storage/__tests__/providers/s3/utils/md5.test.ts b/packages/storage/__tests__/providers/s3/utils/md5.test.ts index 2de7f7dfd0e..7412d58e571 100644 --- a/packages/storage/__tests__/providers/s3/utils/md5.test.ts +++ b/packages/storage/__tests__/providers/s3/utils/md5.test.ts @@ -46,23 +46,23 @@ describe('calculateContentMd5', () => { mockMd5.mockReset(); }); - it('calculates MD5 for content type: string', async () => { - await calculateContentMd5(stringContent); - const [mockMd5Instance] = mockMd5.mock.instances; - expect(mockMd5Instance.update.mock.calls[0][0]).toBe(stringContent); - expect(mockToBase64).toHaveBeenCalled(); - }); - it.each([ + { type: 'string', content: stringContent }, { type: 'ArrayBuffer view', content: new Uint8Array() }, { type: 'ArrayBuffer', content: new ArrayBuffer(8) }, - { type: 'Blob', content: new Blob([stringContent]) }, ])('calculates MD5 for content type: $type', async ({ content }) => { + await calculateContentMd5(content); + const [mockMd5Instance] = mockMd5.mock.instances; + expect(mockMd5Instance.update.mock.calls[0][0]).toBe(content); + expect(mockToBase64).toHaveBeenCalled(); + }); + + it('calculates MD5 for content type: blob', async () => { Object.defineProperty(global, 'FileReader', { writable: true, value: jest.fn(() => mockSuccessfulFileReader), }); - await calculateContentMd5(content); + await calculateContentMd5(new Blob([stringContent])); const [mockMd5Instance] = mockMd5.mock.instances; expect(mockMd5Instance.update.mock.calls[0][0]).toBe(fileReaderResult); expect(mockSuccessfulFileReader.readAsArrayBuffer).toHaveBeenCalled();