Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8995 from MarcelGerber/test-window-en-locale
Browse files Browse the repository at this point in the history
Fix unit tests for non-english locales
  • Loading branch information
JeffryBooher committed Oct 10, 2014
2 parents 03a062c + af77b22 commit 72001b0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
27 changes: 14 additions & 13 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/utils/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions test/spec/CodeInspection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions test/spec/FindReplace-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

var defaultContent = "/* Test comment */\n" +
"define(function (require, exports, module) {\n" +
Expand Down Expand Up @@ -438,7 +438,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;
Expand Down
3 changes: 1 addition & 2 deletions test/spec/InstallExtensionDialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ define(function (require, exports, module) {
var SpecRunnerUtils = require("spec/SpecRunnerUtils"),
KeyEvent = require("utils/KeyEvent"),
FileSystem,
Strings;
Strings = require("strings");

describe("Install Extension Dialog", function () {
var testWindow, dialog, fields, closed,
Expand All @@ -42,7 +42,6 @@ define(function (require, exports, module) {
beforeFirst(function () {
SpecRunnerUtils.createTestWindowAndRun(this, function (w) {
testWindow = w;
Strings = testWindow.require("strings");
FileSystem = testWindow.brackets.test.FileSystem;
});
});
Expand Down

0 comments on commit 72001b0

Please sign in to comment.