Mohd-FaiZ-Jr / Menu-Mate

Menu Mate is a convenient app designed for ITER hostel residents. It allows users to easily view the daily mess menu and check tomorrow's menu in advance, helping them plan their meals ahead of time. Developed by Mandeep Ray & Mohammad Faiz
https://menumate.netlify.app
MIT License
1 stars 11 forks source link

Fix the week calculation in tomorrow.js file. Consider covering the edge cases & testing. #5

Closed Mohd-FaiZ-Jr closed 5 days ago

Mohd-FaiZ-Jr commented 1 week ago

Issue: Fix Week Calculation in tomorrow.js

Problem: The week calculation logic in the tomorrow.js file under the scripts folder is producing incorrect results, especially in edge cases involving month transitions, leap years, and calculations for days around the end or beginning of a month. The current calculation might result in out-of-range values or incorrect week numbers.

Expected Behavior:

Actual Behavior:

Steps to Reproduce:

  1. Check the week calculation for the last day of a month, especially February.
  2. Compare results for leap years and non-leap years.
  3. Calculate tomorrow’s week number and check if it’s out of the expected range (0-3).

Expected Fix:

  1. Update the week calculation logic: Ensure that it consistently produces values in the range of 0 to 3, handling the rollover between months properly.
  2. Edge case handling:
    • Properly handle week transitions across the end of a month or year.
    • Ensure correct behavior for leap years.
  3. Testing:
    • Write unit tests to cover edge cases like:
      • Month-end transitions.
      • Leap year checks.
      • Calculations around the beginning of the month.
    • Test various dates to ensure correct week calculation for tomorrow.

Testing Plan:

  1. Unit Tests:
    • Include test cases for February 28th and 29th in leap years.
    • Test for month-end transitions (e.g., April 30th → May 1st).
    • Ensure week numbers are always between 0 and 3.
  2. Manual Tests:
    • Manually verify that tomorrow’s calculated week is correct for dates in different months, focusing on edge cases.

Priority: Medium