Skip to content

Commit

Permalink
test: dummy-wallet-app add custom button to test locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Justkant committed Oct 17, 2023
1 parent bcdd115 commit f19e382
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 4 additions & 0 deletions libs/test-utils/dummy-wallet-app/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@
background-color: #b8b8b9;
text-align: start;
}

pre {
text-align: initial;
}
20 changes: 18 additions & 2 deletions libs/test-utils/dummy-wallet-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import React, { useEffect, useMemo } from "react";
import React, { useState, useEffect, useMemo } from "react";
import { useE2EInjection } from "./hooks";
import "./App.css";
import { CustomLogger } from "@ledgerhq/live-common/wallet-api/CustomLogger/client";
import { useWalletAPIClient } from "@ledgerhq/wallet-api-client-react";
import { WalletAPIClient } from "@ledgerhq/wallet-api-client";

export default function App() {
useE2EInjection();
const { client } = useWalletAPIClient();
const { client } = useWalletAPIClient() as { client: WalletAPIClient<CustomLogger> };
useEffect(() => {
console.log(client?.custom);
});

const [res, setRes] = useState();

const testLogger = async () => {
try {
// @ts-expect-error: need to fix it in wallet-api by removing the Record
setRes(await client?.custom.log("test"));
} catch (err) {
// @ts-expect-error: err is unknown and we don't check it
setRes(err);
}
};

const params = useMemo(
() => Array.from(new URLSearchParams(window.location.search).entries()),
[],
Expand All @@ -32,6 +46,8 @@ export default function App() {
))}
</ol>
</div>
<button onClick={testLogger}>Test logger</button>
{res ? <pre>{JSON.stringify(res, null, 2)}</pre> : null}
</header>
</div>
);
Expand Down
8 changes: 5 additions & 3 deletions libs/test-utils/dummy-wallet-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import "./index.css";
import App from "./App";

function getCustomModule(client: WalletAPIClient) {
return {
logger: new CustomLogger(client),
};
return new CustomLogger(client);
// We need to improve the types to make this work better
// return {
// logger: new CustomLogger(client),
// };
}

function TransportProvider({ children }: PropsWithChildren<object>) {
Expand Down

0 comments on commit f19e382

Please sign in to comment.