From 258535b58c69e5cedd4ea484123f3b0d678b6ca4 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Sat, 6 Sep 2014 00:00:04 +0200 Subject: [PATCH] Fix unit tests for non-english locales --- src/main.js | 27 ++++++++++++------------ src/utils/Global.js | 2 +- test/spec/CodeInspection-test.js | 3 +-- test/spec/FindReplace-test.js | 3 +-- test/spec/InstallExtensionDialog-test.js | 3 +-- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main.js b/src/main.js index 3250294d869..b1a56bef8d6 100644 --- a/src/main.js +++ b/src/main.js @@ -43,22 +43,23 @@ if (window.location.search.indexOf("testEnvironment") > -1) { require.config({ paths: { "preferences/PreferencesImpl": "../test/TestPreferencesImpl" - } + }, + locale: "en" // force English (US) + }); +} else { + /** + * hack for r.js optimization, move locale to another config call + * + * Use custom brackets property until CEF sets the correct navigator.language + * NOTE: When we change to navigator.language here, we also should change to + * navigator.language in ExtensionLoader (when making require contexts for each + * extension). + */ + require.config({ + locale: window.localStorage.getItem("locale") || (typeof (brackets) !== "undefined" ? brackets.app.language : navigator.language) }); } -/** - * hack for r.js optimization, move locale to another config call - * - * Use custom brackets property until CEF sets the correct navigator.language - * NOTE: When we change to navigator.language here, we also should change to - * navigator.language in ExtensionLoader (when making require contexts for each - * extension). - */ -require.config({ - locale: window.localStorage.getItem("locale") || (typeof (brackets) !== "undefined" ? brackets.app.language : navigator.language) -}); - define(function (require) { "use strict"; diff --git a/src/utils/Global.js b/src/utils/Global.js index 550c9d4b412..5901ac5c246 100644 --- a/src/utils/Global.js +++ b/src/utils/Global.js @@ -95,7 +95,7 @@ define(function (require, exports, module) { global.brackets.getLocale = function () { // By default use the locale that was determined in brackets.js - return global.localStorage.getItem("locale") || global.require.s.contexts._.config.locale; + return params.get("testEnvironment") ? "en" : (global.localStorage.getItem("locale") || global.require.s.contexts._.config.locale); }; global.brackets.setLocale = function (locale) { diff --git a/test/spec/CodeInspection-test.js b/test/spec/CodeInspection-test.js index 82e015523bd..92af1cdb520 100644 --- a/test/spec/CodeInspection-test.js +++ b/test/spec/CodeInspection-test.js @@ -30,7 +30,7 @@ define(function (require, exports, module) { var SpecRunnerUtils = require("spec/SpecRunnerUtils"), FileSystem = require("filesystem/FileSystem"), StringUtils = require("utils/StringUtils"), - Strings; + Strings = require("strings"); describe("Code Inspection", function () { this.category = "integration"; @@ -110,7 +110,6 @@ define(function (require, exports, module) { // Load module instances from brackets.test $ = testWindow.$; brackets = testWindow.brackets; - Strings = testWindow.require("strings"); CommandManager = brackets.test.CommandManager; DocumentManager = brackets.test.DocumentManager; EditorManager = brackets.test.EditorManager; diff --git a/test/spec/FindReplace-test.js b/test/spec/FindReplace-test.js index 1af03be4ae2..37fda2ae2be 100644 --- a/test/spec/FindReplace-test.js +++ b/test/spec/FindReplace-test.js @@ -33,7 +33,7 @@ define(function (require, exports, module) { KeyEvent = require("utils/KeyEvent"), SpecRunnerUtils = require("spec/SpecRunnerUtils"), StringUtils = require("utils/StringUtils"), - Strings, + Strings = require("strings"), _ = require("thirdparty/lodash"); var defaultContent = "/* Test comment */\n" + @@ -440,7 +440,6 @@ define(function (require, exports, module) { testWindow = w; // Load module instances from brackets.test - Strings = testWindow.require("strings"); twCommandManager = testWindow.brackets.test.CommandManager; twEditorManager = testWindow.brackets.test.EditorManager; twFindInFiles = testWindow.brackets.test.FindInFiles; diff --git a/test/spec/InstallExtensionDialog-test.js b/test/spec/InstallExtensionDialog-test.js index d353af34d25..35fe524e6b7 100644 --- a/test/spec/InstallExtensionDialog-test.js +++ b/test/spec/InstallExtensionDialog-test.js @@ -32,7 +32,7 @@ define(function (require, exports, module) { KeyEvent = require("utils/KeyEvent"), NativeApp = require("utils/NativeApp"), FileSystem, - Strings; + Strings = require("strings"); describe("Install Extension Dialog", function () { var testWindow, dialog, fields, goodInstaller, badInstaller, closed, @@ -43,7 +43,6 @@ define(function (require, exports, module) { beforeFirst(function () { SpecRunnerUtils.createTestWindowAndRun(this, function (w) { testWindow = w; - Strings = testWindow.require("strings"); FileSystem = testWindow.brackets.test.FileSystem; }); });