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: rewrite mersenne tests #480

Merged
merged 12 commits into from
Feb 14, 2022

Conversation

piotrekn
Copy link
Contributor

Mersenne tests extracted from random.spec.ts.

@piotrekn piotrekn requested a review from a team as a code owner February 12, 2022 23:45
@codecov
Copy link

codecov bot commented Feb 12, 2022

Codecov Report

Merging #480 (7b68a88) into main (7a2a522) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #480   +/-   ##
=======================================
  Coverage   99.34%   99.34%           
=======================================
  Files        1919     1919           
  Lines      176291   176291           
  Branches      902      904    +2     
=======================================
+ Hits       175135   175136    +1     
+ Misses       1100     1099    -1     
  Partials       56       56           
Impacted Files Coverage Δ
src/mersenne.ts 100.00% <100.00%> (ø)
src/helpers.ts 99.39% <0.00%> (-0.16%) ⬇️
src/vendor/unique.ts 97.58% <0.00%> (+1.61%) ⬆️

test/mersenne.spec.ts Show resolved Hide resolved
test/mersenne.spec.ts Outdated Show resolved Hide resolved
@ST-DDT ST-DDT requested a review from a team February 13, 2022 00:40
@ST-DDT ST-DDT added the c: test label Feb 13, 2022
test/mersenne.spec.ts Outdated Show resolved Hide resolved
test/mersenne.spec.ts Outdated Show resolved Hide resolved
test/mersenne.spec.ts Outdated Show resolved Hide resolved
@Shinigami92 Shinigami92 changed the title Test rewrite mersenne tests test: rewrite mersenne tests Feb 13, 2022
@Shinigami92 Shinigami92 marked this pull request as draft February 13, 2022 09:51
@piotrekn piotrekn marked this pull request as ready for review February 13, 2022 22:56
@piotrekn piotrekn marked this pull request as draft February 13, 2022 22:56
Shinigami92
Shinigami92 previously approved these changes Feb 14, 2022
@Shinigami92 Shinigami92 requested review from ST-DDT and a team February 14, 2022 07:44
@piotrekn piotrekn marked this pull request as ready for review February 14, 2022 08:26
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.

The tests are a little hard to read, but IMO its good enough for now and way better than the previous tests.

Maybe change the seededRuns to

type SeededRun = {
  seed: number | number[];
  expectations: SeededRunExpectation[];
};
type SeededRunExpectations = {
  args: any[], // not sure about the type here
  expected: number,
  skip?: boolean,
};

Then you can use it like this:

const actual = mersenne.rand(...args);

expect(actual).toEqual(expected);

@Shinigami92 What do you think?

Also, IMO we should use .toBe() instead of .toEqual() as we are dealing with primitive values anyway.

@ST-DDT ST-DDT requested a review from a team February 14, 2022 11:26
@Shinigami92
Copy link
Member

The tests are a little hard to read, but IMO its good enough for now and way better than the previous tests.

Maybe change the seededRuns to

type SeededRun = {
  seed: number | number[];
  expectations: SeededRunExpectation[];
};
type SeededRunExpectations = {
  args: any[], // not sure about the type here
  expected: number,
  skip?: boolean,
};

Then you can use it like this:

const actual = mersenne.rand(...args);

expect(actual).toEqual(expected);

@Shinigami92 What do you think?

Also, IMO we should use .toBe() instead of .toEqual() as we are dealing with primitive values anyway.

That's many suggestions / ideas and I think not directly related to this PR
Let's discuss and draft this later together in Discord

test/mersenne.spec.ts Show resolved Hide resolved
@ST-DDT ST-DDT merged commit 2f94155 into faker-js:main Feb 14, 2022
demipel8 pushed a commit to demipel8/faker that referenced this pull request Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants