-
Notifications
You must be signed in to change notification settings - Fork 80
refactor: convert Author component to hooks #150
refactor: convert Author component to hooks #150
Conversation
dist: { fileCount: 0, unpackedSize: 0 }, | ||
}, | ||
_uplinks: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not needed for the test but were missing before. The type error was hidden by using jest.fn
Fixed by running the tests on MacOS |
834b0e4
to
0ba12a1
Compare
|
||
describe('<Author /> component', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
const component = (packageMeta: React.ContextType<typeof DetailContext>['packageMeta']): JSX.Element => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, as it is a component, it must be capitalize and have a more descriptive name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also write this component outside of the describe<'Author .....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component
==> mockAuthorComponent
. It has to be lower case since is a function. Other popular naming way might be withAuthorComponent
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm unfortunately I don't agree with you @juanpicado it returns an JSX element and according to the standards it should be capitalize...Please see that also Function Components are functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main difference is that this doesn't take props, you can't use it as a JSX element.
That's why I didn't consider it a component and why I used lowercase, it's more of a function that returns JSX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@priscilawebdev any last comment here? or can we merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juanpicado no...We can merge :-)
@bighuggies PR looks great! Thank you so much 👏, it needs just some minor changes..please check my comments. |
Codecov Report
@@ Coverage Diff @@
## master #150 +/- ##
=========================================
Coverage ? 82.97%
=========================================
Files ? 97
Lines ? 928
Branches ? 163
=========================================
Hits ? 770
Misses ? 141
Partials ? 17
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @bighuggies , after check the changes, seems something is broken.
it should looks like
or you can double check here
https://registry.verdaccio.org/-/web/detail/jquery/v/2.2.1
I haven't dug enough to see the reason, but let me know whether you have troubles to solve it. I can help.
…daccio-ui into ah/author-component-hooks
That seems to be an issue on A quick I will open a separate PR to fix it 👍 EDIT: #160 |
Thanks @bighuggies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @bighuggies !
thank you @bighuggies... yeah the Tooltip import was wrong.. I need to check why the tests passed...good job! |
Type: refactor
The following has been addressed in the PR: #116
Minor changes had to be made to the mocking in the existing tests to enable hooks. The tests are also more typesafe.
Description:
<Author />
to a function componentuseContext
hookpackageMeta
(is there a better way to do this?)