Skip to content

test: add tests for CommentInput #582

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

Merged
merged 40 commits into from
Jan 6, 2018

Conversation

dyesseyumba
Copy link
Contributor

Hi, here is the unit test for the component 'CommentInput'.

dyesseyumba and others added 27 commits October 19, 2017 09:09
* feat(markdown): Add support for quoted emails

* fix: use paddingHorizontal instead of Left and Right
…#493)

* refactor: Drop rn-app-intro in favor of react-native-swiper

* fix: Don't embed swiper in a View, so that it works on Android
* Spanish file (first translation)

* Languague related files

* Fix

* Replaced double quotes

* Improved spanish translation

* Minor improvements (spanish translation)

* Some improvements (spanish translation)

The GIT reserved words are kept without translate.

* Removed english phrase

* Updated analytics title

* Updated spanish translation

* Added missing fields (spanish translation)

* Replaced tabs (spanish translation)

* Changed some words to downcase (spanish translation)
* feat(issue_events): Show events on issues

* style(issue_events): Added styles to "added label" event

* style(issue_events): Add icon & improve styling of added labels

* style(issue_events): Improve <ReviewRequested /> styles

* feat(issue_events): Remove mentioned/subscribed events from UI

* feat(issue_events): Define <Closed /> events

* refactor(issue_events): Extract <EventIcon /> and <Date />

* feat(issue_events): Add `unlabled` prop to <Labeled />

* feat(issue_events): Define <Merged /> event

* feat(issue_events): Filter out `closed` events preceded by `merged`

* feat(issue_events): Define <HeadRef /> events

* feat(issue_events): Define <Assigned /> events

* feat(issue_events): Define <Reopened /> & <Renamed /> events

* refactor(issue_events): Render <Text /> from <ActorLink />

* style(issue_events): Trim issue names to ensure spacing

* feat(issue_events): Define <Locked />  event

* feat(issue_events): Define <Milestoned />  event

* refactor(issue_events): Clean up authUser from LabeledComponent

* feat(issue_events): Define <MarkedAsDuplicate /> event

* refactor(issue_events): Define generic <Event /> component

* docs(readme): Add @brandly as a contributor

* feat(issue_events): Define <LabelGroup /> for list of label changes

* refactor(issue_events): Use spread operator for textChildren

* style(issue_events): Add blank line after external imports

* feat(issue_events): <InlineLabel /> has rounded corners

* refactor(issue_events): Move <InlineLabel /> into own file

* feat(issue_events): Press username in events to view profile

* refactor(events): Inline most <Event />s into <IssueEventListItem />

* refactor(events): Eliminate <Date /> since its only used once

* refactor(events): Extract formatEventsToRender into event-helpers
Adds back button when AuthProfileScreen is not the root of a StackNavigator.

Ps. AuthProfileScreen is StackNavigator root when the routeName is MyProfile.
* chore(fonts): Not link all fonts from react-native-vector-icons

* fix(fonts): Add the missing Menlo

* fix(cli): Fix for RN 0.48

* chore(cli): Run `yarn run link` again
…int#510)

Convert notification-icon.component.js to use styled-components as part of gitpoint#503
gitpoint#509)

Converted the label-list-item component styles to styled-components
Converted view-container.component.js to use styled components

BREAKING CHANGE: none

none
* test: begin implementing tests

* test: add more tests

* test: add Buton and Badge tests

* test: add StateBadge test

* test: only import used enzyme wrappers

* chore(deps): update table component to 1.1.0

* test: Add tests for ToggleView

* Update ToggleView.js
@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 36.413% when pulling a5b49d0 on dyesseyumba:componentInput_test into 0cd67ba on gitpoint:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 36.413% when pulling a5b49d0 on dyesseyumba:componentInput_test into 0cd67ba on gitpoint:master.

Copy link
Member

@andrewda andrewda left a comment

Choose a reason for hiding this comment

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

Please use lower case to start sentences in it statements. Also, can you run this through prettier? It should have done it by default but I'm guessing your environment isn't setup correctly.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 38.172% when pulling d379786 on dyesseyumba:componentInput_test into 5266fb2 on gitpoint:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 38.172% when pulling 59fc4de on dyesseyumba:componentInput_test into 5266fb2 on gitpoint:master.

Copy link
Member

@andrewda andrewda left a comment

Choose a reason for hiding this comment

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

Just some tiny wording stuff

onSubmit: () => {},
};

it('should render TextInput and TouchableOpacity if I can post', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Use 3rd person. 'should render TextInput and TouchableOpacity if user has post permissions'

expect(wrapper.find('Text').length).toEqual(0);
});

it("should not render TextInput and TouchableOpacity if I can't post", () => {
Copy link
Member

Choose a reason for hiding this comment

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

Use 3rd person. 'should not render TextInput and TouchableOpacity if user does not have post permissions'

expect(wrapper.find('Text').length).toEqual(1);
});

it('should update the state text if value changed', () => {
Copy link
Member

Choose a reason for hiding this comment

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

'should update the state text if value is changed'

expect(wrapper.state('text')).toEqual('Changed text');
});

it('should call handleSubmit methods when submitted', () => {
Copy link
Member

Choose a reason for hiding this comment

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

'should call handleSubmit method when submitted'

expect(wrapper.state('height')).toBe(10);
});

it('should call handleSubmitEditing methods when onSubmitEditing event raised', () => {
Copy link
Member

Choose a reason for hiding this comment

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

'should call handleSubmitEditing method when onSubmitEditing event is raised'

Copy link
Member

Choose a reason for hiding this comment

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

@dyesseyumba 'should call handleSubmitEditing method in Android when onSubmitEditing event is raised'. Please also mention the platform.

andrewda and others added 3 commits October 28, 2017 20:34
@coveralls
Copy link

Coverage Status

Coverage increased (+2.2%) to 41.538% when pulling 2619666 on dyesseyumba:componentInput_test into 753f60c on gitpoint:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.2%) to 41.538% when pulling 25cf771 on dyesseyumba:componentInput_test into 753f60c on gitpoint:master.

Copy link
Member

@andrewda andrewda left a comment

Choose a reason for hiding this comment

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

Looks good after the changes requested by @chinesedfan

@chinesedfan
Copy link
Member

@dyesseyumba Thanks for your updates. Please notice that more components were introduced, but you didn't update test descriptions. It is better to only test one component or some related components in each test case.

@dyesseyumba
Copy link
Contributor Author

@chinesedfan I'm a little lost about new components. Those components are not the olds components styled with 'styled-components'? I updated the test description by adding the prefix "styled" in front of the component name. For example for the component InputText I used styled TextInput in description because it appear as Styled(TextInput) with enzyme.
Do I have to use the name of the component as it appears in ComponentInput class?

You right about to only test one component. I added unnecessary assertions for child components. I'll fix that.

Copy link
Member

@chinesedfan chinesedfan left a comment

Choose a reason for hiding this comment

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

@dyesseyumba Sorry about my words made you confused. "new components" just means other components except for "TextInput" and "TouchableOpacity".

expect(wrapper.find('Styled(TextInput)').length).toEqual(1);
expect(wrapper.find('Styled(TouchableOpacity)').length).toEqual(1);
expect(wrapper.find('Styled(PostButtonIcon)').length).toEqual(1);
expect(wrapper.find('Styled(Text)').length).toEqual(0);
Copy link
Member

Choose a reason for hiding this comment

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

The description didn't mention "Styled(PostButtonIcon)" and "Styled(Text)". They are what I mean "more components".

@coveralls
Copy link

Coverage Status

Coverage increased (+2.2%) to 41.538% when pulling 75e45fd on dyesseyumba:componentInput_test into 753f60c on gitpoint:master.

Copy link
Member

@chinesedfan chinesedfan left a comment

Choose a reason for hiding this comment

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

@dyesseyumba There are still some conflicts between descriptions and implementations. I suggest you to design test cases follow patterns, then no typos will be included completely.

For example, should [not] render <components> if <conditions>. Make sure "components" covers all components, and for each same "components", their "conditions" cover all possibilities.

expect(wrapper.find('Icon').length).toEqual(0);
});

it('should render styled TextInput and styled TouchableOpacity if user does not have post permissions and issue is not locked', () => {
Copy link
Member

Choose a reason for hiding this comment

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

issue is locked.

expect(wrapper.find('Styled(TouchableOpacity)').length).toEqual(1);
});

it('should not render styled Text and icon if user does not have post permissions and issue is not locked', () => {
Copy link
Member

Choose a reason for hiding this comment

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

issue is locked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry! You're right, I missed that. I'll take my time.

onSubmit: () => {},
};

it('should render styled TextInput and styled TouchableOpacity if user has post permissions and issue is not locked', () => {
Copy link
Member

Choose a reason for hiding this comment

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

has push permissions

@coveralls
Copy link

Coverage Status

Coverage increased (+2.2%) to 41.538% when pulling cd7f497 on dyesseyumba:componentInput_test into 753f60c on gitpoint:master.

Copy link
Member

@andrewda andrewda left a comment

Choose a reason for hiding this comment

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

Can you run prettier on this code? Several things need to be cleaned up and will be done so automatically with prettier.

@coveralls
Copy link

coveralls commented Nov 3, 2017

Coverage Status

Coverage increased (+2.2%) to 41.538% when pulling 156285b on dyesseyumba:componentInput_test into 753f60c on gitpoint:master.

@dyesseyumba
Copy link
Contributor Author

@andrewda and @alejandronanez I applied all changes you requested but you didn't approve. Is anything wrong with this PR?

@chinesedfan
Copy link
Member

Ping @andrewda and @alejandronanez. Seems good to me now.

@chinesedfan chinesedfan merged commit 9b54b8e into gitpoint:master Jan 6, 2018
@chinesedfan
Copy link
Member

Don't hardcode Platform

Except the above suggestion by @alejandronanez, everything is OK. But I think it is still acceptable and this PR has been pending for such long time without new feedbacks. So let it be merged!

@dyesseyumba dyesseyumba deleted the componentInput_test branch March 17, 2018 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.