Rename tests to test; add a few tests

This commit is contained in:
Pieter Vander Vennet 2022-04-06 03:06:28 +02:00
parent df706d2f97
commit c3859d56c6
28 changed files with 33 additions and 5 deletions

24
test/testhooks.ts Normal file
View file

@ -0,0 +1,24 @@
import ScriptUtils from "../scripts/ScriptUtils";
import {Utils} from "../Utils";
export const mochaHooks = {
beforeEach(done) {
ScriptUtils.fixUtils();
// Block internet access
const realDownloadFunc = Utils.externalDownloadFunction;
Utils.externalDownloadFunction = async (url) => {
console.error("Fetching ", url, "blocked in tests, use Utils.injectJsonDownloadForTests")
const data = await realDownloadFunc(url)
console.log("\n\n ----------- \nBLOCKED DATA\n Utils.injectJsonDownloadForTests(\n" +
" ", JSON.stringify(url), ", \n",
" ", JSON.stringify(data), "\n )\n------------------\n\n")
throw new Error("Detected internet access for URL " + url + ", please inject it with Utils.injectJsonDownloadForTests")
}
done();
}
}