From ea9882256ea3f3d737f9104fca185d33cef0a80d Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 7 Mar 2025 17:24:52 +0900 Subject: [PATCH] Adding vitest for testing Currently implemented - FormatBytes - MathHelpers --- ReadMe.md | 34 +- build/test.html | 29 ++ package-lock.json | 873 +++++++++++++++++++++++++++++++++++++- package.json | 5 +- src/utils/FormatBytes.mjs | 28 +- src/utils/MathHelpers.mjs | 8 +- tests/FormatBytes.test.js | 81 ++++ tests/MathHelpers.test.js | 30 ++ 8 files changed, 1071 insertions(+), 17 deletions(-) create mode 100644 tests/FormatBytes.test.js create mode 100644 tests/MathHelpers.test.js diff --git a/ReadMe.md b/ReadMe.md index 69c2d40..de22e4c 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -95,24 +95,24 @@ Parse URL for looking up entries in the paramegter list ## Build -Build with the following commands, the output will be stored in "build/js/utilsAll.js" and "build/js/utilsAll.min.js" +Build with the following commands, the output will be stored in "build/js/output/utils.js" and "build/js/output/utils.min.js" For full not minified version ```sh -npm build utilsAll-build +npm build utils-build ``` For minified build (but keeps the function names as is) ```sh -npm build utilsAll-min-build +npm build utils-min-build ``` Or build both at the same time ```sh -npm build utilsAll-build-all +npm build utils-build-all ``` ## Develop @@ -126,5 +126,29 @@ npm install Run watch ```sh -npm run utilsAll-develop +npm run utils-develop ``` + +## Test + +A simple test script is located in "build/test.html" + +### General function tests + +vitest is used for all usage tests + +```sh +npx vitest +``` + +Currently covered: + +- FormatBytes +- MathHelpers + +TODO: + +- JavaScriptHelpers +- StringHelpers +- UniqIdGenerators +- UrlParser diff --git a/build/test.html b/build/test.html index 5059541..75b06c1 100644 --- a/build/test.html +++ b/build/test.html @@ -13,6 +13,29 @@