Skip to content

Commit

Permalink
remove file data
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTallJerry committed Feb 28, 2024
1 parent c5e6926 commit f845562
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
8 changes: 0 additions & 8 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Container, CssBaseline, Stack } from "@mui/material";

export default function App() {
const [textData, setTextData] = useState("");
const [fileData, setFileData] = useState("");
const [jsonResult, setJsonResult] = useState(null);
const [svgResult, setSvgResult] = useState(null);

Expand All @@ -25,19 +24,12 @@ export default function App() {
onSubmit(event, textData);
};

const onFileDataSubmit = (event) => {
onSubmit(event, fileData);
};

return (
<>
<MemoryModelsTab
textData={textData}
setTextData={setTextData}
onTextDataSubmit={onTextDataSubmit}
fileData={fileData}
setFileData={setFileData}
onFileDataSubmit={onFileDataSubmit}
/>
<section>
<h2>Output</h2>
Expand Down
6 changes: 0 additions & 6 deletions demo/src/MemoryModels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from "@mui/material";

type MemoryModelsFileInputPropTypes = {
setFileData: React.Dispatch<React.SetStateAction<string>>;
setTextData: React.Dispatch<React.SetStateAction<string>>;
};
type MemoryModelsTextInputPropTypes = {
Expand All @@ -21,8 +20,6 @@ type MemoryModelsTextInputPropTypes = {
};
type MemoryModelsTabPropTypes = MemoryModelsFileInputPropTypes &
MemoryModelsTextInputPropTypes & {
fileData: string;
onFileDataSubmit: (event: React.MouseEvent<HTMLFormElement>) => void;
onTextDataSubmit: (event: React.MouseEvent<HTMLFormElement>) => void;
};

Expand All @@ -34,14 +31,12 @@ function MemoryModelsFileInput(props: MemoryModelsFileInputPropTypes) {
try {
fileReader.readAsText(uploadedFile, "UTF-8");
fileReader.onload = (event) => {
props.setFileData(uploadedFile.name);
props.setTextData(event.target.result as string);
};
} catch (error) {
console.error(
`Error parsing uploaded File as JSON: ${error.message}`
);
props.setFileData(null);
props.setTextData(null);
}
};
Expand Down Expand Up @@ -93,7 +88,6 @@ export default function MemoryModelsTab(props: MemoryModelsTabPropTypes) {
<Card sx={{ height: "400px", overflow: "auto" }}>
<Typography component="div">
<MemoryModelsFileInput
setFileData={props.setFileData}
setTextData={props.setTextData}
/>
<MemoryModelsTextInput
Expand Down
11 changes: 1 addition & 10 deletions demo/src/__tests__/MemoryModels.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ describe("MemoryModelsTab", () => {
const onSubmitMock = jest.fn((e) => e.preventDefault());
const setTextDataMock = jest.fn();

it("does not submit the form or enable the submit button with empty textData or fileData", () => {
it("does not submit the form or enable the submit button with empty textData", () => {
const textDataMock = "";
render(
<MemoryModelsTab
onFileDataSubmit={onSubmitMock}
onTextDataSubmit={onSubmitMock}
setTextData={setTextDataMock}
textData={textDataMock}
setFileData={setTextDataMock}
fileData={textDataMock}
/>
);

Expand All @@ -32,12 +29,9 @@ describe("MemoryModelsTab", () => {

render(
<MemoryModelsTab
onFileDataSubmit={onSubmitMock}
onTextDataSubmit={onSubmitMock}
setTextData={setTextDataMock}
textData={textDataMock}
setFileData={setTextDataMock}
fileData={textDataMock}
/>
);

Expand All @@ -53,12 +47,9 @@ describe("MemoryModelsTab", () => {
beforeEach(() => {
render(
<MemoryModelsTab
onFileDataSubmit={onSubmitMock}
onTextDataSubmit={onSubmitMock}
setTextData={setTextDataMock}
textData={textDataMock}
setFileData={setTextDataMock}
fileData={textDataMock}
/>
);
});
Expand Down

0 comments on commit f845562

Please sign in to comment.