Cleanup test directory (#2937)

Moves files around and renames some so that the structure is cleaner and
more consistent
This commit is contained in:
Veeck 2022-10-07 19:16:37 +02:00 committed by GitHub
parent 21ae79b386
commit a328ce537f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 739 additions and 825 deletions

View File

@ -21,6 +21,7 @@ Special thanks to: @rejas, @sdetweil
### Updated ### Updated
- Cleaned up test directory
- Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests - Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests
- Updated da translation - Updated da translation
- Rework weather module - Rework weather module

View File

@ -73,7 +73,8 @@ function Server(config, callback) {
app.use("/js", express.static(__dirname)); 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) { for (const directory of directories) {
app.use(directory, express.static(path.resolve(global.root_path + directory))); app.use(directory, express.static(path.resolve(global.root_path + directory)));
} }

1279
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -50,27 +50,27 @@
"homepage": "https://magicmirror.builders", "homepage": "https://magicmirror.builders",
"devDependencies": { "devDependencies": {
"eslint-config-prettier": "^8.5.0", "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-jsdoc": "^39.3.6",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"express-basic-auth": "^1.2.1", "express-basic-auth": "^1.2.1",
"husky": "^8.0.1", "husky": "^8.0.1",
"jest": "^29.0.3", "jest": "^29.1.2",
"jsdom": "^20.0.0", "jsdom": "^20.0.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"playwright": "^1.26.1", "playwright": "^1.26.1",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"pretty-quick": "^3.1.3", "pretty-quick": "^3.1.3",
"sinon": "^14.0.0", "sinon": "^14.0.1",
"stylelint": "^14.12.1", "stylelint": "^14.13.0",
"stylelint-config-prettier": "^9.0.3", "stylelint-config-prettier": "^9.0.3",
"stylelint-config-standard": "^28.0.0", "stylelint-config-standard": "^28.0.0",
"stylelint-prettier": "^2.0.0", "stylelint-prettier": "^2.0.0",
"suncalc": "^1.9.0" "suncalc": "^1.9.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"electron": "^19.1.0" "electron": "^19.1.2"
}, },
"dependencies": { "dependencies": {
"colors": "^1.4.0", "colors": "^1.4.0",
@ -123,7 +123,7 @@
{ {
"displayName": "e2e", "displayName": "e2e",
"setupFilesAfterEnv": [ "setupFilesAfterEnv": [
"<rootDir>/tests/e2e/mock-console.js" "<rootDir>/tests/e2e/helpers/mock-console.js"
], ],
"testMatch": [ "testMatch": [
"**/tests/e2e/**/*.[jt]s?(x)" "**/tests/e2e/**/*.[jt]s?(x)"
@ -132,11 +132,8 @@
"<rootDir>/js/" "<rootDir>/js/"
], ],
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"<rootDir>/tests/e2e/modules/mocks", "<rootDir>/tests/e2e/helpers/",
"<rootDir>/tests/e2e/modules/basic-auth.js", "<rootDir>/tests/e2e/mocks"
"<rootDir>/tests/e2e/modules/weather-functions.js",
"<rootDir>/tests/e2e/global-setup.js",
"<rootDir>/tests/e2e/mock-console.js"
] ]
} }
] ]

View File

@ -1,33 +0,0 @@
{
"LOADING": "Loading &hellip;",
"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."
}

View File

