mirror of
https://github.com/strapi/strapi.git
synced 2025-11-09 14:51:29 +00:00
Init test for upload service
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
e5b319d81e
commit
dd93ccd590
@ -21,7 +21,7 @@ const generateFileName = name => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
formatFileInfo({ filename, type, size }, fileInfo, metas) {
|
formatFileInfo({ filename, type, size }, fileInfo = {}, metas = {}) {
|
||||||
const ext = path.extname(filename);
|
const ext = path.extname(filename);
|
||||||
const baseName = path.basename(filename, ext);
|
const baseName = path.basename(filename, ext);
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,21 @@
|
|||||||
|
const uploadService = require('../Upload');
|
||||||
|
|
||||||
|
describe('Upload service', () => {
|
||||||
|
describe('formatFileInfo', () => {
|
||||||
|
test('Generates hash', () => {
|
||||||
|
const fileData = {
|
||||||
|
filename: 'File Name.png',
|
||||||
|
type: 'image/png',
|
||||||
|
size: 1000 * 1000,
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(uploadService.formatFileInfo(fileData)).toMatchObject({
|
||||||
|
name: 'File Name',
|
||||||
|
hash: expect.stringContaining('File_Name'),
|
||||||
|
ext: '.png',
|
||||||
|
mime: 'image/png',
|
||||||
|
size: 1000,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user