Support uri option in request mock

This commit is contained in:
J. Ryan Stinnett 2020-01-16 14:01:15 +00:00
parent 0dfd58c784
commit dab31d724d

View file

@ -1,14 +1,15 @@
const en = require("../src/i18n/strings/en_EN"); const en = require("../src/i18n/strings/en_EN");
module.exports = jest.fn((opts, cb) => { module.exports = jest.fn((opts, cb) => {
if (opts.url.endsWith("languages.json")) { const url = opts.url || opts.uri;
if (url && url.endsWith("languages.json")) {
cb(undefined, {status: 200}, JSON.stringify({ cb(undefined, {status: 200}, JSON.stringify({
"en": { "en": {
"fileName": "en_EN.json", "fileName": "en_EN.json",
"label": "English", "label": "English",
}, },
})); }));
} else if (opts.url.endsWith("en_EN.json")) { } else if (url && url.endsWith("en_EN.json")) {
cb(undefined, {status: 200}, JSON.stringify(en)); cb(undefined, {status: 200}, JSON.stringify(en));
} else { } else {
cb(undefined, {status: 404}, ""); cb(undefined, {status: 404}, "");