Improve fetch mock setup (#9511)

- Move from language to mock setup file
- Add mock rule for stub image requests
This commit is contained in:
Michael Weimann 2022-10-26 16:54:45 +02:00 committed by GitHub
parent 0f1738b098
commit 7692533e18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -20,10 +20,6 @@ import * as languageHandler from "../../src/languageHandler";
import en from "../../src/i18n/strings/en_EN.json";
import de from "../../src/i18n/strings/de_DE.json";
fetchMock.config.overwriteRoutes = false;
fetchMock.catch("");
window.fetch = fetchMock.sandbox();
const lv = {
"Save": "Saglabāt",
"Uploading %(filename)s and %(count)s others|one": "Качване на %(filename)s и %(count)s друг",

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import fetchMock from "fetch-mock-jest";
import { TextDecoder, TextEncoder } from "util";
// jest 27 removes setImmediate from jsdom
@ -54,3 +55,9 @@ global.TextDecoder = TextDecoder;
// prevent errors whenever a component tries to manually scroll.
window.HTMLElement.prototype.scrollIntoView = jest.fn();
// set up fetch API mock
fetchMock.config.overwriteRoutes = false;
fetchMock.catch("");
fetchMock.get("/image-file-stub", "image file stub");
window.fetch = fetchMock.sandbox();