mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 03:39:55 +00:00
Cleanup test directory (#2937)
Moves files around and renames some so that the structure is cleaner and more consistent
This commit is contained in:
parent
21ae79b386
commit
a328ce537f
@ -21,6 +21,7 @@ Special thanks to: @rejas, @sdetweil
|
||||
|
||||
### Updated
|
||||
|
||||
- Cleaned up test directory
|
||||
- Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests
|
||||
- Updated da translation
|
||||
- Rework weather module
|
||||
|
@ -73,7 +73,8 @@ function Server(config, callback) {
|
||||
|
||||
app.use("/js", express.static(__dirname));
|
||||
|
||||
const directories = ["/config", "/css", "/fonts", "/modules", "/vendor", "/translations", "/tests/configs"];
|
||||
// TODO add tests directory only when running tests?
|
||||
const directories = ["/config", "/css", "/fonts", "/modules", "/vendor", "/translations", "/tests/configs", "/tests/mocks"];
|
||||
for (const directory of directories) {
|
||||
app.use(directory, express.static(path.resolve(global.root_path + directory)));
|
||||
}
|
||||
|
1279
package-lock.json
generated
1279
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -50,27 +50,27 @@
|
||||
"homepage": "https://magicmirror.builders",
|
||||
"devDependencies": {
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-jest": "^27.0.4",
|
||||
"eslint-plugin-jest": "^27.1.1",
|
||||
"eslint-plugin-jsdoc": "^39.3.6",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^29.0.3",
|
||||
"jsdom": "^20.0.0",
|
||||
"jest": "^29.1.2",
|
||||
"jsdom": "^20.0.1",
|
||||
"lodash": "^4.17.21",
|
||||
"nyc": "^15.1.0",
|
||||
"playwright": "^1.26.1",
|
||||
"prettier": "^2.7.1",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"sinon": "^14.0.0",
|
||||
"stylelint": "^14.12.1",
|
||||
"sinon": "^14.0.1",
|
||||
"stylelint": "^14.13.0",
|
||||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-standard": "^28.0.0",
|
||||
"stylelint-prettier": "^2.0.0",
|
||||
"suncalc": "^1.9.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron": "^19.1.0"
|
||||
"electron": "^19.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
@ -123,7 +123,7 @@
|
||||
{
|
||||
"displayName": "e2e",
|
||||
"setupFilesAfterEnv": [
|
||||
"<rootDir>/tests/e2e/mock-console.js"
|
||||
"<rootDir>/tests/e2e/helpers/mock-console.js"
|
||||
],
|
||||
"testMatch": [
|
||||
"**/tests/e2e/**/*.[jt]s?(x)"
|
||||
@ -132,11 +132,8 @@
|
||||
"<rootDir>/js/"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/tests/e2e/modules/mocks",
|
||||
"<rootDir>/tests/e2e/modules/basic-auth.js",
|
||||
"<rootDir>/tests/e2e/modules/weather-functions.js",
|
||||
"<rootDir>/tests/e2e/global-setup.js",
|
||||
"<rootDir>/tests/e2e/mock-console.js"
|
||||
"<rootDir>/tests/e2e/helpers/",
|
||||
"<rootDir>/tests/e2e/mocks"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,33 +0,0 @@
|
||||
{
|
||||
"LOADING": "Loading …",
|
||||
|
||||
"TODAY": "Today",
|
||||
"TOMORROW": "Tomorrow",
|
||||
"DAYAFTERTOMORROW": "In 2 days",
|
||||
"RUNNING": "Ends in",
|
||||
"EMPTY": "No upcoming events.",
|
||||
|
||||
"WEEK": "Week {weekNumber}",
|
||||
|
||||
"N": "N",
|
||||
"NNE": "NNE",
|
||||
"NE": "NE",
|
||||
"ENE": "ENE",
|
||||
"E": "E",
|
||||
"ESE": "ESE",
|
||||
"SE": "SE",
|
||||
"SSE": "SSE",
|
||||
"S": "S",
|
||||
"SSW": "SSW",
|
||||
"SW": "SW",
|
||||
"WSW": "WSW",
|
||||
"W": "W",
|
||||
"WNW": "WNW",
|
||||
"NW": "NW",
|
||||
"NNW": "NNW",
|
||||
|
||||
"UPDATE_NOTIFICATION": "MagicMirror² update available.",
|
||||
"UPDATE_NOTIFICATION_MODULE": "Update available for MODULE_NAME module.",
|
||||
"UPDATE_INFO_SINGLE": "The current installation is COMMIT_COUNT commit behind on the BRANCH_NAME branch.",
|
||||
"UPDATE_INFO_MULTIPLE": "The current installation is COMMIT_COUNT commits behind on the BRANCH_NAME branch."
|
||||
}
|
@ -14,7 +14,7 @@ let config = {
|
||||
calendars: [
|
||||
{
|
||||
maximumNumberOfDays: 10000,
|
||||
url: "http://localhost:8080/tests/configs/data/calendar_test.ics",
|
||||
url: "http://localhost:8080/tests/mocks/calendar_test.ics",
|
||||
auth: {
|
||||
user: "MagicMirror",
|
||||
pass: "CallMeADog"
|
||||
|
@ -14,7 +14,7 @@ let config = {
|
||||
calendars: [
|
||||
{
|
||||
maximumNumberOfDays: 10000,
|
||||
url: "http://localhost:8080/tests/configs/data/calendar_test.ics",
|
||||
url: "http://localhost:8080/tests/mocks/calendar_test.ics",
|
||||
auth: {
|
||||
user: "MagicMirror",
|
||||
pass: "CallMeADog",
|
||||
|
@ -14,7 +14,7 @@ let config = {
|
||||
calendars: [
|
||||
{
|
||||
maximumNumberOfDays: 10000,
|
||||
url: "http://localhost:8010/tests/configs/data/calendar_test.ics",
|
||||
url: "http://localhost:8010/tests/mocks/calendar_test.ics",
|
||||
auth: {
|
||||
user: "MagicMirror",
|
||||
pass: "CallMeADog"
|
||||
|
@ -18,7 +18,7 @@ let config = {
|
||||
symbol: "birthday-cake",
|
||||
fullDaySymbol: "calendar-day",
|
||||
recurringSymbol: "undo",
|
||||
url: "http://localhost:8080/tests/configs/data/calendar_test_icons.ics"
|
||||
url: "http://localhost:8080/tests/mocks/calendar_test_icons.ics"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ let config = {
|
||||
calendars: [
|
||||
{
|
||||
maximumNumberOfDays: 10000,
|
||||
url: "http://localhost:8080/tests/configs/data/calendar_test.ics"
|
||||
url: "http://localhost:8080/tests/mocks/calendar_test.ics"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ let config = {
|
||||
calendars: [
|
||||
{
|
||||
maximumNumberOfDays: 10000,
|
||||
url: "http://localhost:8020/tests/configs/data/calendar_test.ics",
|
||||
url: "http://localhost:8020/tests/mocks/calendar_test.ics",
|
||||
auth: {
|
||||
user: "MagicMirror",
|
||||
pass: "StairwayToHeaven",
|
||||
|
@ -14,7 +14,7 @@ let config = {
|
||||
calendars: [
|
||||
{
|
||||
maximumNumberOfDays: 10000,
|
||||
url: "http://localhost:8080/tests/configs/data/calendar_test.ics",
|
||||
url: "http://localhost:8080/tests/mocks/calendar_test.ics",
|
||||
user: "MagicMirror",
|
||||
pass: "CallMeADog"
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ let config = {
|
||||
{
|
||||
maximumEntries: 6,
|
||||
maximumNumberOfDays: 3650,
|
||||
url: "http://localhost:8080/tests/configs/data/calendar_test_recurring.ics"
|
||||
url: "http://localhost:8080/tests/mocks/calendar_test_recurring.ics"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ let config = {
|
||||
module: "compliments",
|
||||
position: "middle_center",
|
||||
config: {
|
||||
remoteFile: "http://localhost:8080/tests/configs/data/compliments_test.json"
|
||||
remoteFile: "http://localhost:8080/tests/mocks/compliments_test.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -14,7 +14,7 @@ let config = {
|
||||
feeds: [
|
||||
{
|
||||
title: "Rodrigo Ramirez Blog",
|
||||
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
|
||||
url: "http://localhost:8080/tests/mocks/newsfeed_test.xml"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ let config = {
|
||||
feeds: [
|
||||
{
|
||||
title: "Rodrigo Ramirez Blog",
|
||||
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
|
||||
url: "http://localhost:8080/tests/mocks/newsfeed_test.xml"
|
||||
}
|
||||
],
|
||||
ignoreOldItems: true
|
||||
|
@ -13,7 +13,7 @@ let config = {
|
||||
feeds: [
|
||||
{
|
||||
title: "Rodrigo Ramirez Blog",
|
||||
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml"
|
||||
url: "http://localhost:8080/tests/mocks/newsfeed_test.xml"
|
||||
}
|
||||
],
|
||||
prohibitedWords: ["QPanel"],
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("App environment", () => {
|
||||
beforeAll(async () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("All font files from roboto.css should be downloadable", () => {
|
||||
const fontFiles = [];
|
@ -11,7 +11,7 @@ const basicAuth = auth({
|
||||
app.use(basicAuth);
|
||||
|
||||
// Set available directories
|
||||
const directories = ["/tests/configs"];
|
||||
const directories = ["/tests/configs", "/tests/mocks"];
|
||||
const rootPath = path.resolve(__dirname + "/../../../");
|
||||
|
||||
for (let directory of directories) {
|
@ -1,7 +1,7 @@
|
||||
const helpers = require("../global-setup");
|
||||
const helpers = require("./global-setup");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { generateWeather, generateWeatherForecast } = require("./mocks");
|
||||
const { generateWeather, generateWeatherForecast } = require("../../mocks/weather_test");
|
||||
|
||||
exports.getText = async (element, result) => {
|
||||
const elem = await helpers.waitForElement(element);
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("ipWhitelist directive configuration", () => {
|
||||
describe("Set ipWhitelist without access", () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
|
||||
describe("Alert module", () => {
|
||||
beforeAll(async () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const helpers = require("../global-setup");
|
||||
const serverBasicAuth = require("./basic-auth.js");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const serverBasicAuth = require("../helpers/basic-auth.js");
|
||||
|
||||
describe("Calendar module", () => {
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
|
||||
describe("Clock set to spanish language module", () => {
|
||||
afterAll(async () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const moment = require("moment");
|
||||
|
||||
describe("Clock module", () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
|
||||
describe("Compliments module", () => {
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
|
||||
describe("Test helloworld module", () => {
|
||||
afterAll(async () => {
|
||||
|
@ -1,4 +0,0 @@
|
||||
const generateWeather = require("./weather_current");
|
||||
const generateWeatherForecast = require("./weather_forecast");
|
||||
|
||||
module.exports = { generateWeather, generateWeatherForecast };
|
@ -1,64 +0,0 @@
|
||||
const _ = require("lodash");
|
||||
|
||||
/**
|
||||
* @param {object} extendedData extra data to add to the default mock data
|
||||
* @returns {string} mocked current weather data
|
||||
*/
|
||||
const generateWeather = (extendedData = {}) => {
|
||||
return JSON.stringify(
|
||||
_.merge(
|
||||
{},
|
||||
{
|
||||
coord: {
|
||||
lon: 11.58,
|
||||
lat: 48.14
|
||||
},
|
||||
weather: [
|
||||
{
|
||||
id: 615,
|
||||
main: "Snow",
|
||||
description: "light rain and snow",
|
||||
icon: "13d"
|
||||
},
|
||||
{
|
||||
id: 500,
|
||||
main: "Rain",
|
||||
description: "light rain",
|
||||
icon: "10d"
|
||||
}
|
||||
],
|
||||
base: "stations",
|
||||
main: {
|
||||
temp: 1.49,
|
||||
pressure: 1005,
|
||||
humidity: 93.7,
|
||||
temp_min: 1,
|
||||
temp_max: 2
|
||||
},
|
||||
visibility: 7000,
|
||||
wind: {
|
||||
speed: 11.8,
|
||||
deg: 250
|
||||
},
|
||||
clouds: {
|
||||
all: 75
|
||||
},
|
||||
dt: 1547387400,
|
||||
sys: {
|
||||
type: 1,
|
||||
id: 1267,
|
||||
message: 0.0031,
|
||||
country: "DE",
|
||||
sunrise: 1547362817,
|
||||
sunset: 1547394301
|
||||
},
|
||||
id: 2867714,
|
||||
name: "Munich",
|
||||
cod: 200
|
||||
},
|
||||
extendedData
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = generateWeather;
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
|
||||
describe("Newsfeed module", () => {
|
||||
afterAll(async () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
const moment = require("moment");
|
||||
const helpers = require("../global-setup");
|
||||
const weatherFunc = require("./weather-functions");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const weatherFunc = require("../helpers/weather-functions");
|
||||
|
||||
describe("Weather module", () => {
|
||||
afterAll(async () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const helpers = require("../global-setup");
|
||||
const weatherFunc = require("./weather-functions");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const weatherFunc = require("../helpers/weather-functions");
|
||||
|
||||
describe("Weather module: Weather Forecast", () => {
|
||||
afterAll(async () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("Display of modules", () => {
|
||||
beforeAll(async () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("Check configuration without modules", () => {
|
||||
beforeAll(async () => {
|
||||
@ -15,7 +15,7 @@ describe("Check configuration without modules", () => {
|
||||
expect(elem.textContent).toContain("MagicMirror²");
|
||||
});
|
||||
|
||||
it("Show the text Michael's website", async () => {
|
||||
it("Show the url of michael's website", async () => {
|
||||
const elem = await helpers.waitForElement("#module_5_helloworld .module-content");
|
||||
expect(elem).not.toBe(null);
|
||||
expect(elem.textContent).toContain("www.michaelteeuw.nl");
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("Position of modules", () => {
|
||||
beforeAll(async () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("port directive configuration", () => {
|
||||
describe("Set port 8090", () => {
|
@ -1,4 +1,4 @@
|
||||
const helpers = require("./global-setup");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("Vendors", () => {
|
||||
beforeAll(() => {
|
||||
|
@ -1,5 +1,66 @@
|
||||
const _ = require("lodash");
|
||||
|
||||
/**
|
||||
* @param {object} extendedData extra data to add to the default mock data
|
||||
* @returns {string} mocked current weather data
|
||||
*/
|
||||
const generateWeather = (extendedData = {}) => {
|
||||
return JSON.stringify(
|
||||
_.merge(
|
||||
{},
|
||||
{
|
||||
coord: {
|
||||
lon: 11.58,
|
||||
lat: 48.14
|
||||
},
|
||||
weather: [
|
||||
{
|
||||
id: 615,
|
||||
main: "Snow",
|
||||
description: "light rain and snow",
|
||||
icon: "13d"
|
||||
},
|
||||
{
|
||||
id: 500,
|
||||
main: "Rain",
|
||||
description: "light rain",
|
||||
icon: "10d"
|
||||
}
|
||||
],
|
||||
base: "stations",
|
||||
main: {
|
||||
temp: 1.49,
|
||||
pressure: 1005,
|
||||
humidity: 93.7,
|
||||
temp_min: 1,
|
||||
temp_max: 2
|
||||
},
|
||||
visibility: 7000,
|
||||
wind: {
|
||||
speed: 11.8,
|
||||
deg: 250
|
||||
},
|
||||
clouds: {
|
||||
all: 75
|
||||
},
|
||||
dt: 1547387400,
|
||||
sys: {
|
||||
type: 1,
|
||||
id: 1267,
|
||||
message: 0.0031,
|
||||
country: "DE",
|
||||
sunrise: 1547362817,
|
||||
sunset: 1547394301
|
||||
},
|
||||
id: 2867714,
|
||||
name: "Munich",
|
||||
cod: 200
|
||||
},
|
||||
extendedData
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {object} extendedData extra data to add to the default mock data
|
||||
* @returns {string} mocked forecast weather data
|
||||
@ -112,4 +173,4 @@ const generateWeatherForecast = (extendedData = {}) => {
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = generateWeatherForecast;
|
||||
module.exports = { generateWeather, generateWeatherForecast };
|
@ -14,7 +14,7 @@ describe("Translator", () => {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
next();
|
||||
});
|
||||
app.use("/translations", express.static(path.join(__dirname, "..", "..", "..", "tests", "configs", "data")));
|
||||
app.use("/translations", express.static(path.join(__dirname, "..", "..", "..", "tests", "mocks")));
|
||||
|
||||
server = app.listen(3000);
|
||||
|
||||
@ -160,10 +160,10 @@ describe("Translator", () => {
|
||||
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||
dom.window.onload = () => {
|
||||
const { Translator } = dom.window;
|
||||
const file = "TranslationTest.json";
|
||||
const file = "translation_test.json";
|
||||
|
||||
Translator.load(mmm, file, false, () => {
|
||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", file));
|
||||
expect(Translator.translations[mmm.name]).toEqual(json);
|
||||
done();
|
||||
});
|
||||
@ -174,10 +174,10 @@ describe("Translator", () => {
|
||||
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||
dom.window.onload = () => {
|
||||
const { Translator } = dom.window;
|
||||
const file = "TranslationTest.json";
|
||||
const file = "translation_test.json";
|
||||
|
||||
Translator.load(mmm, file, true, () => {
|
||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", file));
|
||||
expect(Translator.translationsFallback[mmm.name]).toEqual(json);
|
||||
done();
|
||||
});
|
||||
@ -188,7 +188,7 @@ describe("Translator", () => {
|
||||
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||
dom.window.onload = () => {
|
||||
const { Translator, XMLHttpRequest } = dom.window;
|
||||
const file = "TranslationTest.json";
|
||||
const file = "translation_test.json";
|
||||
|
||||
XMLHttpRequest.prototype.send = () => {
|
||||
throw "Shouldn't load files";
|
||||
@ -212,7 +212,7 @@ describe("Translator", () => {
|
||||
describe("loadCoreTranslations", () => {
|
||||
it("should load core translations and fallback", (done) => {
|
||||
const dom = new JSDOM(
|
||||
`<script>var translations = {en: "http://localhost:3000/translations/en.json"}; var Log = {log: () => {}};</script>\
|
||||
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
||||
{ runScripts: "dangerously", resources: "usable" }
|
||||
);
|
||||
@ -220,7 +220,7 @@ describe("Translator", () => {
|
||||
const { Translator } = dom.window;
|
||||
Translator.loadCoreTranslations("en");
|
||||
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", "translation_test.json"));
|
||||
setTimeout(() => {
|
||||
expect(Translator.coreTranslations).toEqual(en);
|
||||
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||
@ -231,7 +231,7 @@ describe("Translator", () => {
|
||||
|
||||
it("should load core fallback if language cannot be found", (done) => {
|
||||
const dom = new JSDOM(
|
||||
`<script>var translations = {en: "http://localhost:3000/translations/en.json"}; var Log = {log: () => {}};</script>\
|
||||
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
||||
{ runScripts: "dangerously", resources: "usable" }
|
||||
);
|
||||
@ -239,7 +239,7 @@ describe("Translator", () => {
|
||||
const { Translator } = dom.window;
|
||||
Translator.loadCoreTranslations("MISSINGLANG");
|
||||
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", "translation_test.json"));
|
||||
setTimeout(() => {
|
||||
expect(Translator.coreTranslations).toEqual({});
|
||||
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||
@ -252,7 +252,7 @@ describe("Translator", () => {
|
||||
describe("loadCoreTranslationsFallback", () => {
|
||||
it("should load core translations fallback", (done) => {
|
||||
const dom = new JSDOM(
|
||||
`<script>var translations = {en: "http://localhost:3000/translations/en.json"}; var Log = {log: () => {}};</script>\
|
||||
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
||||
{ runScripts: "dangerously", resources: "usable" }
|
||||
);
|
||||
@ -260,7 +260,7 @@ describe("Translator", () => {
|
||||
const { Translator } = dom.window;
|
||||
Translator.loadCoreTranslationsFallback();
|
||||
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "mocks", "translation_test.json"));
|
||||
setTimeout(() => {
|
||||
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||
done();
|
||||
|
Loading…
x
Reference in New Issue
Block a user