From a5a73e869ce69bc310f86b6162530816d12822f1 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Tue, 11 Jan 2022 19:10:35 -0600 Subject: [PATCH] Convert remaining main process tests to TypeScript --- test/app/.eslintrc.js | 15 ---------- .../test-node/app/protocol_filter_test.ts | 30 +++++++++---------- .../test-node/app/spell_check_test.ts | 6 ++-- 3 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 test/app/.eslintrc.js rename test/app/protocol_filter_test.js => ts/test-node/app/protocol_filter_test.ts (81%) rename test/app/spell_check_test.js => ts/test-node/app/spell_check_test.ts (89%) diff --git a/test/app/.eslintrc.js b/test/app/.eslintrc.js deleted file mode 100644 index 751462d5e..000000000 --- a/test/app/.eslintrc.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2018-2020 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only - -// For reference: https://github.com/airbnb/javascript - -module.exports = { - env: { - mocha: true, - browser: false, - }, - - parserOptions: { - sourceType: 'module', - }, -}; diff --git a/test/app/protocol_filter_test.js b/ts/test-node/app/protocol_filter_test.ts similarity index 81% rename from test/app/protocol_filter_test.js rename to ts/test-node/app/protocol_filter_test.ts index 4e3a892b7..4a2ad0915 100644 --- a/test/app/protocol_filter_test.js +++ b/ts/test-node/app/protocol_filter_test.ts @@ -1,9 +1,9 @@ -// Copyright 2018-2020 Signal Messenger, LLC +// Copyright 2018-2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -const { expect } = require('chai'); +import { assert } from 'chai'; -const { _urlToPath } = require('../../app/protocol_filter'); +import { _urlToPath } from '../../../app/protocol_filter'; describe('Protocol Filter', () => { describe('_urlToPath', () => { @@ -14,7 +14,7 @@ describe('Protocol Filter', () => { '/Users/someone/Development/signal/electron/background.html'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('returns proper file path for unix style file URI with querystring', () => { @@ -24,7 +24,7 @@ describe('Protocol Filter', () => { '/Users/someone/Development/signal/electron/background.html'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('returns proper file path for unix style file URI with hash and querystring', () => { @@ -34,7 +34,7 @@ describe('Protocol Filter', () => { '/Users/someone/Development/signal/electron/background.html'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('returns proper file path for file URI on windows', () => { @@ -44,7 +44,7 @@ describe('Protocol Filter', () => { const isWindows = true; const actual = _urlToPath(path, { isWindows }); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('translates from URL format to filesystem format', () => { @@ -54,7 +54,7 @@ describe('Protocol Filter', () => { '/Users/someone/Development Files/signal/electron/background.html'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('translates from URL format to filesystem format', () => { @@ -64,7 +64,7 @@ describe('Protocol Filter', () => { '/Users/someone/Development Files/signal/electron/background.html'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('handles UNC path', () => { @@ -72,7 +72,7 @@ describe('Protocol Filter', () => { const expected = '//share/path'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('handles UNC path on windows', () => { @@ -81,7 +81,7 @@ describe('Protocol Filter', () => { const isWindows = true; const actual = _urlToPath(path, { isWindows }); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('handles simple relative path', () => { @@ -89,16 +89,16 @@ describe('Protocol Filter', () => { const expected = 'relative/path'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); - it('handles simple relative path', () => { + it('handles simple relative path on Windows', () => { const path = 'file://relative/path'; const expected = 'elative/path'; const isWindows = true; const actual = _urlToPath(path, { isWindows }); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); it('hands back a path with .. in it', () => { @@ -106,7 +106,7 @@ describe('Protocol Filter', () => { const expected = '../../..'; const actual = _urlToPath(path); - expect(actual).to.equal(expected); + assert.strictEqual(actual, expected); }); }); }); diff --git a/test/app/spell_check_test.js b/ts/test-node/app/spell_check_test.ts similarity index 89% rename from test/app/spell_check_test.js rename to ts/test-node/app/spell_check_test.ts index 169cc285a..4f9d1c700 100644 --- a/test/app/spell_check_test.js +++ b/ts/test-node/app/spell_check_test.ts @@ -1,9 +1,9 @@ -// Copyright 2020 Signal Messenger, LLC +// Copyright 2020-2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -const { assert } = require('chai'); +import { assert } from 'chai'; -const { getLanguages } = require('../../app/spell_check'); +import { getLanguages } from '../../../app/spell_check'; describe('SpellCheck', () => { describe('getLanguages', () => {