-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var fs = require('fs'); | ||
var mkdirp = require('mkdirp'); | ||
var process = require('child_process'); | ||
|
||
var TRANSLATION_STORE_PATH = __dirname + '/../../../../data/translations'; | ||
|
||
var checkReturnedTranslations = function (actualTranslationJson) { | ||
var language = 'en'; | ||
var expectedTranslationJsonFile = __dirname + '/data/reference/' + language + '.json'; | ||
var expectedTranslationJson = require(expectedTranslationJsonFile); | ||
|
||
return compareTranslations(actualTranslationJson, expectedTranslationJson); | ||
}; | ||
|
||
var createTestTranslations = function () { | ||
var translationStorePath = TRANSLATION_STORE_PATH; | ||
var language = 'en'; | ||
var srcFile = __dirname + '/data/reference/' + language + '.json'; | ||
var destFile = translationStorePath + '/' + language + '.json'; | ||
|
||
if (!fs.existsSync(translationStorePath)) { | ||
mkdirp.sync(translationStorePath); | ||
} | ||
console.log('Write file: ' + srcFile + ' to file: ' + destFile); | ||
fs.writeFileSync(destFile, fs.readFileSync(srcFile)); | ||
}; | ||
|
||
var deleteTestTranslations = function () { | ||
var translationStorePath = TRANSLATION_STORE_PATH; | ||
process.execSync('rm -rf ' + translationStorePath); | ||
}; | ||
|
||
function compareTranslations(actual, expected) { | ||
var equal = true; | ||
|
||
for (var key in expected) { | ||
if (!actual.hasOwnProperty(key)) { | ||
equal = false; | ||
break; | ||
} | ||
if (actual[key] !== expected[key]) { | ||
equal = false; | ||
break; | ||
} | ||
} | ||
|
||
return equal; | ||
} | ||
|
||
module.exports.checkReturnedTranslations = checkReturnedTranslations; | ||
module.exports.createTestTranslations = createTestTranslations; | ||
module.exports.deleteTestTranslations = deleteTestTranslations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"test_plugin_1-NO_SSL": "Dont run the DE dev server using HTTPS", | ||
"test_plugin_1-DEV": "Run the DE server with development mode defaults" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"test_plugin_1-NO_SSL": "Dont run the dev server using HTTPS", | ||
"test_plugin_1-DEV": "Run the server with development mode defaults", | ||
"test_plugin_1-NO_RUN_SERVER": "Dont run the dev server", | ||
"test_plugin_1-HOME": "Run along home now!", | ||
"test_plugin_2-XXXXXX": "This is XXXXXX string", | ||
"test_plugin_2-YYYY_PPPP": "This is YYYY_PPPP string", | ||
"test_plugin_2-FFFFFFFFFFFF": "This is FFFFFFFFFFFF string", | ||
"test_plugin_2-ZZZ": "This is ZZZ string" | ||
} |