diff options
author | Samuel Mannehed <samuel@cendio.se> | 2016-11-28 16:11:47 +0100 |
---|---|---|
committer | Samuel Mannehed <samuel@cendio.se> | 2016-11-28 16:14:55 +0100 |
commit | 77bc3a551bf505c493eb63cfc8a3df1a08e763e3 (patch) | |
tree | d114a88605ad0e4917490098c1a5fffc627dcd1c | |
parent | ffa819eec198e2f3934a35b07b963976ca1f7ebd (diff) | |
download | novnc-77bc3a551bf505c493eb63cfc8a3df1a08e763e3.tar.gz |
Fix translation util tests
We have to temporarily replace window.navigator due to the fact that
its property languages is read-only. The tests for the translation
utilities require different values of this property. The failing tests
were added in merge of PR #718 (in commit
f5bf2d84ef1bae02dfaff068de7565664a00fba3).
-rw-r--r-- | tests/test.util.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test.util.js b/tests/test.util.js index fbce2ef..bce475d 100644 --- a/tests/test.util.js +++ b/tests/test.util.js @@ -57,6 +57,19 @@ describe('Utils', function() { }); describe('language selection', function () { + var origNavigator; + beforeEach(function () { + // window.navigator is a protected read-only property in many + // environments, so we need to redefine it whilst running these + // tests. + origNavigator = Object.getOwnPropertyDescriptor(window, "navigator"); + Object.defineProperty(window, "navigator", {value: {}}); + window.navigator.languages = []; + }); + afterEach(function () { + Object.defineProperty(window, "navigator", origNavigator); + }); + it('should use English by default', function() { expect(Util.Localisation.language).to.equal('en'); }); |