From 944c8c291254b657ba75de1c046f3817bb8f03ea Mon Sep 17 00:00:00 2001 From: Alexander Do Date: Sat, 7 Apr 2018 03:22:26 +0000 Subject: [PATCH] Add test for missing browser language --- js/test/I18n.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/test/I18n.js b/js/test/I18n.js index 0d2fc084..c3a69b24 100644 --- a/js/test/I18n.js +++ b/js/test/I18n.js @@ -99,6 +99,28 @@ describe('I18n', function () { return language === result && language === alias; } ); + + jsc.property( + 'should default to en', + function() { + var clean = jsdom('', {url: 'https://privatebin.net/'}); + + [ 'language', 'userLanguage' ].forEach(function (key) { + Object.defineProperty(navigator, key, { + value: undefined, + writeable: false + }); + }); + + $.PrivateBin.I18n.reset('en'); + $.PrivateBin.I18n.loadTranslations(); + var result = $.PrivateBin.I18n.translate('en'), + alias = $.PrivateBin.I18n._('en'); + + clean(); + return 'en' === result && 'en' === alias; + } + ); }); });