2020-10-30 15:34:04 -05:00
// Copyright 2017-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2018-11-02 11:02:53 -07:00
/* global i18n */
describe ( 'i18n' , ( ) => {
describe ( 'i18n' , ( ) => {
it ( 'returns empty string for unknown string' , ( ) => {
2018-03-23 18:37:32 -07:00
assert . strictEqual ( i18n ( 'random' ) , '' ) ;
2017-05-15 14:48:19 -07:00
} ) ;
2018-11-02 11:02:53 -07:00
it ( 'returns message for given string' , ( ) => {
2021-10-06 12:16:51 -04:00
assert . equal ( i18n ( 'reportIssue' ) , [ 'Contact Support' ] ) ;
2017-05-15 14:48:19 -07:00
} ) ;
2020-02-13 10:14:08 -08:00
it ( 'returns message with single substitution' , ( ) => {
2020-07-29 16:20:05 -07:00
const actual = i18n ( 'cannotUpdateDetail' , [
'https://signal.org/download' ,
] ) ;
2020-02-13 10:14:08 -08:00
assert . equal (
actual ,
'Signal Desktop failed to update, but there is a new version available. Please go to https://signal.org/download and install the new version manually, then either contact support or file a bug about this problem.'
) ;
} ) ;
2018-11-02 11:02:53 -07:00
it ( 'returns message with multiple substitutions' , ( ) => {
2020-07-29 16:20:05 -07:00
const actual = i18n ( 'theyChangedTheTimer' , {
name : 'Someone' ,
time : '5 minutes' ,
} ) ;
2018-07-09 14:29:13 -07:00
assert . equal (
actual ,
2020-07-29 16:20:05 -07:00
'Someone set the disappearing message time to 5 minutes.'
2018-07-09 14:29:13 -07:00
) ;
2017-05-15 14:48:19 -07:00
} ) ;
} ) ;
2018-11-02 11:02:53 -07:00
describe ( 'getLocale' , ( ) => {
it ( 'returns a string with length two or greater' , ( ) => {
2017-05-15 14:48:19 -07:00
const locale = i18n . getLocale ( ) ;
assert . isAtLeast ( locale . trim ( ) . length , 2 ) ;
} ) ;
} ) ;
} ) ;