diff --git a/test/modules/types/mime_test.js b/test/modules/types/mime_test.js deleted file mode 100644 index 947fa6a29..000000000 --- a/test/modules/types/mime_test.js +++ /dev/null @@ -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)); - }); - }); - }); -}); diff --git a/test/modules/link_previews_test.js b/ts/test-node/types/LinkPreview_test.ts similarity index 98% rename from test/modules/link_previews_test.js rename to ts/test-node/types/LinkPreview_test.ts index c632ef2af..67d5c56f9 100644 --- a/test/modules/link_previews_test.js +++ b/ts/test-node/types/LinkPreview_test.ts @@ -1,13 +1,13 @@ -// Copyright 2019-2020 Signal Messenger, LLC +// Copyright 2019-2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -const { assert } = require('chai'); +import { assert } from 'chai'; -const { +import { findLinks, isLinkSafeToPreview, isLinkSneaky, -} = require('../../ts/types/LinkPreview'); +} from '../../types/LinkPreview'; describe('Link previews', () => { describe('#isLinkSafeToPreview', () => { diff --git a/ts/test-node/types/MIME_test.ts b/ts/test-node/types/MIME_test.ts index 0f3b18a48..970e0b212 100644 --- a/ts/test-node/types/MIME_test.ts +++ b/ts/test-node/types/MIME_test.ts @@ -1,4 +1,4 @@ -// Copyright 2021 Signal Messenger, LLC +// Copyright 2018-2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import { assert } from 'chai'; @@ -12,11 +12,29 @@ describe('MIME', () => { }); 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('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', () => { it('returns true for long messages', () => { assert.isTrue(MIME.isLongMessage('text/x-signal-plain'));