-
Notifications
You must be signed in to change notification settings - Fork 10
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
Integrate/typescript: Project shifted to Typescript #251
base: integrate/typescript
Are you sure you want to change the base?
Integrate/typescript: Project shifted to Typescript #251
Conversation
client/src/test/utils/utils.test.js
Outdated
import { getFullname, makeQueryStringTransformable } from '../../utils/utils'; | ||
|
||
it('Shoud check if getFullname util works', () => { | ||
expect(getFullname({ firstName: 'Jack', lastName: 'John' })).toEqual( |
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.
Is in it good to have file that contain data-> user1: {firstName: "abc",lastName:"xyz", fullName: "abc xyz"}?
'Jack John' | ||
); | ||
expect(getFullname({ firstName: 'Jack' })).toEqual('Jack'); | ||
expect(getFullname({ firstName: '', lastName: '' })).toEqual('-'); |
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.
why do we expect fullname to be '-' if firstname and lastname is empty?
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.
Because the util method is written this way.
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.
Don't you think if thats the case we need to fix util method instead of hack test?
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.
We display a '-' when nothing is provided. If we need to change the util, an issue can be created with the requirement.
class CommentBox extends Component { | ||
type Props = SubmitVoid; | ||
|
||
class CommentBox extends Component<Props> { |
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.
if this component does not have a state we can change it to dump or stateless functional component. If it has state we need to define type for state
return ( | ||
<ul className="commentList"> | ||
{props.comments.map(comment => ( | ||
<CommentListItem comment={comment} key={comment.id} /> | ||
<CommentListItem comment={comment} /> |
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.
does not this produce an error after removing key ?
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.
This was duplicated. In the container and the component to be rendered. I kept it only in the component. Won't throw a warning.
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.
Accidentally removed the key. Should have removed from the Item. Done.
comment: Comment | ||
}; | ||
|
||
class CommentListItem extends Component<Props> { |
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.
make it functional component if does not have state
eventID: string | ||
}; | ||
|
||
class CommentsBlock extends Component<Props> { |
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.
make it functional component if does not have state
description: string, | ||
}; | ||
|
||
const DescriptionContainer = (props: Props) => { |
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.
its not logically correct container can not be stateless functional component
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.
If the container doesn't require any state, why shouldn't it be a functional component?
@@ -89,7 +94,7 @@ class DropSearch extends Component<Props, State> { | |||
* - and pass either undefined or extracted object to prop (handleSearchChange method) | |||
* @returns undefined. | |||
*/ | |||
handleSearchChange = (e: SyntheticEvent<HTMLButtonElement>) => { | |||
handleSearchChange = e => { |
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.
can not we add event type here?
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.
We don't need to add types to everything in our app. Mostly the model should be restricted with types. Including redux logic and component state.
No description provided.