2019-12-17 14:24:37 +03:00
|
|
|
const en = require("../src/i18n/strings/en_EN");
|
2020-09-15 15:24:20 +03:00
|
|
|
const de = require("../src/i18n/strings/de_DE");
|
2019-12-17 14:24:37 +03:00
|
|
|
|
2020-09-24 12:09:34 +03:00
|
|
|
// Mock the browser-request for the languageHandler tests to return
|
|
|
|
// Fake languages.json containing references to en_EN and de_DE
|
|
|
|
// en_EN.json
|
|
|
|
// de_DE.json
|
2019-12-17 14:24:37 +03:00
|
|
|
module.exports = jest.fn((opts, cb) => {
|
2020-01-16 17:01:15 +03:00
|
|
|
const url = opts.url || opts.uri;
|
|
|
|
if (url && url.endsWith("languages.json")) {
|
2019-12-17 14:24:37 +03:00
|
|
|
cb(undefined, {status: 200}, JSON.stringify({
|
|
|
|
"en": {
|
|
|
|
"fileName": "en_EN.json",
|
|
|
|
"label": "English",
|
|
|
|
},
|
2020-09-15 15:24:20 +03:00
|
|
|
"de": {
|
|
|
|
"fileName": "de_DE.json",
|
|
|
|
"label": "German",
|
|
|
|
},
|
2019-12-17 14:24:37 +03:00
|
|
|
}));
|
2020-01-16 17:01:15 +03:00
|
|
|
} else if (url && url.endsWith("en_EN.json")) {
|
2019-12-17 14:24:37 +03:00
|
|
|
cb(undefined, {status: 200}, JSON.stringify(en));
|
2020-09-15 15:24:20 +03:00
|
|
|
} else if (url && url.endsWith("de_DE.json")) {
|
|
|
|
cb(undefined, {status: 200}, JSON.stringify(de));
|
2019-12-17 14:24:37 +03:00
|
|
|
} else {
|
2020-01-16 17:06:54 +03:00
|
|
|
cb(true, {status: 404}, "");
|
2019-12-17 14:24:37 +03:00
|
|
|
}
|
|
|
|
});
|