From f2c6c5a2e3453a65effd92360a1dc289e9659c2f Mon Sep 17 00:00:00 2001 From: sebranchett Date: Wed, 16 Jul 2025 17:31:17 +0200 Subject: [PATCH] fix the tests. Ugly, but it works --- package.json | 2 +- tests/testGetImage.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/testGetImage.js diff --git a/package.json b/package.json index f7fef97..43c5835 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A project for generating and testing circuits", "main": "src/gui/main.js", "scripts": { - "test": "mocha --require tests/setup.js 'tests/**/*.test.js'", + "test": "cp src/gui/renderers/GetImage.js src/gui/renderers/origGetImage.js && cp tests/testGetImage.js src/gui/renderers/GetImage.js && mocha --require tests/setup.js 'tests/**/*.test.js' && mv src/gui/renderers/origGetImage.js src/gui/renderers/GetImage.js", "bundle": "esbuild src/gui/main.js --minify --format=esm --bundle --outdir=dist/static --asset-names=assets/[name] --loader:.png=dataurl", "copy": "cp -r assets dist/assets && cp src/gui/gui.html dist/", "build": "npm run bundle && npm run copy", diff --git a/tests/testGetImage.js b/tests/testGetImage.js new file mode 100644 index 0000000..3fa84ed --- /dev/null +++ b/tests/testGetImage.js @@ -0,0 +1,7 @@ +export function GetImage(type) { + // Concatenate '../../../assets/' and type + const imagePath = `../../../assets/${type}`; + + // Return the full URL to the image + return new URL(imagePath, import.meta.url).href; +}