diff --git a/__tests__/tests/components/ImageZoom.js b/__tests__/tests/components/ImageZoom.js
new file mode 100644
index 000000000..4bf0c7cf1
--- /dev/null
+++ b/__tests__/tests/components/ImageZoom.js
@@ -0,0 +1,58 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+
+import { ImageZoom } from 'components';
+
+describe('', () => {
+ const defaultProps = {
+ style: { backgroundColor: 'red' },
+ uri: { uri: 'dummy.png' },
+ };
+
+ it('should render clickable image when the component initializes', () => {
+ const wrapper = shallow();
+
+ const clickableImg = wrapper.find({ nativeId: 'image-zoom-clickable-img' });
+
+ expect(clickableImg.length).toBe(1);
+ });
+
+ it('should render modal when the user presses Touchable', () => {
+ const wrapper = shallow();
+
+ wrapper.find({ nativeId: 'image-zoom-clickable-img' }).simulate('press');
+
+ const modal = wrapper.find({ nativeId: 'image-zoom-modal' });
+
+ expect(modal.length).toBe(1);
+ });
+
+ it('should close modal when onRequestClose is called', () => {
+ const wrapper = shallow();
+ wrapper.setState({ imgZoom: true });
+
+ wrapper.find({ nativeId: 'image-zoom-modal' }).simulate('requestClose');
+
+ const modal = wrapper.find({ nativeId: 'image-zoom-modal' });
+
+ expect(modal.length).toBe(0);
+ });
+
+ it('should close modal when the user presses CloseButton', () => {
+ const wrapper = shallow();
+ wrapper.setState({ imgZoom: true });
+
+ wrapper.find({ nativeId: 'image-zoom-close-button' }).simulate('press');
+
+ expect(wrapper.state('imgZoom')).toBeFalsy();
+ });
+
+ it('should close modal when the user taps the image', () => {
+ const wrapper = shallow();
+ wrapper.setState({ imgZoom: true });
+
+ wrapper.find({ nativeId: 'image-zoom-photo-view' }).simulate('tap');
+
+ expect(wrapper.state('imgZoom')).toBeFalsy();
+ });
+});
diff --git a/src/components/image-zoom.component.js b/src/components/image-zoom.component.js
index 1d6d13690..a98fc61fc 100644
--- a/src/components/image-zoom.component.js
+++ b/src/components/image-zoom.component.js
@@ -53,6 +53,9 @@ export class ImageZoom extends Component {
this.state = {
imgZoom: false,
};
+
+ this.openModal = this.openModal.bind(this);
+ this.closeModal = this.closeModal.bind(this);
}
openModal() {
@@ -68,11 +71,22 @@ export class ImageZoom extends Component {
if (this.state.imgZoom) {
return (
- this.closeModal()}>
+
- this.closeModal()} source={uri} />
+
- this.closeModal()}>
+
@@ -81,7 +95,11 @@ export class ImageZoom extends Component {
}
return (
- this.openModal()} underlayColor="transparent">
+
);