From 661d5f48404a948eb72963900ef84b2eae1bc029 Mon Sep 17 00:00:00 2001 From: jableader Date: Sat, 18 Oct 2025 13:17:39 +1100 Subject: [PATCH] Refactor #7 --- package.json | 5 ++++- refactor-strategy.md | 10 +++++++--- tests/mealMapper.test.js | 27 ++++++++++++++++++++++++++ tests/shoppingListMapper.test.js | 33 ++++++++++++++++++++++++++++++++ tests/units.test.js | 27 ++++++++++++++++++++++++++ vitest.config.js | 16 ++++++++++++++++ 6 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 tests/mealMapper.test.js create mode 100644 tests/shoppingListMapper.test.js create mode 100644 tests/units.test.js create mode 100644 vitest.config.js diff --git a/package.json b/package.json index 55ae4f6..90a8b49 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,10 @@ "build": "vue-cli-service build", "lint": "vue-cli-service lint", "format": "prettier --write .", - "prepare": "husky install" + "prepare": "husky install", + "test": "vitest run", + "test:watch": "vitest", + "test:coverage": "vitest run --coverage" }, "dependencies": { "core-js": "^3.8.3", diff --git a/refactor-strategy.md b/refactor-strategy.md index c8d0090..8037fbe 100644 --- a/refactor-strategy.md +++ b/refactor-strategy.md @@ -55,9 +55,11 @@ Outcome: Stable formatting and consistent linting across contributors. ### Phase 5 — Tests (Targeted) -- [ ] Add a unit test runner (Vitest or Jest) -- [ ] Test mappers (dates/reference wiring) -- [ ] Test `units.js` conversions and totals +- [x] Add a unit test runner (Vitest) +- [x] Test mappers (dates/reference wiring) + - Added tests: `tests/mealMapper.test.js`, `tests/shoppingListMapper.test.js` +- [x] Test `units.js` conversions and totals + - Added tests: `tests/units.test.js` Outcome: Confidence in refactors and easier onboarding. @@ -80,3 +82,5 @@ Outcome: Confidence in refactors and easier onboarding. - Added `composables/useMeals.js`; migrated meal pages to composable and `