From 5341ec7cb8ee755c967250e98b13f4b5e972d9ad Mon Sep 17 00:00:00 2001 From: Julia Afeltra Date: Thu, 8 Aug 2024 17:25:15 -0400 Subject: [PATCH] Rename CodeMirrorComponent -> CodeEditor and ConsoleComponent -> Console --- src/App.jsx | 4 +-- ...CodeMirrorComponent.jsx => CodeEditor.jsx} | 4 +-- .../{ConsoleComponent.jsx => Console.jsx} | 0 src/components/FSHControls.jsx | 4 +-- src/components/FSHOutput.jsx | 4 +-- src/components/JSONOutput.jsx | 4 +-- ...CodeMirrorComponent.css => CodeEditor.css} | 0 ...Component.test.jsx => CodeEditor.test.jsx} | 28 ++++++++----------- ...oleComponent.test.jsx => Console.test.jsx} | 11 +++----- src/tests/components/JSONOutput.test.jsx | 2 +- 10 files changed, 26 insertions(+), 35 deletions(-) rename src/components/{CodeMirrorComponent.jsx => CodeEditor.jsx} (99%) rename src/components/{ConsoleComponent.jsx => Console.jsx} (100%) rename src/style/{CodeMirrorComponent.css => CodeEditor.css} (100%) rename src/tests/components/{CodeMirrorComponent.test.jsx => CodeEditor.test.jsx} (79%) rename src/tests/components/{ConsoleComponent.test.jsx => Console.test.jsx} (77%) diff --git a/src/App.jsx b/src/App.jsx index 5bd7a36e..210f8c4d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -10,7 +10,7 @@ import { expandLink } from './utils/BitlyWorker'; import TopBar from './components/TopBar'; import JSONOutput from './components/JSONOutput'; import FSHOutput from './components/FSHOutput'; -import ConsoleComponent from './components/ConsoleComponent'; +import Console from './components/Console'; import FSHControls from './components/FSHControls'; import theme from './theme'; @@ -420,7 +420,7 @@ export default function App(props) {
- ({ } })); -export default function CodeMirrorComponent(props) { +export default function CodeEditor(props) { const classes = useStyles(); const expandedConsoleContext = useContext(ExpandedConsoleContext); const [drawerOpen, setDrawerOpen] = useState(true); diff --git a/src/components/ConsoleComponent.jsx b/src/components/Console.jsx similarity index 100% rename from src/components/ConsoleComponent.jsx rename to src/components/Console.jsx diff --git a/src/components/FSHControls.jsx b/src/components/FSHControls.jsx index a74b728b..edceb246 100644 --- a/src/components/FSHControls.jsx +++ b/src/components/FSHControls.jsx @@ -31,7 +31,7 @@ import { import { runSUSHI, runGoFSH } from '../utils/FSHHelpers'; import { sliceDependency } from '../utils/helpers'; import { TreeView, TreeItem } from '@material-ui/lab'; -import CodeMirrorComponent from './CodeMirrorComponent'; +import CodeEditor from './CodeEditor'; const useStyles = makeStyles((theme) => ({ box: { @@ -431,7 +431,7 @@ export default function FSHControls(props) { - - ({ @@ -406,7 +406,7 @@ export default function JSONOutput(props) { return ( <> - { @@ -16,7 +16,7 @@ afterEach(() => { }); it('Renders initial text in the editor', () => { - const { getByText } = render(, container); + const { getByText } = render(, container); const textElement = getByText(/Edit FSH here!/i); expect(textElement).toBeInTheDocument(); @@ -25,7 +25,7 @@ it('Renders initial text in the editor', () => { it('Renders a drawer when one is provided in props', () => { const renderDrawer = () =>
Simple drawer contents
; const { getByText, getByRole } = render( - , + , container ); const drawerText = getByText(/simple drawer contents/i); @@ -37,7 +37,7 @@ it('Renders a drawer when one is provided in props', () => { it('Drawer can be collapsed and expanded', async () => { const renderDrawer = () =>
Simple drawer contents
; const { getByRole, queryByRole, getByTestId } = render( - , + , container ); let drawer = getByTestId('editor-drawer'); @@ -64,16 +64,13 @@ it('Drawer can be collapsed and expanded', async () => { }); it('Editor wraps when text wrapping is true', async () => { - const { container: renderContainer } = render( - , - container - ); + const { container: renderContainer } = render(, container); expect(renderContainer.querySelector('.CodeMirror-wrap')).toBeInTheDocument(); }); it('Editor does not wrap when text wrapping is false', async () => { const { container: renderContainer } = render( - , + , container ); expect(renderContainer.querySelector('.CodeMirror-wrap')).not.toBeInTheDocument(); @@ -81,7 +78,7 @@ it('Editor does not wrap when text wrapping is false', async () => { it('Does not renders a drawer or expand button when one is not provided in props', () => { // No renderDrawer prop passed in - const { queryByRole } = render(, container); + const { queryByRole } = render(, container); const expandButton = queryByRole('button', { name: /expand/i }); const collapseButton = queryByRole('button', { name: /collapse/i }); expect(expandButton).not.toBeInTheDocument(); @@ -93,7 +90,7 @@ it('Renders action buttons for specified actions', () => { const saveMock = vi.fn(); const deleteMock = vi.fn(); const { getByRole } = render( - , + , container ); @@ -108,7 +105,7 @@ it('Renders action buttons for specified actions', () => { it('Does not render action buttons for unspecified actions', () => { const deleteMock = vi.fn(); - const { queryByRole } = render(, container); + const { queryByRole } = render(, container); const copyButton = queryByRole('button', { name: /copy/i }); const saveButton = queryByRole('button', { name: /save/i }); @@ -122,7 +119,7 @@ it('Does not render action buttons for unspecified actions', () => { it('Renders Share option for fsh mode', () => { // set mode to fsh - const { getByRole } = render(, container); + const { getByRole } = render(, container); const shareButton = getByRole('button', { name: /share fsh/i }); expect(shareButton).toBeInTheDocument(); @@ -130,10 +127,7 @@ it('Renders Share option for fsh mode', () => { it('Does not render Share option for non-fsh mode', () => { // mode is anything but fsh - const { queryByRole } = render( - , - container - ); + const { queryByRole } = render(, container); const shareButton = queryByRole('button', { name: /share fsh/i }); expect(shareButton).not.toBeInTheDocument(); diff --git a/src/tests/components/ConsoleComponent.test.jsx b/src/tests/components/Console.test.jsx similarity index 77% rename from src/tests/components/ConsoleComponent.test.jsx rename to src/tests/components/Console.test.jsx index 8e858f2b..2751d9a9 100644 --- a/src/tests/components/ConsoleComponent.test.jsx +++ b/src/tests/components/Console.test.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import { unmountComponentAtNode } from 'react-dom'; -import ConsoleComponent from '../../components/ConsoleComponent'; +import Console from '../../components/Console'; let container = null; beforeEach(() => { @@ -16,7 +16,7 @@ afterEach(() => { }); it('Renders with the appropriate label', () => { - const { getByText } = render(, container); + const { getByText } = render(, container); const textElement = getByText('Console'); expect(textElement).toBeInTheDocument(); @@ -25,10 +25,7 @@ it('Renders with the appropriate label', () => { it('Renders with proper messages in the console', () => { const infoMessages = ['Hello', 'Goodbye', 'How are you?']; - const { getByText, queryByText } = render( - , - container - ); + const { getByText, queryByText } = render(, container); const textElement1 = getByText(/Hello/i); const textElement2 = getByText(/Goodbye/i); const textElement3 = getByText(/How are you\?/i); @@ -45,7 +42,7 @@ it('Renders error and warning labels when passed in as messages', () => { const problemMessages = ['error foo', 'error bar', 'warning foo', 'warning bar']; const { queryByText } = render( - , + , container ); const successLabel = queryByText(/Success!/i); diff --git a/src/tests/components/JSONOutput.test.jsx b/src/tests/components/JSONOutput.test.jsx index 881a7d2d..c5590386 100644 --- a/src/tests/components/JSONOutput.test.jsx +++ b/src/tests/components/JSONOutput.test.jsx @@ -33,7 +33,7 @@ it('Renders with the proper text and updates with proper text when loading', () expect(loadingPlaceholderText).toBeInTheDocument(); }); -// TODO: CodeMirrorComponent doesn't get the package text properly - not sure why +// TODO: CodeEditor doesn't get the package text properly - not sure why it.skip('Renders with the first profile when text is an object (SUSHI Package)', async () => { const { getByText } = render(