mapcomplete/test/testhooks.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
576 B
TypeScript
Raw Normal View History

2022-03-23 19:48:06 +01:00
import ScriptUtils from "../scripts/ScriptUtils"
import { Utils } from "../Utils"
import * as fakedom from "fake-dom"
import Locale from "../UI/i18n/Locale"
2023-02-03 04:48:32 +01:00
import { beforeEach } from "vitest"
2022-03-23 19:48:06 +01:00
2023-02-03 04:48:32 +01:00
beforeEach(async () => {
ScriptUtils.fixUtils()
Locale.language.setData("en")
2023-02-03 04:48:32 +01:00
if (fakedom === undefined || window === undefined) {
throw "FakeDom not initialized"
}
2023-02-03 04:48:32 +01:00
// Block internet access
Utils.externalDownloadFunction = async (url) => {
throw "Fetching " + url + "blocked in tests, use Utils.injectJsonDownloadForTests instead"
}
})