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' , ( ) => {
2018-03-24 01:37:32 +00:00
assert . strictEqual ( i18n ( 'random' ) , '' ) ;
2017-05-15 21:48:19 +00:00
} ) ;
2018-11-02 18:02:53 +00:00
it ( 'returns message for given string' , ( ) => {
2020-07-29 23:20:05 +00:00
assert . equal ( i18n ( 'reportIssue' ) , [ 'Report an issue' ] ) ;
2017-05-15 21:48:19 +00:00
} ) ;
2020-02-13 18:14:08 +00:00
it ( 'returns message with single substitution' , ( ) => {
2020-07-29 23:20:05 +00:00
const actual = i18n ( 'cannotUpdateDetail' , [
'https://signal.org/download' ,
] ) ;
2020-02-13 18:14:08 +00: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 18:02:53 +00:00
it ( 'returns message with multiple substitutions' , ( ) => {
2020-07-29 23:20:05 +00:00
const actual = i18n ( 'theyChangedTheTimer' , {
name : 'Someone' ,
time : '5 minutes' ,
} ) ;
2018-07-09 21:29:13 +00:00
assert . equal (
actual ,
2020-07-29 23:20:05 +00:00
'Someone set the disappearing message time to 5 minutes.'
2018-07-09 21:29:13 +00:00
) ;
2017-05-15 21:48:19 +00:00
} ) ;
} ) ;
2018-11-02 18:02:53 +00:00
describe ( 'getLocale' , ( ) => {
it ( 'returns a string with length two or greater' , ( ) => {
2017-05-15 21:48:19 +00:00
const locale = i18n . getLocale ( ) ;
assert . isAtLeast ( locale . trim ( ) . length , 2 ) ;
} ) ;
} ) ;
} ) ;