2019-12-17 19:24:37 +08:00
|
|
|
const en = require("../src/i18n/strings/en_EN");
|
2020-09-15 20:24:20 +08:00
|
|
|
const de = require("../src/i18n/strings/de_DE");
|
2022-01-05 18:37:28 +08:00
|
|
|
const lv = {
|
|
|
|
"Save": "Saglabāt",
|
2022-01-07 23:20:24 +08:00
|
|
|
"Uploading %(filename)s and %(count)s others|one": "Качване на %(filename)s и %(count)s друг",
|
2022-01-05 18:37:28 +08:00
|
|
|
};
|
2019-12-17 19:24:37 +08:00
|
|
|
|
2020-09-24 17:09:34 +08:00
|
|
|
// Mock the browser-request for the languageHandler tests to return
|
2022-01-05 18:37:28 +08:00
|
|
|
// Fake languages.json containing references to en_EN, de_DE and lv
|
2020-09-24 17:09:34 +08:00
|
|
|
// en_EN.json
|
|
|
|
// de_DE.json
|
2022-01-05 18:37:28 +08:00
|
|
|
// lv.json - mock version with few translations, used to test fallback translation
|
2019-12-17 19:24:37 +08:00
|
|
|
module.exports = jest.fn((opts, cb) => {
|
2020-01-16 22:01:15 +08:00
|
|
|
const url = opts.url || opts.uri;
|
|
|
|
if (url && url.endsWith("languages.json")) {
|
2019-12-17 19:24:37 +08:00
|
|
|
cb(undefined, {status: 200}, JSON.stringify({
|
|
|
|
"en": {
|
|
|
|
"fileName": "en_EN.json",
|
|
|
|
"label": "English",
|
|
|
|
},
|
2020-09-15 20:24:20 +08:00
|
|
|
"de": {
|
|
|
|
"fileName": "de_DE.json",
|
|
|
|
"label": "German",
|
|
|
|
},
|
2022-01-05 18:37:28 +08:00
|
|
|
"lv": {
|
|
|
|
"fileName": "lv.json",
|
|
|
|
"label": "Latvian"
|
|
|
|
}
|
2019-12-17 19:24:37 +08:00
|
|
|
}));
|
2020-01-16 22:01:15 +08:00
|
|
|
} else if (url && url.endsWith("en_EN.json")) {
|
2019-12-17 19:24:37 +08:00
|
|
|
cb(undefined, {status: 200}, JSON.stringify(en));
|
2020-09-15 20:24:20 +08:00
|
|
|
} else if (url && url.endsWith("de_DE.json")) {
|
|
|
|
cb(undefined, {status: 200}, JSON.stringify(de));
|
2022-01-05 18:37:28 +08:00
|
|
|
} else if (url && url.endsWith("lv.json")) {
|
|
|
|
cb(undefined, {status: 200}, JSON.stringify(lv));
|
2019-12-17 19:24:37 +08:00
|
|
|
} else {
|
2020-01-16 22:06:54 +08:00
|
|
|
cb(true, {status: 404}, "");
|
2019-12-17 19:24:37 +08:00
|
|
|
}
|
|
|
|
});
|