Move link preview and MIME tests to TypeScript
This commit is contained in:
parent
114316745d
commit
0c28561473
|
@ -1,31 +0,0 @@
|
||||||
// Copyright 2018-2020 Signal Messenger, LLC
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
const { assert } = require('chai');
|
|
||||||
|
|
||||||
const MIME = require('../../../ts/types/MIME');
|
|
||||||
|
|
||||||
describe('MIME', () => {
|
|
||||||
describe('isJPEG', () => {
|
|
||||||
it('should return true for `image/jpeg`', () => {
|
|
||||||
assert.isTrue(MIME.isJPEG('image/jpeg'));
|
|
||||||
});
|
|
||||||
|
|
||||||
[
|
|
||||||
'jpg',
|
|
||||||
'jpeg',
|
|
||||||
'image/jpg', // invalid MIME type: https://stackoverflow.com/a/37266399/125305
|
|
||||||
'image/gif',
|
|
||||||
'image/tiff',
|
|
||||||
'application/json',
|
|
||||||
0,
|
|
||||||
false,
|
|
||||||
null,
|
|
||||||
undefined,
|
|
||||||
].forEach(value => {
|
|
||||||
it(`should return false for \`${value}\``, () => {
|
|
||||||
assert.isFalse(MIME.isJPEG(value));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,13 +1,13 @@
|
||||||
// Copyright 2019-2020 Signal Messenger, LLC
|
// Copyright 2019-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
const { assert } = require('chai');
|
import { assert } from 'chai';
|
||||||
|
|
||||||
const {
|
import {
|
||||||
findLinks,
|
findLinks,
|
||||||
isLinkSafeToPreview,
|
isLinkSafeToPreview,
|
||||||
isLinkSneaky,
|
isLinkSneaky,
|
||||||
} = require('../../ts/types/LinkPreview');
|
} from '../../types/LinkPreview';
|
||||||
|
|
||||||
describe('Link previews', () => {
|
describe('Link previews', () => {
|
||||||
describe('#isLinkSafeToPreview', () => {
|
describe('#isLinkSafeToPreview', () => {
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2018-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
|
@ -12,11 +12,29 @@ describe('MIME', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns false for non-GIFs', () => {
|
it('returns false for non-GIFs', () => {
|
||||||
|
assert.isFalse(MIME.isGif(''));
|
||||||
|
assert.isFalse(MIME.isGif('gif'));
|
||||||
assert.isFalse(MIME.isGif('image/jpeg'));
|
assert.isFalse(MIME.isGif('image/jpeg'));
|
||||||
assert.isFalse(MIME.isGif('text/plain'));
|
assert.isFalse(MIME.isGif('text/plain'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isJPEG', () => {
|
||||||
|
it('should return true for `image/jpeg`', () => {
|
||||||
|
assert.isTrue(MIME.isJPEG('image/jpeg'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false for non-JPEGs', () => {
|
||||||
|
assert.isFalse(MIME.isJPEG(''));
|
||||||
|
assert.isFalse(MIME.isJPEG('jpg'));
|
||||||
|
assert.isFalse(MIME.isJPEG('jpeg'));
|
||||||
|
assert.isFalse(MIME.isJPEG('image/jpg')); // invalid MIME type: https://stackoverflow.com/a/37266399/125305
|
||||||
|
assert.isFalse(MIME.isJPEG('image/gif'));
|
||||||
|
assert.isFalse(MIME.isJPEG('image/tiff'));
|
||||||
|
assert.isFalse(MIME.isJPEG('application/json'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('isLongMessage', () => {
|
describe('isLongMessage', () => {
|
||||||
it('returns true for long messages', () => {
|
it('returns true for long messages', () => {
|
||||||
assert.isTrue(MIME.isLongMessage('text/x-signal-plain'));
|
assert.isTrue(MIME.isLongMessage('text/x-signal-plain'));
|
||||||
|
|
Loading…
Reference in New Issue