Summary
The utility functions in apps/web/lib/quotes/utils.ts have no unit tests. These are pure functions with clear inputs/outputs, making them ideal for a first contribution.
Functions to test
calculateDepositAmount(total, depositType, depositValue) — calculates deposit as percentage or fixed amount
formatQuoteCurrency(amount, currency) — formats a number as currency with a space after the symbol
isQuoteExpired(expirationDate) — checks if a quote's expiration date has passed
Files
- Source:
apps/web/lib/quotes/utils.ts
- Test file to create:
apps/web/__tests__/lib/quotes/utils.test.ts
Acceptance criteria
Getting started
Look at existing test files in apps/web/__tests__/lib/ for the testing patterns used in this project. The project uses Vitest.
Summary
The utility functions in
apps/web/lib/quotes/utils.tshave no unit tests. These are pure functions with clear inputs/outputs, making them ideal for a first contribution.Functions to test
calculateDepositAmount(total, depositType, depositValue)— calculates deposit as percentage or fixed amountformatQuoteCurrency(amount, currency)— formats a number as currency with a space after the symbolisQuoteExpired(expirationDate)— checks if a quote's expiration date has passedFiles
apps/web/lib/quotes/utils.tsapps/web/__tests__/lib/quotes/utils.test.tsAcceptance criteria
calculateDepositAmountwith percentage type (e.g., 10% of $1000 = $100)calculateDepositAmountwith fixed type (e.g., $200 fixed on $1000 total)calculateDepositAmountwhen fixed deposit exceeds total (should cap at total)formatQuoteCurrencywith USD and other currencies (EUR, GBP, INR)isQuoteExpiredwith past date (returns true), future date (returns false), and null (returns false)pnpm vitest run apps/web/__tests__/lib/quotes/utils.test.tsGetting started
Look at existing test files in
apps/web/__tests__/lib/for the testing patterns used in this project. The project uses Vitest.