-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from FluffyLabs/diff-checker
Add diffchecker
- Loading branch information
Showing
5 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { InitialState, Pvm } from "@/pvm-packages/pvm/pvm"; | ||
import ReactJsonViewCompare from "react-json-view-compare"; | ||
|
||
export type ExpectedState = InitialState & { | ||
status: Pvm["status"]; | ||
}; | ||
const actualToExpected = (actual: ReturnType<Pvm["getState"]>): ExpectedState | undefined => { | ||
if (!actual) return; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { pageMap, ...rest } = actual; | ||
return rest as ExpectedState; | ||
}; | ||
|
||
export const DiffChecker = (args: { expected?: ExpectedState; actual: ReturnType<Pvm["getState"]> }) => { | ||
const actual = actualToExpected(args.actual); | ||
|
||
if (!args.actual) return null; | ||
|
||
return <ReactJsonViewCompare oldData={args.expected} newData={actual} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module "react-json-view-compare"; |