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: remove JSON.stringify wrapper around faker.seed() in tests descriptions #1196

Merged
merged 2 commits into from
Jul 28, 2022

Conversation

pkuczynski
Copy link
Member

I am not sure why we had those JSON.stringify @Shinigami92?

@pkuczynski pkuczynski requested a review from a team as a code owner July 26, 2022 20:48
@pkuczynski pkuczynski self-assigned this Jul 26, 2022
@pkuczynski pkuczynski added c: chore PR that doesn't affect the runtime behavior c: test labels Jul 26, 2022
@xDivisionByZerox xDivisionByZerox added this to the v7 - Current Major milestone Jul 26, 2022
@xDivisionByZerox xDivisionByZerox requested a review from a team July 26, 2022 20:53
@codecov
Copy link

codecov bot commented Jul 26, 2022

Codecov Report

Merging #1196 (006a548) into main (6629806) will increase coverage by 0.01%.
The diff coverage is n/a.

❗ Current head 006a548 differs from pull request most recent head 51e29fe. Consider uploading reports for the commit 51e29fe to get more accurate results

@@            Coverage Diff             @@
##             main    #1196      +/-   ##
==========================================
+ Coverage   99.63%   99.64%   +0.01%     
==========================================
  Files        2148     2146       -2     
  Lines      230582   230499      -83     
  Branches      983      981       -2     
==========================================
- Hits       229736   229689      -47     
+ Misses        825      789      -36     
  Partials       21       21              
Impacted Files Coverage Δ
src/modules/internet/user-agent.ts 87.24% <0.00%> (-5.51%) ⬇️
src/definitions/date.ts 0.00% <0.00%> (ø)
src/definitions/color.ts 0.00% <0.00%> (ø)
src/definitions/hacker.ts 0.00% <0.00%> (ø)
src/definitions/system.ts 0.00% <0.00%> (ø)
src/definitions/address.ts 0.00% <0.00%> (ø)
src/definitions/company.ts 0.00% <0.00%> (ø)
src/definitions/finance.ts 0.00% <0.00%> (ø)
src/definitions/science.ts 0.00% <0.00%> (ø)
src/definitions/vehicle.ts 0.00% <0.00%> (ø)
... and 7 more

@xDivisionByZerox
Copy link
Member

They were wrapped due to faker.seed being able to return an array of numbers if one is used as input value. But we don't do that so this should be fine.

Copy link
Member

@ST-DDT ST-DDT left a comment

Choose a reason for hiding this comment

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

I think it's okay.

@pkuczynski
Copy link
Member Author

pkuczynski commented Jul 26, 2022

They were wrapped due to faker.seed being able to return an array of numbers if one is used as input value. But we don't do that so this should be fine.

  1. seed(seed?: number): number;
  2. console.log(`${[1, 2, 3]}`) // '1,2,3'

:)

@xDivisionByZerox
Copy link
Member

console.log(${[1, 2, 3]}) // '1,2,3'

And that's why JSON.stringif was used for arrays. Because this output this sh*t. I mean it works but doesn't provide clarity. You could also have written console.log(`${seed1}, ${seed2}, ${seed3}`).
One the other side, JSON gives me a nicely formatted array console.log(JSON.stringify([1,2,3])) // [1,2,3].

But it doesn't matter since we know now from the signature overload if the return value will be an array or not and can act accordingly.

@pkuczynski
Copy link
Member Author

From the signature we know it's never an array :)

@ST-DDT ST-DDT requested review from a team July 26, 2022 23:10
@xDivisionByZerox
Copy link
Member

faker/src/faker.ts

Lines 242 to 244 in 5ea8252

seed(
seed: number | number[] = Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
): number | number[] {

It literally has number OR number[] as return type.

@pkuczynski
Copy link
Member Author

Indeed! I haven't notice the overload because of jsdoc, sorry :)

@ST-DDT ST-DDT enabled auto-merge (squash) July 28, 2022 07:56
@ST-DDT ST-DDT merged commit de39d9c into main Jul 28, 2022
@ST-DDT ST-DDT deleted the drop-json-stringify branch July 30, 2022 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: chore PR that doesn't affect the runtime behavior c: test
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants