mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-15 07:28:59 +00:00
Add MIME type module
This commit is contained in:
3
js/modules/types/mime.js
Normal file
3
js/modules/types/mime.js
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.isJPEG = mimeType =>
|
||||
mimeType === 'image/jpeg' ||
|
||||
mimeType === 'image/jpg';
|
||||
23
test/modules/types/mime_test.js
Normal file
23
test/modules/types/mime_test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { assert } = require('chai');
|
||||
|
||||
const MIME = require('../../../js/modules/types/mime');
|
||||
|
||||
|
||||
describe('MIME', () => {
|
||||
describe('isJPEG', () => {
|
||||
it('should return true for `image/jpeg`', () => {
|
||||
assert.isTrue(MIME.isJPEG('image/jpeg'));
|
||||
});
|
||||
|
||||
it('should return true for `image/jpg`', () => {
|
||||
assert.isTrue(MIME.isJPEG('image/jpeg'));
|
||||
});
|
||||
|
||||
['image/gif', 'image/tiff', 'application/json', 0, false, null, undefined]
|
||||
.forEach((value) => {
|
||||
it(`should return false for \`${value}\``, () => {
|
||||
assert.isFalse(MIME.isJPEG(value));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user