Skip to content

Commit

Permalink
Convert i18n tests to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal authored May 31, 2022
1 parent 49bb132 commit 06dec4f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ <h3>{{ welcomeToSignal }}</h3>

<script type="text/javascript" src="libphonenumber_util_test.js"></script>
<script type="text/javascript" src="reliable_trigger_test.js"></script>
<script type="text/javascript" src="i18n_test.js"></script>
<script type="text/javascript" src="stickers_test.js"></script>

<script type="text/javascript">
Expand Down
17 changes: 13 additions & 4 deletions test/i18n_test.js → ts/test-both/types/setupI18n_test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
// Copyright 2017-2020 Signal Messenger, LLC
// Copyright 2017-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

/* global i18n */
import { assert } from 'chai';
import type { LocalizerType } from '../../types/Util';
import { setupI18n } from '../../util/setupI18n';
import * as enMessages from '../../../_locales/en/messages.json';

describe('setupI18n', () => {
let i18n: LocalizerType;

beforeEach(() => {
i18n = setupI18n('en', enMessages);
});

describe('i18n', () => {
describe('i18n', () => {
it('returns empty string for unknown string', () => {
assert.strictEqual(i18n('random'), '');
});
it('returns message for given string', () => {
assert.equal(i18n('reportIssue'), ['Contact Support']);
assert.strictEqual(i18n('reportIssue'), 'Contact Support');
});
it('returns message with single substitution', () => {
const actual = i18n('migratingToSQLCipher', ['45/200']);
Expand Down

0 comments on commit 06dec4f

Please sign in to comment.