Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unit tests in src/utils/date.test.js fail in early January #2090

Closed
yurishkuro opened this issue Jan 5, 2024 · 0 comments · Fixed by #2091
Closed

[Bug]: Unit tests in src/utils/date.test.js fail in early January #2090

yurishkuro opened this issue Jan 5, 2024 · 0 comments · Fixed by #2091
Labels

Comments

@yurishkuro
Copy link
Member

yurishkuro commented Jan 5, 2024

What happened?

Tests started failing.

Summary of all failing tests
 FAIL  src/utils/date.test.js
  ● formatRelativeDate › Displays MM-DAY (Same month different date)

    expect(received).toBe(expected) // Object.is equality

    Expected: "Dec 29"
    Received: "Dec 29, 2023"

      226 |       day: 'numeric',
      227 |     });
    > 228 |     expect(formatRelativeDate(input)).toBe(output);
          |                                       ^
      229 |   });
      230 | });
      231 |

      at Object.toBe (src/utils/date.test.js:228:39)

The reason is because this test tries to render today-4 and expects MM-DAY, but when in the first 4 days of January this renders the date with the previous year.

@yurishkuro yurishkuro added the bug label Jan 5, 2024
yurishkuro added a commit that referenced this issue Jan 5, 2024
## Which problem is this PR solving?
- Resolves #2090

## Description of the changes
- Mock the current date to a fix value to avoid time of year variations
in behavior

---------

Signed-off-by: Yuri Shkuro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant