Add test for missing browser language

This commit is contained in:
Alexander Do 2018-04-07 03:22:26 +00:00
parent c6950b9b56
commit 944c8c2912
1 changed files with 22 additions and 0 deletions

View File

@ -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;
}
);
});
});