|
| 1 | +import { Blob } from 'buffer' |
1 | 2 | import sharp from 'sharp' |
2 | 3 | import Md5 from 'md5' |
3 | 4 | import { describe, expect, it } from 'vitest' |
@@ -28,11 +29,22 @@ describe('upload should work', async () => { |
28 | 29 | token = result.data.uptoken |
29 | 30 | }) |
30 | 31 |
|
31 | | - it('upload image', async () => { |
32 | | - const result = await api.upload.upload(image, token) |
33 | | - expect(result.success).toBe(true) |
34 | | - expect(result.fileUrl).to.be.a('string') |
35 | | - expect(result.id).to.be.a('string') |
36 | | - expect(result.key).a('string') |
| 32 | + describe('upload image', () => { |
| 33 | + it('Buffer should work', async () => { |
| 34 | + // @ts-expect-error |
| 35 | + const result = await api.upload.upload(new Blob([image.buffer]), token) |
| 36 | + expect(result.success).toBe(true) |
| 37 | + expect(result.fileUrl).to.be.a('string') |
| 38 | + expect(result.id).to.be.a('string') |
| 39 | + expect(result.key).a('string') |
| 40 | + }) |
| 41 | + |
| 42 | + it('Blob should work', async () => { |
| 43 | + const result = await api.upload.upload(image, token) |
| 44 | + expect(result.success).toBe(true) |
| 45 | + expect(result.fileUrl).to.be.a('string') |
| 46 | + expect(result.id).to.be.a('string') |
| 47 | + expect(result.key).a('string') |
| 48 | + }) |
37 | 49 | }) |
38 | 50 | }) |
0 commit comments