@ -14,7 +14,7 @@ let config = {
calendars: [ calendars: [
{ {
maximumNumberOfDays: 10000, maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics", url: "http://localhost:8080/tests/mocks/calendar_test.ics",
auth: { auth: {
user: "MagicMirror", user: "MagicMirror",
pass: "CallMeADog" pass: "CallMeADog"

View File

@ -14,7 +14,7 @@ let config = {
calendars: [ calendars: [
{ {
maximumNumberOfDays: 10000, maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics", url: "http://localhost:8080/tests/mocks/calendar_test.ics",
auth: { auth: {
user: "MagicMirror", user: "MagicMirror",
pass: "CallMeADog", pass: "CallMeADog",

View File

@ -14,7 +14,7 @@ let config = {
calendars: [ calendars: [
{ {
maximumNumberOfDays: 10000, maximumNumberOfDays: 10000,
url: "http://localhost:8010/tests/configs/data/calendar_test.ics", url: "http://localhost:8010/tests/mocks/calendar_test.ics",
auth: { auth: {
user: "MagicMirror", user: "MagicMirror",
pass: "CallMeADog" pass: "CallMeADog"

View File

@ -18,7 +18,7 @@ let config = {
symbol: "birthday-cake", symbol: "birthday-cake",
fullDaySymbol: "calendar-day", fullDaySymbol: "calendar-day",
recurringSymbol: "undo", recurringSymbol: "undo",
url: "http://localhost:8080/tests/configs/data/calendar_test_icons.ics" url: "http://localhost:8080/tests/mocks/calendar_test_icons.ics"
} }
] ]
} }

View File

@ -14,7 +14,7 @@ let config = {
calendars: [ calendars: [
{ {
maximumNumberOfDays: 10000, maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics" url: "http://localhost:8080/tests/mocks/calendar_test.ics"
} }
] ]
} }

View File

@ -16,7 +16,7 @@ let config = {
calendars: [ calendars: [
{ {
maximumNumberOfDays: 10000, maximumNumberOfDays: 10000,
url: "http://localhost:8020/tests/configs/data/calendar_test.ics", url: "http://localhost:8020/tests/mocks/calendar_test.ics",
auth: { auth: {
user: "MagicMirror", user: "MagicMirror",
pass: "StairwayToHeaven", pass: "StairwayToHeaven",

View File

@ -14,7 +14,7 @@ let config = {
calendars: [ calendars: [
{ {
maximumNumberOfDays: 10000, maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics", url: "http://localhost:8080/tests/mocks/calendar_test.ics",
user: "MagicMirror", user: "MagicMirror",
pass: "CallMeADog" pass: "CallMeADog"
} }

View File

@ -15,7 +15,7 @@ let config = {
{ {
maximumEntries: 6, maximumEntries: 6,
maximumNumberOfDays: 3650, maximumNumberOfDays: 3650,
url: "http://localhost:8080/tests/configs/data/calendar_test_recurring.ics" url: "http://localhost:8080/tests/mocks/calendar_test_recurring.ics"
} }
] ]
} }

View File

@ -9,7 +9,7 @@ let config = {
module: "compliments", module: "compliments",
position: "middle_center", position: "middle_center",
config: { config: {
remoteFile: "http://localhost:8080/tests/configs/data/compliments_test.json" remoteFile: "http://localhost:8080/tests/mocks/compliments_test.json"
} }
} }
] ]

View File

@ -14,7 +14,7 @@ let config = {
feeds: [ feeds: [
{ {
title: "Rodrigo Ramirez Blog", title: "Rodrigo Ramirez Blog",
url: "http://localhost:8080/tests/configs/data/feed_test_rodrigoramirez.xml" url: "http://localhost:8080/tests/mocks/newsfeed_test.xml"
} }
] ]
} }

View File

@ -13,7 +13,7 @@ let config = {
feeds: [ feeds: [
{ {
title: "Rodrigo Ramirez Blog", 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 ignoreOldItems: true

View File

@ -13,7 +13,7 @@ let config = {
feeds: [ feeds: [
{ {
title: "Rodrigo Ramirez Blog", 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"], prohibitedWords: ["QPanel"],

View File

@ -1,4 +1,4 @@
const helpers = require("./global-setup"); const helpers = require("./helpers/global-setup");
describe("App environment", () => { describe("App environment", () => {
beforeAll(async () => { beforeAll(async () => {

View File

@ -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", () => { describe("All font files from roboto.css should be downloadable", () => {
const fontFiles = []; const fontFiles = [];

View File

@ -11,7 +11,7 @@ const basicAuth = auth({
app.use(basicAuth); app.use(basicAuth);
// Set available directories // Set available directories
const directories = ["/tests/configs"]; const directories = ["/tests/configs", "/tests/mocks"];
const rootPath = path.resolve(__dirname + "/../../../"); const rootPath = path.resolve(__dirname + "/../../../");
for (let directory of directories) { for (let directory of directories) {

View File

@ -1,7 +1,7 @@
const helpers = require("../global-setup"); const helpers = require("./global-setup");
const path = require("path"); const path = require("path");
const fs = require("fs"); const fs = require("fs");
const { generateWeather, generateWeatherForecast } = require("./mocks"); const { generateWeather, generateWeatherForecast } = require("../../mocks/weather_test");
exports.getText = async (element, result) => { exports.getText = async (element, result) => {
const elem = await helpers.waitForElement(element); const elem = await helpers.waitForElement(element);

View File

@ -1,4 +1,4 @@
const helpers = require("./global-setup"); const helpers = require("./helpers/global-setup");
describe("ipWhitelist directive configuration", () => { describe("ipWhitelist directive configuration", () => {
describe("Set ipWhitelist without access", () => { describe("Set ipWhitelist without access", () => {

View File

@ -1,4 +1,4 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
describe("Alert module", () => { describe("Alert module", () => {
beforeAll(async () => { beforeAll(async () => {

View File

@ -1,5 +1,5 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
const serverBasicAuth = require("./basic-auth.js"); const serverBasicAuth = require("../helpers/basic-auth.js");
describe("Calendar module", () => { describe("Calendar module", () => {
/** /**

View File

@ -1,4 +1,4 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
describe("Clock set to spanish language module", () => { describe("Clock set to spanish language module", () => {
afterAll(async () => { afterAll(async () => {

View File

@ -1,4 +1,4 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
const moment = require("moment"); const moment = require("moment");
describe("Clock module", () => { describe("Clock module", () => {

View File

@ -1,4 +1,4 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
describe("Compliments module", () => { describe("Compliments module", () => {
/** /**

View File

@ -1,4 +1,4 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
describe("Test helloworld module", () => { describe("Test helloworld module", () => {
afterAll(async () => { afterAll(async () => {

View File

@ -1,4 +0,0 @@
const generateWeather = require("./weather_current");
const generateWeatherForecast = require("./weather_forecast");
module.exports = { generateWeather, generateWeatherForecast };

View File

@ -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;

View File

@ -1,4 +1,4 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
describe("Newsfeed module", () => { describe("Newsfeed module", () => {
afterAll(async () => { afterAll(async () => {

View File

@ -1,6 +1,6 @@
const moment = require("moment"); const moment = require("moment");
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
const weatherFunc = require("./weather-functions"); const weatherFunc = require("../helpers/weather-functions");
describe("Weather module", () => { describe("Weather module", () => {
afterAll(async () => { afterAll(async () => {

View File

@ -1,5 +1,5 @@
const helpers = require("../global-setup"); const helpers = require("../helpers/global-setup");
const weatherFunc = require("./weather-functions"); const weatherFunc = require("../helpers/weather-functions");
describe("Weather module: Weather Forecast", () => { describe("Weather module: Weather Forecast", () => {
afterAll(async () => { afterAll(async () => {

View File

@ -1,4 +1,4 @@
const helpers = require("./global-setup"); const helpers = require("./helpers/global-setup");
describe("Display of modules", () => { describe("Display of modules", () => {
beforeAll(async () => { beforeAll(async () => {

View File

@ -1,4 +1,4 @@
const helpers = require("./global-setup"); const helpers = require("./helpers/global-setup");
describe("Check configuration without modules", () => { describe("Check configuration without modules", () => {
beforeAll(async () => { beforeAll(async () => {
@ -15,7 +15,7 @@ describe("Check configuration without modules", () => {
expect(elem.textContent).toContain("MagicMirror²"); 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"); const elem = await helpers.waitForElement("#module_5_helloworld .module-content");
expect(elem).not.toBe(null); expect(elem).not.toBe(null);
expect(elem.textContent).toContain("www.michaelteeuw.nl"); expect(elem.textContent).toContain("www.michaelteeuw.nl");

View File

@ -1,4 +1,4 @@
const helpers = require("./global-setup"); const helpers = require("./helpers/global-setup");
describe("Position of modules", () => { describe("Position of modules", () => {
beforeAll(async () => { beforeAll(async () => {

View File

@ -1,4 +1,4 @@
const helpers = require("./global-setup"); const helpers = require("./helpers/global-setup");
describe("port directive configuration", () => { describe("port directive configuration", () => {
describe("Set port 8090", () => { describe("Set port 8090", () => {

View File

@ -1,4 +1,4 @@
const helpers = require("./global-setup"); const helpers = require("./helpers/global-setup");
describe("Vendors", () => { describe("Vendors", () => {
beforeAll(() => { beforeAll(() => {

View File

@ -1,5 +1,66 @@
const _ = require("lodash"); 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 * @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked forecast weather data * @returns {string} mocked forecast weather data
@ -112,4 +173,4 @@ const generateWeatherForecast = (extendedData = {}) => {
); );
}; };
module.exports = generateWeatherForecast; module.exports = { generateWeather, generateWeatherForecast };

View File

@ -14,7 +14,7 @@ describe("Translator", () => {
res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Origin", "*");
next(); 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); 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" }); 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 = () => { dom.window.onload = () => {
const { Translator } = dom.window; const { Translator } = dom.window;
const file = "TranslationTest.json"; const file = "translation_test.json";
Translator.load(mmm, file, false, () => { 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); expect(Translator.translations[mmm.name]).toEqual(json);
done(); 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" }); 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 = () => { dom.window.onload = () => {
const { Translator } = dom.window; const { Translator } = dom.window;
const file = "TranslationTest.json"; const file = "translation_test.json";
Translator.load(mmm, file, true, () => { 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); expect(Translator.translationsFallback[mmm.name]).toEqual(json);
done(); 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" }); 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 = () => { dom.window.onload = () => {
const { Translator, XMLHttpRequest } = dom.window; const { Translator, XMLHttpRequest } = dom.window;
const file = "TranslationTest.json"; const file = "translation_test.json";
XMLHttpRequest.prototype.send = () => { XMLHttpRequest.prototype.send = () => {
throw "Shouldn't load files"; throw "Shouldn't load files";
@ -212,7 +212,7 @@ describe("Translator", () => {
describe("loadCoreTranslations", () => { describe("loadCoreTranslations", () => {
it("should load core translations and fallback", (done) => { it("should load core translations and fallback", (done) => {
const dom = new JSDOM( 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")}">`, <script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" } { runScripts: "dangerously", resources: "usable" }
); );
@ -220,7 +220,7 @@ describe("Translator", () => {
const { Translator } = dom.window; const { Translator } = dom.window;
Translator.loadCoreTranslations("en"); 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(() => { setTimeout(() => {
expect(Translator.coreTranslations).toEqual(en); expect(Translator.coreTranslations).toEqual(en);
expect(Translator.coreTranslationsFallback).toEqual(en); expect(Translator.coreTranslationsFallback).toEqual(en);
@ -231,7 +231,7 @@ describe("Translator", () => {
it("should load core fallback if language cannot be found", (done) => { it("should load core fallback if language cannot be found", (done) => {
const dom = new JSDOM( 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")}">`, <script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" } { runScripts: "dangerously", resources: "usable" }
); );
@ -239,7 +239,7 @@ describe("Translator", () => {
const { Translator } = dom.window; const { Translator } = dom.window;
Translator.loadCoreTranslations("MISSINGLANG"); 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(() => { setTimeout(() => {
expect(Translator.coreTranslations).toEqual({}); expect(Translator.coreTranslations).toEqual({});
expect(Translator.coreTranslationsFallback).toEqual(en); expect(Translator.coreTranslationsFallback).toEqual(en);
@ -252,7 +252,7 @@ describe("Translator", () => {
describe("loadCoreTranslationsFallback", () => { describe("loadCoreTranslationsFallback", () => {
it("should load core translations fallback", (done) => { it("should load core translations fallback", (done) => {
const dom = new JSDOM( 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")}">`, <script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" } { runScripts: "dangerously", resources: "usable" }
); );
@ -260,7 +260,7 @@ describe("Translator", () => {
const { Translator } = dom.window; const { Translator } = dom.window;
Translator.loadCoreTranslationsFallback(); 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(() => { setTimeout(() => {
expect(Translator.coreTranslationsFallback).toEqual(en); expect(Translator.coreTranslationsFallback).toEqual(en);
done(); done();