Convert remaining main process tests to TypeScript
This commit is contained in:
parent
8f2c663a12
commit
a5a73e869c
3 changed files with 18 additions and 33 deletions
|
@ -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',
|
||||
},
|
||||
};
|
|
@ -1,112 +0,0 @@
|
|||
// Copyright 2018-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const { _urlToPath } = require('../../app/protocol_filter');
|
||||
|
||||
describe('Protocol Filter', () => {
|
||||
describe('_urlToPath', () => {
|
||||
it('returns proper file path for unix style file URI with hash', () => {
|
||||
const path =
|
||||
'file:///Users/someone/Development/signal/electron/background.html#first-page';
|
||||
const expected =
|
||||
'/Users/someone/Development/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns proper file path for unix style file URI with querystring', () => {
|
||||
const path =
|
||||
'file:///Users/someone/Development/signal/electron/background.html?name=Signal&locale=en&version=2.4.0';
|
||||
const expected =
|
||||
'/Users/someone/Development/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns proper file path for unix style file URI with hash and querystring', () => {
|
||||
const path =
|
||||
'file:///Users/someone/Development/signal/electron/background.html#somewhere?name=Signal';
|
||||
const expected =
|
||||
'/Users/someone/Development/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns proper file path for file URI on windows', () => {
|
||||
const path =
|
||||
'file:///C:/Users/Someone/dev/desktop/background.html?name=Signal&locale=en&version=2.4.0';
|
||||
const expected = 'C:/Users/Someone/dev/desktop/background.html';
|
||||
const isWindows = true;
|
||||
|
||||
const actual = _urlToPath(path, { isWindows });
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('translates from URL format to filesystem format', () => {
|
||||
const path =
|
||||
'file:///Users/someone/Development%20Files/signal/electron/background.html';
|
||||
const expected =
|
||||
'/Users/someone/Development Files/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('translates from URL format to filesystem format', () => {
|
||||
const path =
|
||||
'file:///Users/someone/Development%20Files/signal/electron/background.html';
|
||||
const expected =
|
||||
'/Users/someone/Development Files/signal/electron/background.html';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('handles UNC path', () => {
|
||||
const path = '//share/path';
|
||||
const expected = '//share/path';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('handles UNC path on windows', () => {
|
||||
const path = '//share/path';
|
||||
const expected = '//share/path';
|
||||
const isWindows = true;
|
||||
|
||||
const actual = _urlToPath(path, { isWindows });
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('handles simple relative path', () => {
|
||||
const path = 'file://relative/path';
|
||||
const expected = 'relative/path';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('handles simple relative path', () => {
|
||||
const path = 'file://relative/path';
|
||||
const expected = 'elative/path';
|
||||
const isWindows = true;
|
||||
|
||||
const actual = _urlToPath(path, { isWindows });
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
|
||||
it('hands back a path with .. in it', () => {
|
||||
const path = 'file://../../..';
|
||||
const expected = '../../..';
|
||||
|
||||
const actual = _urlToPath(path);
|
||||
expect(actual).to.equal(expected);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
const { assert } = require('chai');
|
||||
|
||||
const { getLanguages } = require('../../app/spell_check');
|
||||
|
||||
describe('SpellCheck', () => {
|
||||
describe('getLanguages', () => {
|
||||
it('works with locale and base available', () => {
|
||||
assert.deepEqual(getLanguages('en-US', ['en-US', 'en-CA', 'en']), [
|
||||
'en-US',
|
||||
'en',
|
||||
]);
|
||||
});
|
||||
|
||||
it('works with neither locale nor base available', () => {
|
||||
assert.deepEqual(getLanguages('en-US', ['en-NZ', 'en-CA']), [
|
||||
'en-NZ',
|
||||
'en-CA',
|
||||
]);
|
||||
});
|
||||
|
||||
it('works with only base locale available', () => {
|
||||
assert.deepEqual(getLanguages('en-US', ['en', 'en-CA']), ['en']);
|
||||
});
|
||||
|
||||
it('works with only full locale available', () => {
|
||||
assert.deepEqual(getLanguages('en-US', ['en-CA', 'en-US']), ['en-US']);
|
||||
});
|
||||
|
||||
it('works with base provided and base available', () => {
|
||||
assert.deepEqual(getLanguages('en', ['en-CA', 'en-US', 'en']), ['en']);
|
||||
});
|
||||
|
||||
it('works with base provided and base not available', () => {
|
||||
assert.deepEqual(getLanguages('en', ['en-CA', 'en-US']), [
|
||||
'en-CA',
|
||||
'en-US',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue