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

feat: add RelativeTimeFormat to Intl API #479

Conversation

sebastinez
Copy link
Contributor

Purpose (TL;DR) - mandatory

PR #474 has introduced a mock for the intl API, and this has introduced a regression for me, where I'm not able to call Intl.RelativeTimeFormat.

Background (Problem in detail)

The problem showed in some of my test cases, once I updated fake-timers, when trying to use Intl.RelativeTimeFormat I got the following error: Intl.RelativeTimeFormat is not a constructor

Solution

The solution I opted for is to assign RelativeTimeFormat to the mocked Intl API with.

ClockIntl.RelativeTimeFormat = NativeIntl.RelativeTimeFormat;

@sebastinez sebastinez force-pushed the sebastinez/add-relative-time-format-to-intl-api branch from f66cd19 to e640586 Compare August 22, 2023 13:15
By mocking the Intl API, the RelativeTimeFormat object was missing.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
@sebastinez sebastinez force-pushed the sebastinez/add-relative-time-format-to-intl-api branch from e640586 to f4469bf Compare August 22, 2023 13:21
@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (fc312b9) 96.47% compared to head (d09e29c) 96.48%.

❗ Current head d09e29c differs from pull request most recent head d4e78f2. Consider uploading reports for the commit d4e78f2 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #479      +/-   ##
==========================================
+ Coverage   96.47%   96.48%   +0.01%     
==========================================
  Files           2        2              
  Lines         680      682       +2     
==========================================
+ Hits          656      658       +2     
  Misses         24       24              
Flag Coverage Δ
unit 96.48% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/fake-timers-src.js 96.50% <100.00%> (+0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@fatso83 fatso83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like an OK interim solution.

src/fake-timers-src.js Outdated Show resolved Hide resolved
@sebastinez
Copy link
Contributor Author

Thanks for your reviews, what are the next steps?
Do you need me to sign something or can the PR get merged?

@sebastinez
Copy link
Contributor Author

Hey folks, this issue doesn't allow me to update fake-timers, since it would break my production.
Is there work be done on a better solution? Or is anything holding this PR up?

@sebastinez sebastinez closed this Oct 2, 2023
@sebastinez sebastinez reopened this Oct 2, 2023
@sebastinez
Copy link
Contributor Author

Didn't want to close the PR, just comment on it

@fatso83
Copy link
Contributor

fatso83 commented Oct 2, 2023

Seems like you just need to implement your own suggestion that iterates over the props 🤩

PS. Nothing should ever prevent you from upgrading. Try the Npm package 'patch-package' next time ✌️

@SimenB
Copy link
Member

SimenB commented Oct 2, 2023

Since there's no compilation step in this repo, you can also depend on your fork directly

@fatso83 fatso83 merged commit 9b2b474 into sinonjs:main Oct 5, 2023
8 checks passed
@piotrpalek
Copy link

piotrpalek commented Oct 18, 2023

I'm getting the same issue, but with Intl.NumberFormat :( I think sinon would need to pick up the whole Intl API to fix this

edit: ok.. now I see this is actually doing that, so I probably need to wait for a release to happen?

@fatso83
Copy link
Contributor

fatso83 commented Oct 19, 2023

New version is out.

@piotrpalek
Copy link

Thanks! Sorry for hijacking this PR 😅

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.

None yet

4 participants