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(phone): rename phoneNumber to number #1063

Merged
merged 10 commits into from
Jun 16, 2022

Conversation

xDivisionByZerox
Copy link
Member

Listed as a todo in #1044.

This PR does the following things:

  • move the implementation from phone.phoneNumber() into a new function called phone.number()
  • deprecate phone.phoneNumber() via the internal deprecated method
  • add a @deprecated JSDoc parameter to the phone.phoneNumber() signature documentation
  • duplicates the test checks from phoneNumber() to number()
  • add a test case for phoneNumber() deprecation log

@xDivisionByZerox xDivisionByZerox added p: 1-normal Nothing urgent c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs labels Jun 12, 2022
@xDivisionByZerox xDivisionByZerox added this to the v7 - Current Major milestone Jun 12, 2022
@xDivisionByZerox xDivisionByZerox self-assigned this Jun 12, 2022
@xDivisionByZerox xDivisionByZerox requested a review from a team as a code owner June 12, 2022 01:27
@xDivisionByZerox xDivisionByZerox requested a review from a team June 12, 2022 01:39
@xDivisionByZerox
Copy link
Member Author

The ci is failing with an error I couldn't figure out.

FAIL  test/scripts/apidoc/examplesAndDeprecations.spec.ts > examples and deprecations > Phone > number
AssertionError: expected "warn" to not be called at allexpected "warn" to not be called at all
Received: 
    1st warn call:
    Array [
❯test/scripts/apidoc/examplesAndDeprecations.spec.ts:107:26
      "[@faker-js/faker]: faker.phone.phoneNumber() is deprecated since v7.2.0 and will be removed in v8.0.0. Please use faker.phone.number() instead.",
    ]
105|       } else {
106|         for (const spy of consoleSpies) {
107|           expect(spy).not.toHaveBeenCalled();
   | ^
108|         }
109|       }
    2nd warn call:
    Array [
      "[@faker-js/faker]: faker.phone.phoneNumber() is deprecated since v7.2.0 and will be removed in v8.0.0. Please use faker.phone.number() instead.",
Test Files 1 failed | 32 passed (33)
    ]
    3rd warn call:
     Tests 2 failed | 37156 passed | 9 todo (37167)
    Array [
      "[@faker-js/faker]: faker.phone.phoneNumber() is deprecated since v7.2.0 and will be removed in v8.0.0. Please use faker.phone.number() instead.",
    ]
Number of calls: 3

The error states that phone.number() is logging to the console, but if you have a look at the message (and the source code) you can clearly see that phone.phoneNumber() is the one doing the log.

What am I missing?

src/modules/phone/index.ts Show resolved Hide resolved
src/modules/phone/index.ts Outdated Show resolved Hide resolved
src/modules/phone/index.ts Outdated Show resolved Hide resolved
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.

Faker.fake still uses this method in the example.

@xDivisionByZerox
Copy link
Member Author

Faker.fake still uses this method in the example.

I understand, I usually search with "Find All References" when replacing something. Obviously, these references do not get found.

@codecov
Copy link

codecov bot commented Jun 12, 2022

Codecov Report

Merging #1063 (ffd9c2d) into main (50d8af1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1063   +/-   ##
=======================================
  Coverage   99.64%   99.64%           
=======================================
  Files        2135     2135           
  Lines      229190   229213   +23     
  Branches      977      979    +2     
=======================================
+ Hits       228376   228402   +26     
+ Misses        793      790    -3     
  Partials       21       21           
Impacted Files Coverage Δ
src/modules/fake/index.ts 100.00% <100.00%> (ø)
src/modules/phone/index.ts 100.00% <100.00%> (ø)
src/modules/finance/index.ts 100.00% <0.00%> (+0.68%) ⬆️

@ST-DDT
Copy link
Member

ST-DDT commented Jun 12, 2022

Faker.fake still uses this method in the example.

I understand, I usually search with "Find All References" when replacing something. Obviously, these references do not get found.

Thats why the test is there 😉

ST-DDT
ST-DDT previously approved these changes Jun 12, 2022
@ST-DDT ST-DDT requested a review from a team June 12, 2022 16:16
@ST-DDT ST-DDT added the s: accepted Accepted feature / Confirmed bug label Jun 12, 2022
@xDivisionByZerox
Copy link
Member Author

Thats why the test is there 😉

Yeah, but I was totally lost when looking at the error message since I wasn't able to find any (direct) call reference. We could potentially extend the message for these cases (faker.fake)? Not this PR tho.

test/phone.spec.ts Outdated Show resolved Hide resolved
@xDivisionByZerox xDivisionByZerox force-pushed the refactor/phone/rename-phoneNumber branch from 17dfb73 to 7ac3647 Compare June 16, 2022 18:48
src/modules/phone/index.ts Outdated Show resolved Hide resolved
test/phone.spec.ts Show resolved Hide resolved
@Shinigami92 Shinigami92 requested a review from ST-DDT June 16, 2022 19:52
@Shinigami92 Shinigami92 enabled auto-merge (squash) June 16, 2022 19:52
@Shinigami92 Shinigami92 merged commit aa031bb into main Jun 16, 2022
@ST-DDT ST-DDT deleted the refactor/phone/rename-phoneNumber branch June 16, 2022 19:53
Minozzzi pushed a commit to Minozzzi/faker that referenced this pull request Jul 19, 2022
@xDivisionByZerox xDivisionByZerox added the m: phone Something is referring to the phone module label Jul 28, 2022
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 m: phone Something is referring to the phone module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants