Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fe8be54
refactor(fonts): Remove useless fonts in android (#485)
dyesseyumba Oct 19, 2017
282f475
refactor(fonts): Remove MaterialIcons from used fonts in android (#485)
dyesseyumba Oct 19, 2017
4498f9a
Revert "refactor(fonts): Remove MaterialIcons from used fonts in andr…
dyesseyumba Oct 19, 2017
f09824a
fix: Update stateRandom and reset cookies after a successful login (#…
machour Oct 18, 2017
7f5695c
feat(markdown): Add support for quoted emails (#501)
machour Oct 19, 2017
a0c70b9
refactor: Drop rn-app-intro in favor of react-native-swiper (#493)
machour Oct 19, 2017
2b1c630
chore: Hide the commitlint folder (#488)
machour Oct 19, 2017
71396d4
feature(translation): add Spanish translation (#442)
khvilaboa Oct 19, 2017
6a19b1f
feat: Issue Events (#438)
brandly Oct 19, 2017
f51d206
fix(ux): Add back button for AuthProfileScreen (#507)
jouderianjr Oct 19, 2017
1153feb
style(issueeventlistitem, commentlistitem): Slightly shrink issue eve…
Oct 19, 2017
3415486
fix: Remove undefined var & fix typo (#517)
machour Oct 20, 2017
f89eabb
chore: fix `yarn run link` (#513)
chinesedfan Oct 20, 2017
07b4d63
chore(*): convert notification icon styles to styled-component (#510)
pdong Oct 20, 2017
d32c703
chore(*): convert label-list-item component styles to styled componen…
pdong Oct 20, 2017
9c4a23b
chore(*): style view-container.component.js (#508)
pdong Oct 20, 2017
b347424
refactor(auth): get user data after login (#502)
lex111 Oct 20, 2017
8f5baf4
test: begin implementing basic component tests (#407)
andrewda Oct 20, 2017
742aca3
refactor(fonts): Remove useless fonts in android (#485)
dyesseyumba Oct 19, 2017
d39759e
refactor(fonts): Remove MaterialIcons from used fonts in android (#485)
dyesseyumba Oct 19, 2017
1d35709
Revert "refactor(fonts): Remove MaterialIcons from used fonts in andr…
dyesseyumba Oct 19, 2017
43814b6
Merge remote-tracking branch 'origin/master'
dyesseyumba Oct 20, 2017
b5eaf4e
Merge remote-tracking branch 'upstream/master'
dyesseyumba Oct 21, 2017
29a1281
Merge remote-tracking branch 'upstream/master'
dyesseyumba Oct 22, 2017
482af68
Merge remote-tracking branch 'upstream/master'
dyesseyumba Oct 25, 2017
e31a1ab
test: Add tests for CommentInput (#518)
dyesseyumba Oct 25, 2017
a5b49d0
Merge remote-tracking branch 'upstream/master' into componentInput_test
dyesseyumba Oct 25, 2017
d0b8584
Merge remote-tracking branch 'upstream/master' into componentInput_test
dyesseyumba Oct 26, 2017
f478de0
refactor: Beautify the code of CommentInput unit test.
dyesseyumba Oct 27, 2017
dd56954
Merge remote-tracking branch 'upstream/master' into componentInput_test
dyesseyumba Oct 27, 2017
13ac053
refactor: use jest mocks instead of sinon spies.
dyesseyumba Oct 27, 2017
d379786
refactor: Apply @chinesedfan recommendations
dyesseyumba Oct 28, 2017
59fc4de
refactor: Improve test descriptions.
dyesseyumba Oct 28, 2017
9f79d23
Merge branch 'master' into componentInput_test
andrewda Oct 29, 2017
d138748
Merge remote-tracking branch 'upstream/master' into componentInput_test
dyesseyumba Oct 30, 2017
2619666
test: Add two cases of test and integrate styled-components in tests.
dyesseyumba Oct 30, 2017
25cf771
refactor: Remove console.log statement.
dyesseyumba Oct 30, 2017
75e45fd
test: Improve test descriptions and remove useless console.log
dyesseyumba Oct 31, 2017
cd7f497
test: Fix conflicts between descriptions and implementations.
dyesseyumba Nov 2, 2017
156285b
refactor: Runned prettier on CommentInput.js
dyesseyumba Nov 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ haste-map-react-native-packager*
# editors
.vscode
.idea

coverage/
119 changes: 119 additions & 0 deletions __tests__/tests/components/CommentInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React from 'react';
import {shallow} from 'enzyme';
import {Platform} from 'react-native';

import {CommentInput} from 'components';

describe('<CommentInput />', () => {

const defaultProps = {
users: [],
userHasPushPermission: true,
issueLocked: false,
locale: '',
onSubmit: () => {},
};

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

Copy link
Copy Markdown
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'


const wrapper = shallow(
<CommentInput {...defaultProps}/>
);

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

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

Copy link
Copy Markdown
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'


const wrapper = shallow(
<CommentInput
{...defaultProps}
userHasPushPermission={false}
issueLocked={true}/>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we separate as 2 cases? For userHasPushPermission and issueLocked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think no. Because userHasPushPermission and issueLocked are linked with the operation and.
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dyesseyumba Yes, there are 2 kinds of results. But we have 4 kinds of inputs, userHasPushPermission x2 and issueLocked x2. And issueLocked also affects the locked issue text and icon. Can you cover them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'm on it.

);

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

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

Copy link
Copy Markdown
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'

const wrapper = shallow(
<CommentInput {...defaultProps}/>
);

const input = wrapper.find('TextInput');

input.simulate('changeText', 'Changed text');

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

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

Copy link
Copy Markdown
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'

const wrapper = shallow(
<CommentInput {...defaultProps}/>
);

const handleSubmitSpy = jest.spyOn(wrapper.instance(), 'handleSubmit');

wrapper
.instance()
.forceUpdate();

wrapper
.find('TextInput')
.simulate('changeText', 'Changed text');

wrapper
.find('TouchableOpacity')
.simulate('press');

expect(handleSubmitSpy).toHaveBeenCalled();
});

it('should change the content size', () => {
const wrapper = shallow(
<CommentInput {...defaultProps}/>
);

wrapper
.find('TextInput')
.simulate('contentSizeChange', {
nativeEvent: {
contentSize: {
height: 10
}
}
});

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

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

Copy link
Copy Markdown
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
Copy Markdown
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.

const wrapper = shallow(
<CommentInput {...defaultProps}/>
);

const handleSubmitEditingSpy = jest.spyOn(wrapper.instance(), 'handleSubmitEditing');

wrapper
.instance()
.forceUpdate();

Platform.OS = 'android';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should mock this instead of modifying it directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I failed to import the mocked Platform object in wrapped CommentInput.

CommentInput import the Platform from 'react-native'. The challenge here is to inject the mocked Platform to CommentInput when called in import. But I didn't succeed. For that, I think I should use inject-loader.

Do you have any idea?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you explain this line for me? I am curious about iOS.

@dyesseyumba dyesseyumba Oct 28, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is an instruction for the platform Android in the method handleSubmitEditing. And the Platform object in imported in the class CommentInput from 'react-native'. But I failed to mock and import the platform object in CommentInput. I know @alejandronanez asked me to don't hardcode Platform, but I didn't found how to make it. I can use inject-loader as explained in this article but I have to install it.
image

About iOS; there is no condition for that in CommentInput class


wrapper
.find('TextInput')
.simulate('submitEditing', {
nativeEvent: {
text: 'Changed by submitEditing'
}
});

expect(handleSubmitEditingSpy).toHaveBeenCalled();

expect(wrapper.state('text')).toEqual('Changed by submitEditing\n');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, why does it end with \n?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is because the character \n is used in the method handleSubmitEditing.
image

});
});