Skip to content

Conversation

dev-sna
Copy link
Collaborator

@dev-sna dev-sna commented Dec 19, 2018

No description provided.

import { getFullname, makeQueryStringTransformable } from '../../utils/utils';

it('Shoud check if getFullname util works', () => {
expect(getFullname({ firstName: 'Jack', lastName: 'John' })).toEqual(
Copy link
Contributor

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('-');
Copy link
Contributor

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?

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.

Copy link
Contributor

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?

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> {
Copy link
Contributor

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

<ul className="commentList">
{props.comments.map(comment => (
<CommentListItem comment={comment} key={comment.id} />
<CommentListItem comment={comment} />
Copy link
Contributor

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 ?

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.

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> {
Copy link
Contributor

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> {
Copy link
Contributor

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) => {
Copy link
Contributor

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

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?

* @returns undefined.
*/
handleSearchChange = (e: SyntheticEvent<HTMLButtonElement>) => {
handleSearchChange = e => {
Copy link
Contributor

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?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants