mirror of
https://github.com/youzan/vant.git
synced 2025-10-17 08:37:23 +00:00
test(Uploader): add test cases (#8318)
* test(Uploader): add test cases * test(Uploader): add test cases * test(Uploader): add test cases * test(Uploader): 修复类型错误 Co-authored-by: nemo-shen <1034131477@qq.com>
This commit is contained in:
23
src/uploader/test/utils.spec.ts
Normal file
23
src/uploader/test/utils.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { isImageFile } from '../utils';
|
||||
|
||||
test('isImageFile', () => {
|
||||
expect(isImageFile({ url: 'https://a.jpg' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.jpeg' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.png' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.svg' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.gif' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.webp' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.jfif' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.bmp' })).toBeTruthy();
|
||||
expect(isImageFile({ url: 'https://a.dpg' })).toBeTruthy();
|
||||
expect(
|
||||
isImageFile({ file: new File([], 'foo.jpg', { type: 'image/jpg' }) })
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
isImageFile({ file: new File([], 'bar.pdf', { type: 'application/pdf' }) })
|
||||
).toBeFalsy();
|
||||
expect(isImageFile({ content: 'data:image/xxx' })).toBeTruthy();
|
||||
expect(isImageFile({ content: 'data:application/xxx' })).toBeFalsy();
|
||||
expect(isImageFile({ isImage: true })).toBeTruthy();
|
||||
expect(isImageFile({})).toBeFalsy();
|
||||
});
|
Reference in New Issue
Block a user