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

refactor: simplify module creation #2485

Merged
merged 12 commits into from
Nov 6, 2023
Merged

refactor: simplify module creation #2485

merged 12 commits into from
Nov 6, 2023

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented Oct 17, 2023

Simplifies the modules by reusing the constructors from a shared module base.

This is a v8.x only feature, that will likely be obsolete in v9.0.

What do you think?

@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs labels Oct 17, 2023
@ST-DDT ST-DDT added this to the v8.x milestone Oct 17, 2023
@ST-DDT ST-DDT requested review from a team October 17, 2023 22:02
@ST-DDT ST-DDT self-assigned this Oct 17, 2023
@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Merging #2485 (415ed35) into next (358572d) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2485      +/-   ##
==========================================
+ Coverage   99.57%   99.58%   +0.01%     
==========================================
  Files        2819     2820       +1     
  Lines      255134   255037      -97     
  Branches     1095     1080      -15     
==========================================
- Hits       254050   253984      -66     
+ Misses       1056     1025      -31     
  Partials       28       28              
Files Coverage Δ
src/internal/module-base.ts 100.00% <100.00%> (ø)
src/modules/airline/index.ts 100.00% <100.00%> (ø)
src/modules/animal/index.ts 100.00% <100.00%> (ø)
src/modules/color/index.ts 99.79% <100.00%> (-0.01%) ⬇️
src/modules/commerce/index.ts 100.00% <100.00%> (ø)
src/modules/company/index.ts 100.00% <100.00%> (ø)
src/modules/database/index.ts 100.00% <100.00%> (ø)
src/modules/datatype/index.ts 100.00% <100.00%> (ø)
src/modules/date/index.ts 100.00% <100.00%> (ø)
src/modules/finance/index.ts 100.00% <100.00%> (ø)
... and 17 more

... and 1 file with indirect coverage changes

Copy link
Member

@xDivisionByZerox xDivisionByZerox left a comment

Choose a reason for hiding this comment

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

Can we add extend the test factory (or write a separate one) to include automatic test for these this bindings on all methods? Currently I'm not 100% sure that I can do.

const method = faker[moduleKey][methodKey]; 
method();

Additionally, while being a nice little addition I have a hard time seeing the advantage of introducing it now.

src/modules/module-base.ts Outdated Show resolved Hide resolved
@ST-DDT
Copy link
Member Author

ST-DDT commented Oct 18, 2023

Can we add extend the test factory (or write a separate one) to include automatic test for these this bindings on all methods? Currently I'm not 100% sure that I can do.

const method = faker[moduleKey][methodKey]; 
method();

We already have that:

const callable = this.module[method];
const value = callable(...args);

@ST-DDT ST-DDT added the s: needs decision Needs team/maintainer decision label Oct 20, 2023
@ST-DDT ST-DDT added s: accepted Accepted feature / Confirmed bug and removed s: needs decision Needs team/maintainer decision labels Oct 24, 2023
@ST-DDT ST-DDT enabled auto-merge (squash) November 6, 2023 08:32
@ST-DDT ST-DDT merged commit 48a7af4 into next Nov 6, 2023
38 checks passed
@ST-DDT ST-DDT deleted the refactor/module-creation branch November 6, 2023 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants