diff --git a/src/components/CodeViewer.js b/src/components/CodeViewer.js
index 3cae8d87..ee47e819 100644
--- a/src/components/CodeViewer.js
+++ b/src/components/CodeViewer.js
@@ -1,5 +1,11 @@
import React, { Component } from 'react';
-import { Button, Modal } from 'semantic-ui-react';
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ Link,
+} from '@material-ui/core';
import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { hot } from 'react-hot-loader';
@@ -12,6 +18,14 @@ import 'brace/theme/monokai';
const mapStateToProps = ({ code }) => ({ code });
class CodeViewer extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ open: false,
+ };
+ }
+
stripCode = () => {
const { code } = this.props;
@@ -22,44 +36,53 @@ class CodeViewer extends Component {
return '';
}
+ handleOpen = () => {
+ this.setState({
+ open: true,
+ });
+ }
+
+ handleClose = () => {
+ this.setState({
+ open: false,
+ });
+ }
+
render() {
const { children } = this.props;
+ const { open } = this.state;
return (
-
- { children }
-
- )}
- >
-
-
- {' '}
-
- JavaScript
-
- :
-
-
-
-
-
+ <>
+
+
+ >
);
}
}
diff --git a/src/components/__tests__/CodeViewer.test.js b/src/components/__tests__/CodeViewer.test.js
index 9e5c560b..ece00f1b 100644
--- a/src/components/__tests__/CodeViewer.test.js
+++ b/src/components/__tests__/CodeViewer.test.js
@@ -1,6 +1,7 @@
import React from 'react';
-import { mount } from 'enzyme';
+import { shallow } from 'enzyme';
import configureStore from 'redux-mock-store';
+import { Button, Dialog } from '@material-ui/core';
import CodeViewer from '../CodeViewer';
@@ -13,11 +14,11 @@ describe('The CodeViewer component', () => {
jsCode: 'test code',
},
});
- const wrapper = mount(
+ const wrapper = shallow(
Show Me The Code!
,
- );
+ ).dive().dive();
expect(wrapper).toMatchSnapshot();
});
@@ -27,11 +28,20 @@ describe('The CodeViewer component', () => {
jsCode: null,
},
});
- const wrapper = mount(
+ const wrapper = shallow(
Show Me The Code!
,
- );
- expect(wrapper).toMatchSnapshot();
+ ).dive().dive();
+
+ expect(wrapper.state('open')).toBe(false);
+
+ wrapper.find(Button).simulate('click');
+
+ expect(wrapper.state('open')).toBe(true);
+
+ wrapper.find(Dialog).simulate('close');
+
+ expect(wrapper.state('open')).toBe(false);
});
});
diff --git a/src/components/__tests__/__snapshots__/CodeViewer.test.js.snap b/src/components/__tests__/__snapshots__/CodeViewer.test.js.snap
index 1eac38ab..da1fa147 100644
--- a/src/components/__tests__/__snapshots__/CodeViewer.test.js.snap
+++ b/src/components/__tests__/__snapshots__/CodeViewer.test.js.snap
@@ -1,251 +1,80 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`The CodeViewer component handles blank code with no errors 1`] = `
-
-
-
- Show Me The Code!
-
- }
- >
- }
- onClose={[Function]}
- onMount={[Function]}
- onOpen={[Function]}
- onUnmount={[Function]}
- openOnTriggerClick={true}
- trigger={
-
- }
- >
- [
-
- ,
- }
- }
- >
-
- Show Me The Code!
- ,
- }
- }
- >
-
-
- ]
-
-
-
-
-
-
-
-`;
-
exports[`The CodeViewer component renders on the page with no errors 1`] = `
-
-
+
+ Show Me The Code!
+
+
-
- Show Me The Code!
-
- }
+
+
+
+
+ JavaScript
+
+ :
+
+
- }
- onClose={[Function]}
- onMount={[Function]}
- onOpen={[Function]}
- onUnmount={[Function]}
- openOnTriggerClick={true}
- trigger={
-
+
- [
-
- ,
- }
- }
- >
-
- Show Me The Code!
- ,
- }
- }
- >
-
-
- ]
-
-
-
-
-
-
-
+ enableBasicAutocompletion={false}
+ enableLiveAutocompletion={false}
+ enableSnippets={false}
+ focus={false}
+ fontSize={14}
+ height="500px"
+ highlightActiveLine={true}
+ maxLines={null}
+ minLines={null}
+ mode="javascript"
+ name="ace-editor"
+ navigateToFileEnd={true}
+ onChange={null}
+ onLoad={null}
+ onPaste={null}
+ onScroll={null}
+ placeholder={null}
+ readOnly={true}
+ scrollMargin={
+ Array [
+ 0,
+ 0,
+ 0,
+ 0,
+ ]
+ }
+ setOptions={Object {}}
+ showGutter={true}
+ showPrintMargin={true}
+ style={Object {}}
+ tabSize={4}
+ theme="github"
+ value="test code"
+ width="750px"
+ wrapEnabled={false}
+ />
+
+
+
`;