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

fix: accept dates as params for Date methods #200

Merged
merged 62 commits into from
Mar 24, 2022

Conversation

pkuczynski
Copy link
Member

Fixes #198

@netlify
Copy link

netlify bot commented Jan 17, 2022

✔️ Deploy Preview for vigilant-wescoff-04e480 ready!

🔨 Explore the source changes: c03bd39

🔍 Inspect the deploy log: https://app.netlify.com/sites/vigilant-wescoff-04e480/deploys/61eb4621ab6f360008224c99

😎 Browse the preview: https://deploy-preview-200--vigilant-wescoff-04e480.netlify.app

@pkuczynski pkuczynski changed the title Accept dates as params for Date methods fix: accept dates as params for Date methods Jan 17, 2022
src/date.ts Outdated Show resolved Hide resolved
@Shinigami92 Shinigami92 added the p: 2-high Fix main branch label Jan 17, 2022
@Shinigami92
Copy link
Member

Due to this is a runtime change, I think we will do this in v6.1, because we try to focus on stability of the project itself first (CI, tests, docs etc)

@Shinigami92 Shinigami92 added this to the v6.1.0 milestone Jan 17, 2022
@pkuczynski
Copy link
Member Author

Due to this is a runtime change, I think we will do this in v6.1, because we try to focus on stability of the project itself first (CI, tests, docs etc)

I only got to this change, because my current code start failing after the upgrade. So this is not strictly a new feature, but restoring functionality working with previous version of faker.

@Shinigami92
Copy link
Member

Speaking about unit tests, could you add one?

@pkuczynski
Copy link
Member Author

Speaking about unit tests, could you add one?

Done. If you would be using jest I could do it.each to run the same tests with different examples. Without it, I just had to duplicate some tests

@pkuczynski
Copy link
Member Author

Btw. good that you asked about tests, as I discovered a bug, where original date was incorrectly mutated...

@LawrenceWooding
Copy link

I only got to this change, because my current code start failing after the upgrade. So this is not strictly a new feature, but restoring functionality working with previous version of faker.

I had a similar experience to @pkuczynski - attempting to replace the old faker-js package with this new one caused errors in previously working code. I am confident that most (if not all) of the Date functions used to support Date() fields. This is supported by the fact that in the documentation for Dates all of the functions take Date objects instead of strings (or at least the ones that were already documented).

Speaking of which the docs should probably be updated in this branch to better reflect the type definitions (e.g string | Date as opposed to Date). I am happy to do this if I get a spare moment.

Thank you @pkuczynski for looking into this issue, it is the primary roadblock between my organisation switching our frontend repository to the community faker-js package.

@LawrenceWooding
Copy link

I have made a pull request in @pkuczynski 's fork with the updated documentation. :)

@pkuczynski pkuczynski requested a review from a team as a code owner January 21, 2022 10:11
@pkuczynski
Copy link
Member Author

I have made a pull request in @pkuczynski 's fork with the updated documentation. :)

And I just merged it, thanks :)

@pkuczynski
Copy link
Member Author

@Shinigami92 Is there anything else you want me to do to get this PR accepted, merged and released?

src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
@Shinigami92
Copy link
Member

Done. If you would be using jest I could do it.each to run the same tests with different examples. Without it, I just had to duplicate some tests

You will love our next PR incoming :P
See #235

@pkuczynski
Copy link
Member Author

You will love our next PR incoming :P See #235

Citing their docs: "It's not recommended to migrate your current testing setups yet" ;) So I am not sure :) Is it jest based?

@Shinigami92
Copy link
Member

Citing their docs: "It's not recommended to migrate your current testing setups yet" ;) So I am not sure :) Is it jest based?

I'm one of Vite core members and in direct contact with Anthony Fu 🙂
Also yes, vitest is a somewhat swap-in-out replacement for jest. But written in more modern syntax and stripped out old legacy stuff. So it's jest but in fast ^^

@Shinigami92 Shinigami92 added c: bug Something isn't working p: 1-normal Nothing urgent labels Mar 15, 2022
@Shinigami92 Shinigami92 mentioned this pull request Mar 16, 2022
5 tasks
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
@pkuczynski
Copy link
Member Author

@Shinigami92 rebased and feedback applied. Let me know if anything is still missing?

@Shinigami92 Shinigami92 removed the needs rebase There is a merge conflict label Mar 23, 2022
src/date.ts Outdated Show resolved Hide resolved
src/date.ts Outdated Show resolved Hide resolved
@Shinigami92 Shinigami92 self-requested a review March 23, 2022 20:54
@pkuczynski
Copy link
Member Author

pkuczynski commented Mar 23, 2022

Added missing jsdoc to these new functions, after you converted them from arrow. Anything else @Shinigami92?

@Shinigami92
Copy link
Member

Anything else @Shinigami92?

I'm in bed now ^^
Will look tomorrow, thx for the JSDocs

@codecov
Copy link

codecov bot commented Mar 23, 2022

Codecov Report

Merging #200 (7632415) into main (825a8c8) will increase coverage by 0.00%.
The diff coverage is 100.00%.

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

@@           Coverage Diff           @@
##             main     #200   +/-   ##
=======================================
  Coverage   99.33%   99.33%           
=======================================
  Files        1923     1923           
  Lines      176857   176860    +3     
  Branches      908      913    +5     
=======================================
+ Hits       175687   175690    +3     
  Misses       1114     1114           
  Partials       56       56           
Impacted Files Coverage Δ
src/helpers.ts 99.12% <ø> (-0.01%) ⬇️
src/date.ts 100.00% <100.00%> (ø)
src/vendor/unique.ts 93.54% <0.00%> (-1.62%) ⬇️
src/vendor/user-agent.ts 98.87% <0.00%> (+0.56%) ⬆️

@ST-DDT ST-DDT requested a review from a team March 23, 2022 23:51
@Shinigami92 Shinigami92 enabled auto-merge (squash) March 24, 2022 07:25
@Shinigami92 Shinigami92 merged commit 91a1aab into faker-js:main Mar 24, 2022
@pkuczynski pkuczynski deleted the patch-1 branch March 24, 2022 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accept dates as params for Date methods