2022-01-12 01:10:35 +00:00
|
|
|
// Copyright 2020-2022 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-01-12 01:10:35 +00:00
|
|
|
import { assert } from 'chai';
|
2020-04-15 20:44:46 +00:00
|
|
|
|
2022-01-12 01:10:35 +00:00
|
|
|
import { getLanguages } from '../../../app/spell_check';
|
2020-04-15 20:44:46 +00:00
|
|
|
|
|
|
|
describe('SpellCheck', () => {
|
|
|
|
describe('getLanguages', () => {
|
|
|
|
it('works with locale and base available', () => {
|
|
|
|
assert.deepEqual(getLanguages('en-US', ['en-US', 'en-CA', 'en']), [
|
|
|
|
'en-US',
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
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', () => {
|
2022-06-27 20:44:13 +00:00
|
|
|
assert.deepEqual(getLanguages('en-US', ['en', 'en-CA']), ['en', 'en-CA']);
|
2020-04-15 20:44:46 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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',
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|