signal-desktop/test/i18n_test.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2017-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2018-11-02 18:02:53 +00:00
/* global i18n */
describe('i18n', () => {
describe('i18n', () => {
it('returns empty string for unknown string', () => {
assert.strictEqual(i18n('random'), '');
});
2018-11-02 18:02:53 +00:00
it('returns message for given string', () => {
assert.equal(i18n('reportIssue'), ['Contact Support']);
});
it('returns message with single substitution', () => {
2022-02-02 21:13:56 +00:00
const actual = i18n('migratingToSQLCipher', ['45/200']);
assert.equal(actual, 'Optimizing messages... 45/200 complete.');
});
2018-11-02 18:02:53 +00:00
it('returns message with multiple substitutions', () => {
const actual = i18n('theyChangedTheTimer', {
name: 'Someone',
time: '5 minutes',
});
assert.equal(
actual,
'Someone set the disappearing message time to 5 minutes.'
);
});
});
2018-11-02 18:02:53 +00:00
describe('getLocale', () => {
it('returns a string with length two or greater', () => {
const locale = i18n.getLocale();
assert.isAtLeast(locale.trim().length, 2);
});
});
});