Skip to content

Commit af91382

Browse files
author
jaapbakker88
authored
rename Image component to ImageComponent (#554)
1 parent 283154a commit af91382

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

src/components/Attachment/Attachment.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import DefaultAudio from './Audio';
1010
import DefaultCard from './Card';
1111
import DefaultFile from './FileAttachment';
1212

13-
import { Image as DefaultImage, Gallery as DefaultGallery } from '../Gallery';
13+
import {
14+
ImageComponent as DefaultImage,
15+
Gallery as DefaultGallery,
16+
} from '../Gallery';
1417

1518
export const SUPPORTED_VIDEO_FORMATS = [
1619
'video/mp4',

src/components/Gallery/Image.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { sanitizeUrl } from '@braintree/sanitize-url';
1111
* @example ../../docs/Image.md
1212
* @extends {React.PureComponent<import('type').ImageProps>}
1313
*/
14-
class Image extends React.PureComponent {
14+
class ImageComponent extends React.PureComponent {
1515
static propTypes = {
1616
/** The full size image url */
1717
image_url: PropTypes.string,
@@ -56,4 +56,4 @@ class Image extends React.PureComponent {
5656
}
5757
}
5858

59-
export default Image;
59+
export default ImageComponent;

src/components/Gallery/__tests__/Image.test.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,27 @@ import { cleanup, render, fireEvent, waitFor } from '@testing-library/react';
55

66
import '@testing-library/jest-dom';
77

8-
import Image from '../Image';
8+
import ImageComponent from '../Image';
99

1010
const mockImageAssets = 'https://placeimg.com/640/480/any';
1111

1212
afterEach(cleanup); // eslint-disable-line
1313

1414
describe('Image', () => {
1515
it('should render component with default props', () => {
16-
const tree = renderer.create(<Image images={mockImageAssets} />).toJSON();
16+
const tree = renderer
17+
.create(<ImageComponent images={mockImageAssets} />)
18+
.toJSON();
1719
expect(tree).toMatchSnapshot();
1820
});
1921

2022
describe('it should prevent unsafe image uri protocols in the rendered image src', () => {
2123
it('should prevent javascript protocol in image src', () => {
2224
// eslint-disable-next-line no-script-url
2325
const xssJavascriptUri = 'javascript:alert("p0wn3d")';
24-
const { getByTestId } = render(<Image image_url={xssJavascriptUri} />);
26+
const { getByTestId } = render(
27+
<ImageComponent image_url={xssJavascriptUri} />,
28+
);
2529
expect(getByTestId('image-test')).not.toHaveAttribute(
2630
'src',
2731
xssJavascriptUri,
@@ -30,28 +34,30 @@ describe('Image', () => {
3034
it('should prevent javascript protocol in thumbnail src', () => {
3135
// eslint-disable-next-line no-script-url
3236
const xssJavascriptUri = 'javascript:alert("p0wn3d")';
33-
const { getByTestId } = render(<Image thumb_url={xssJavascriptUri} />);
37+
const { getByTestId } = render(
38+
<ImageComponent thumb_url={xssJavascriptUri} />,
39+
);
3440
expect(getByTestId('image-test')).not.toHaveAttribute(
3541
'src',
3642
xssJavascriptUri,
3743
);
3844
});
3945
it('should prevent dataUris in image src', () => {
4046
const xssDataUri = 'data:image/svg+xml;base64,DANGEROUSENCODEDSVG';
41-
const { getByTestId } = render(<Image image_url={xssDataUri} />);
47+
const { getByTestId } = render(<ImageComponent image_url={xssDataUri} />);
4248
expect(getByTestId('image-test')).not.toHaveAttribute('src', xssDataUri);
4349
});
4450
it('should prevent dataUris in thumb src', () => {
4551
const xssDataUri = 'data:image/svg+xml;base64,DANGEROUSENCODEDSVG';
46-
const { getByTestId } = render(<Image thumb_url={xssDataUri} />);
52+
const { getByTestId } = render(<ImageComponent thumb_url={xssDataUri} />);
4753
expect(getByTestId('image-test')).not.toHaveAttribute('src', xssDataUri);
4854
});
4955
});
5056

5157
it('should open modal on image click', async () => {
5258
jest.spyOn(console, 'warn').mockImplementation(() => null);
5359
const { getByTestId, getByTitle } = render(
54-
<Image images={mockImageAssets} />,
60+
<ImageComponent images={mockImageAssets} />,
5561
);
5662
fireEvent.click(getByTestId('image-test'));
5763

src/components/Gallery/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { default as Gallery } from './Gallery';
2-
export { default as Image } from './Image';
2+
export { default as ImageComponent } from './Image';
33
export { default as ModalImage } from './ModalImage';
44
export { default as ModalWrapper } from './ModalWrapper';

0 commit comments

Comments
 (0)