Skip to content

Add unit tests for quote utility functions #63

@aruneshwisdm

Description

@aruneshwisdm

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

  • Test calculateDepositAmount with percentage type (e.g., 10% of $1000 = $100)
  • Test calculateDepositAmount with fixed type (e.g., $200 fixed on $1000 total)
  • Test calculateDepositAmount when fixed deposit exceeds total (should cap at total)
  • Test formatQuoteCurrency with USD and other currencies (EUR, GBP, INR)
  • Test isQuoteExpired with past date (returns true), future date (returns false), and null (returns false)
  • All tests pass with pnpm vitest run apps/web/__tests__/lib/quotes/utils.test.ts

Getting started

Look at existing test files in apps/web/__tests__/lib/ for the testing patterns used in this project. The project uses Vitest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions