mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
chore: minor tweaks
This commit is contained in:
committed by
Chathula
parent
983216b10e
commit
0ac7959927
@@ -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"
|
||||
|
||||
@@ -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)',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user