2021-05-21 15:17:21 +02:00
|
|
|
const mimeUtils = require('./mime-utils.js').mime;
|
2020-06-09 21:15:43 +02:00
|
|
|
|
|
|
|
describe('mimeUils', function() {
|
|
|
|
|
|
|
|
beforeEach(async (done) => {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2020-12-01 20:05:24 +02:00
|
|
|
it('should get the file extension from the mime type', (async () => {
|
2020-06-09 21:15:43 +02:00
|
|
|
expect(mimeUtils.toFileExtension('image/jpeg')).toBe('jpg');
|
|
|
|
expect(mimeUtils.toFileExtension('image/jpg')).toBe('jpg');
|
|
|
|
expect(mimeUtils.toFileExtension('IMAGE/JPG')).toBe('jpg');
|
|
|
|
expect(mimeUtils.toFileExtension('')).toBe(null);
|
|
|
|
}));
|
|
|
|
|
2020-12-01 20:05:24 +02:00
|
|
|
it('should get the mime type from the filename', (async () => {
|
2020-06-09 21:15:43 +02:00
|
|
|
expect(mimeUtils.fromFilename('test.jpg')).toBe('image/jpeg');
|
|
|
|
expect(mimeUtils.fromFilename('test.JPG')).toBe('image/jpeg');
|
|
|
|
expect(mimeUtils.fromFilename('test.doesntexist')).toBe(null);
|
|
|
|
expect(mimeUtils.fromFilename('test')).toBe(null);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|