Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTallJerry committed Apr 9, 2024
1 parent 5e980c8 commit 34886cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ export default function App() {
const [svgResult, setSvgResult] = useState(null);
const [failureBanner, setFailureBanner] = useState("");

const onSubmit = (event, data) => {
if (event) {
event.preventDefault();
}
const onTextDataSubmit = (event?) => {
event?.preventDefault();
try {
setJsonResult(JSON.parse(data));
setJsonResult(JSON.parse(textData));
setFailureBanner("");
} catch (error) {
const errorMessage = `Error parsing inputted JSON: ${error.message}`;
Expand All @@ -33,9 +31,6 @@ export default function App() {
setJsonResult(null);
}
};
const onTextDataSubmit = (event?) => {
onSubmit(event || null, textData);
};

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/__tests__/MemoryModelsSample.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ describe("MemoryModelsSample", () => {

// Wait for state updates and side effects to complete
await waitFor(() => {
// expect(onSubmitMock).toHaveBeenCalledWith();
expect(setTextDataMock).toHaveBeenCalledWith(
JSON.stringify({ sample: "automation" }, null, 2)
);
expect(nextState).toEqual({ config: "config" });
expect(onSubmitMock).toHaveBeenCalled();
});
});
});

0 comments on commit 34886cc

Please sign in to comment.