faker icon indicating copy to clipboard operation
faker copied to clipboard

feat(number): add romanNumeral method

Open AmaanRS opened this issue 1 year ago β€’ 13 comments
trafficstars

This is a draft, please check this

AmaanRS avatar Aug 22 '24 06:08 AmaanRS

Deploy Preview for fakerjs ready!

Name Link
Latest commit 6e04bef8b03b370c1bcb67489fd3b029bd745722
Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/6723548764693d0008135ec3
Deploy Preview https://deploy-preview-3070.fakerjs.dev
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Aug 22 '24 06:08 netlify[bot]

In this commit 7abd2c7b262a31d5a699a17f99dcfab9d4650afd i created a new function intToRomanNumeral so where should i place it ?

AmaanRS avatar Aug 28 '24 14:08 AmaanRS

How should i write random seeded test for "it('should generate a Roman numeral between 1 and 10')" ? Since i don't what answer will be.

AmaanRS avatar Aug 29 '24 13:08 AmaanRS

And there will be no value range test ?

AmaanRS avatar Aug 29 '24 13:08 AmaanRS

There's a few ways you could do it. For 1 to 10 you could check if it's any of the values from I to X by listing all 10 values.

You could also check it only contains suitable characters.

Also add tests that check hitting each of the errors and check appropriate error is thrown.

matthewmayer avatar Aug 29 '24 14:08 matthewmayer

Please let me know if there are any changes with the code and test if not i will run preflight and then commit the code

AmaanRS avatar Aug 30 '24 05:08 AmaanRS

Ideally please run preflight after every change. This will help catch any minor syntax errors etc so the reviewers can focus on the logic of your code rather than nitpicking.

matthewmayer avatar Aug 30 '24 12:08 matthewmayer

I ran into an error during preflight FakerApiDocsProcessingError: Failed to process parameter options at src/modules/number/index.ts:468:16 : Expected exactly one element for jsdocs, got 0

AmaanRS avatar Sep 01 '24 13:09 AmaanRS

Expected exactly one element for jsdocs

its not a very intuitive error message but i think the problem is that you're missing a @since JSDoc tag

add

@since 9.1.0 at the bottom of the JSDoc as this likely wont be in the 9.0.0 release.

matthewmayer avatar Sep 01 '24 14:09 matthewmayer

I ran into an error during preflight FakerApiDocsProcessingError: Failed to process parameter options at src/modules/number/index.ts:468:16 : Expected exactly one element for jsdocs, got 0

The error is not caused by @since. It is caused by the options.min/max parameter not having jsdocs. I'll improve the error message.

FakerApiDocsProcessingError: Failed to process property 'options.min' at src/modules/number/index.ts:467:36 : Expected exactly one element for jsdocs, got 0

The options object should be defined like this:

  romanNumeral(
    options:
      | number
      | {
          /**
           * Lower bound for generated number.
           *
           * @default 1
           */
          min?: number;
          /**
           * Upper bound for generated number.
           *
           * @default 3999
           */
          max?: number;
        } = {}
  ): string {

ST-DDT avatar Sep 01 '24 19:09 ST-DDT

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.96%. Comparing base (c02beea) to head (6e04bef). Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3070   +/-   ##
=======================================
  Coverage   99.95%   99.96%           
=======================================
  Files        2805     2805           
  Lines      217025   217070   +45     
  Branches      956      969   +13     
=======================================
+ Hits       216938   217002   +64     
+ Misses         87       68   -19     
Files with missing lines Coverage Ξ”
src/modules/number/index.ts 100.00% <100.00%> (ΓΈ)

... and 2 files with indirect coverage changes

codecov[bot] avatar Sep 03 '24 01:09 codecov[bot]

@AmaanRS Could you please address the requested changes?

ST-DDT avatar Oct 12 '24 23:10 ST-DDT

Please also change the description of the PR to something explaining the feature in more detail. A few sentences are sufficient.

ST-DDT avatar Oct 19 '24 19:10 ST-DDT

@Shinigami92 and @import-brain Could you please re-review this PR (or dismiss your stale reviews)?

ST-DDT avatar Oct 29 '24 12:10 ST-DDT

@AmaanRS Thanks for your first contribution. ❀️ I hope you had a good experience contributing. If you have any suggestions on how to improve things, please let us know.

This feature will be released in Faker v9.2, which will probably release shortly (a week to a few weeks).

ST-DDT avatar Oct 31 '24 10:10 ST-DDT