Skip to content

Commit 8ffa733

Browse files
Merge pull request #258 from virdesai/crns-147/close-button-tests-and-hooks
CRNS-147: converting CloseButton component from class to functional component and adding hooks
2 parents ee639b7 + a40b921 commit 8ffa733

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

src/components/CloseButton/CloseButton.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,27 @@ import { Image } from 'react-native';
33

44
import styled from '@stream-io/styled-components';
55

6-
import { themed } from '../../styles/theme';
76
import closeRound from '../../images/icons/close-round.png';
87

8+
import { themed } from '../../styles/theme';
9+
910
const Container = styled.View`
10-
width: 30;
11-
height: 30;
12-
border-radius: 3;
1311
align-items: center;
14-
justify-content: center;
1512
background-color: white;
1613
border: 1px solid rgba(0, 0, 0, 0.1);
14+
border-radius: 3px;
15+
height: 30px;
16+
justify-content: center;
17+
width: 30px;
1718
${({ theme }) => theme.closeButton.container.css}
1819
`;
1920

20-
const CloseButton = themed(
21-
class CloseButton extends React.PureComponent {
22-
static themePath = 'closeButton';
23-
render() {
24-
return (
25-
<Container>
26-
<Image source={closeRound} />
27-
</Container>
28-
);
29-
}
30-
},
21+
const CloseButton = () => (
22+
<Container>
23+
<Image source={closeRound} testID='close-button' />
24+
</Container>
3125
);
3226

33-
CloseButton.propTypes = {};
27+
CloseButton.themePath = 'closeButton';
3428

35-
export default CloseButton;
29+
export default themed(CloseButton);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { render, wait } from '@testing-library/react-native';
3+
4+
import CloseButton from '../CloseButton';
5+
6+
describe('CloseButton', () => {
7+
it('should render a CloseButton', async () => {
8+
const { queryByTestId } = render(<CloseButton />);
9+
10+
await wait(() => expect(queryByTestId('close-button')).toBeTruthy());
11+
});
12+
});

0 commit comments

Comments
 (0)