chore: minor tweaks

This commit is contained in:
Kamil Myśliwiec
2025-04-11 13:42:34 +02:00
committed by Chathula
parent 983216b10e
commit 0ac7959927
2 changed files with 23 additions and 0 deletions

View File

@@ -25,6 +25,7 @@
"peerDependencies": {
"class-transformer": "*",
"class-validator": "*",
"file-type": "^20.4.1",
"reflect-metadata": "^0.1.12 || ^0.2.0",
"rxjs": "^7.1.0",
"file-type": "20.4.1"

View File

@@ -235,5 +235,27 @@ describe('FileTypeValidator', () => {
'Validation failed (detected file type is image/png, expected type is jpeg)',
);
});
it('should handle regexp file type in error message', async () => {
const fileTypeValidator = new FileTypeValidator({
fileType: /^image\//,
});
const file = { mimetype: 'application/pdf' } as IFile;
expect(fileTypeValidator.buildErrorMessage(file)).to.equal(
`Validation failed (current file type is application/pdf, expected type is /^image\\//)`,
);
});
it('should handle file extension in error message', async () => {
const fileTypeValidator = new FileTypeValidator({
fileType: 'jpeg',
});
const file = { mimetype: 'image/png' } as IFile;
expect(fileTypeValidator.buildErrorMessage(file)).to.equal(
'Validation failed (current file type is image/png, expected type is jpeg)',
);
});
});
});