Skip to content

Commit 317f73c

Browse files
committed
fix(test): Fix CommentInput test cases
1 parent 280210a commit 317f73c

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

__tests__/tests/components/CommentInput.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ describe('<CommentInput />', () => {
1313
onSubmit: () => {},
1414
};
1515

16-
it('should render styled TextInput and styled TouchableOpacity if user has push permissions and issue is not locked', () => {
16+
it('should render styled TextInput and send Icon if user has push permissions and issue is not locked', () => {
1717
const wrapper = shallow(<CommentInput {...defaultProps} />);
1818

1919
expect(wrapper.find('Styled(TextInput)').length).toEqual(1);
20-
expect(wrapper.find('Styled(TouchableOpacity)').length).toEqual(1);
20+
expect(wrapper.find('Styled(Icon)[name="send"]').length).toEqual(1);
2121
});
2222

23-
it('should not render styled Text and Icon if user has push permissions and issue is not locked', () => {
23+
it('should not render styled Text and lock Icon if user has push permissions and issue is not locked', () => {
2424
const wrapper = shallow(<CommentInput {...defaultProps} />);
2525

2626
expect(wrapper.find('Styled(Text)').length).toEqual(0);
2727
expect(wrapper.find('Icon').length).toEqual(0);
2828
});
2929

30-
it('should not render styled TextInput and styled TouchableOpacity if user does not have push permissions and issue is locked', () => {
30+
it('should not render styled TextInput and send Icon if user does not have push permissions and issue is locked', () => {
3131
const wrapper = shallow(
3232
<CommentInput
3333
{...defaultProps}
@@ -37,10 +37,10 @@ describe('<CommentInput />', () => {
3737
);
3838

3939
expect(wrapper.find('Styled(TextInput)').length).toEqual(0);
40-
expect(wrapper.find('Styled(TouchableOpacity)').length).toEqual(0);
40+
expect(wrapper.find('Styled(Icon)[name="send"]').length).toEqual(0);
4141
});
4242

43-
it('should render styled Text and Icon if user does not have push permissions and issue is locked', () => {
43+
it('should render styled Text and lock Icon if user does not have push permissions and issue is locked', () => {
4444
const wrapper = shallow(
4545
<CommentInput
4646
{...defaultProps}
@@ -53,16 +53,16 @@ describe('<CommentInput />', () => {
5353
expect(wrapper.find('Icon').length).toEqual(1);
5454
});
5555

56-
it('should render styled TextInput and styled TouchableOpacity if user has push permissions and issue is locked', () => {
56+
it('should render styled TextInput and send Icon if user has push permissions and issue is locked', () => {
5757
const wrapper = shallow(
5858
<CommentInput {...defaultProps} issueLocked={true} />
5959
);
6060

6161
expect(wrapper.find('Styled(TextInput)').length).toEqual(1);
62-
expect(wrapper.find('Styled(TouchableOpacity)').length).toEqual(1);
62+
expect(wrapper.find('Styled(Icon)[name="send"]').length).toEqual(1);
6363
});
6464

65-
it('should not render styled Text and Icon if user has push permissions and issue is locked', () => {
65+
it('should not render styled Text and lock Icon if user has push permissions and issue is locked', () => {
6666
const wrapper = shallow(
6767
<CommentInput {...defaultProps} issueLocked={true} />
6868
);
@@ -71,7 +71,7 @@ describe('<CommentInput />', () => {
7171
expect(wrapper.find('Icon').length).toEqual(0);
7272
});
7373

74-
it('should not render styled Text and Icon if user does not have push permissions and issue is not locked', () => {
74+
it('should not render styled Text and lock Icon if user does not have push permissions and issue is not locked', () => {
7575
const wrapper = shallow(
7676
<CommentInput {...defaultProps} userHasPushPermission={false} />
7777
);
@@ -80,13 +80,13 @@ describe('<CommentInput />', () => {
8080
expect(wrapper.find('Icon').length).toEqual(0);
8181
});
8282

83-
it('should render styled TextInput and styled TouchableOpacity if user does not have push permissions and issue is not locked', () => {
83+
it('should render styled TextInput and send Icon if user does not have push permissions and issue is not locked', () => {
8484
const wrapper = shallow(
8585
<CommentInput {...defaultProps} userHasPushPermission={false} />
8686
);
8787

8888
expect(wrapper.find('Styled(TextInput)').length).toEqual(1);
89-
expect(wrapper.find('Styled(TouchableOpacity)').length).toEqual(1);
89+
expect(wrapper.find('Styled(Icon)[name="send"]').length).toEqual(1);
9090
});
9191

9292
it('should update the state text if value is changed', () => {
@@ -108,7 +108,10 @@ describe('<CommentInput />', () => {
108108

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

111-
wrapper.find('Styled(TouchableOpacity)').simulate('press');
111+
wrapper
112+
.find('Styled(Icon)[name="send"]')
113+
.parent()
114+
.simulate('press');
112115

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

0 commit comments

Comments
 (0)