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

test(test): fix inconsistent timezone in date tests #40

Merged
merged 1 commit into from
May 11, 2024

Conversation

dabbott
Copy link
Contributor

@dabbott dabbott commented May 11, 2024

I noticed a few date-related tests weren't passing for me locally:

 FAIL  test/unsafe.test.ts
  ● change Date instance

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

    Expected: 946684800000
    Received: 946627200000

      577 |   expect(data.foo).toBe(state.foo);
      578 |   expect(data.date).toBe(state.date);
    > 579 |   expect(state.date.getTime()).toBe(946684800000);
          |                                ^
      580 | });
      581 |

      at Object.<anonymous> (test/unsafe.test.ts:579:32)

I believe this is because setFullYear applies the system's local time zone automatically. Using setMilliseconds should avoid this issue. With this change, all tests pass locally and presumably shouldn't impact the github actions test runner.

I love the library and I'm excited to start poking around the code more!

@unadlib unadlib merged commit 6bd4c11 into unadlib:main May 11, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants