Skip to content

Commit

Permalink
test: add test for activeWallet inside ActionSelectionForm
Browse files Browse the repository at this point in the history
  • Loading branch information
MinHtet-O committed Jul 1, 2024
1 parent 338deb7 commit 9e6e56a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"blockchain:contracts:synpress": "node --experimental-modules ./tests/e2e/setup-contracts.mjs",
"blockchain:contracts:testcafe": "node --experimental-modules ./src/test/setup-contracts-testcafe.mjs",
"build": "run-s build:sitemap check-types build:css build:app",
"build:dev": "cross-env NODE_ENV=development npm run build",
"build:dev": "cross-env NODE_ENV=production npm run build",
"build:test": "cross-env NODE_ENV=test NET=local npm run build",
"build:prod": "cross-env NODE_ENV=production NET=mainnet npm run build",
"build:css": "postcss src/tailwind.css -o src/index.css",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ const defaultProps = {

describe("ActionSelectionForm", () => {
it("should display the non-editable beneficiary & holder", async () => {
await act(async () => {
const container = render(<ActionSelectionForm {...defaultProps} />);
const activeWalletComponent = container.getByTestId("activeWallet");
const holderText = within(activeWalletComponent).getByText("0xa61B056dA0084a5f391EC137583073096880C2e3");
expect(activeWalletComponent).not.toBeNull();
expect(holderText).not.toBeNull();
});
});

it("should display the active wallet", async () => {
await act(async () => {
const container = render(<ActionSelectionForm {...defaultProps} />);
const beneficiaryComponent = container.getByTestId("asset-title-owner");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ export const ActionSelectionForm: FunctionComponent<ActionSelectionFormProps> =

const handleConnectWallet = async () => {
try {
console.log("before connect to wallet 123");
await onConnectToWallet();
} catch (error: any) {
console.log("handle connect wallet error catch");
console.error(error);
handleMetamaskError(error.message, error.code);
}
};
Expand Down Expand Up @@ -151,6 +150,7 @@ export const ActionSelectionForm: FunctionComponent<ActionSelectionFormProps> =
{account ? (
<div
onClick={handleWalletInfoClick}
data-testid="activeWallet"
className="w-44 p-4 ml-auto flex items-center bg-gray-100 text-gray-800 rounded-lg shadow cursor-pointer hover:bg-gray-200 transition duration-300 ease-in-out select-none"
>
<img src={"/static/images/wallet.png"} alt="Wallet Icon" className="w-6 h-6 mr-4" />
Expand Down

0 comments on commit 9e6e56a

Please sign in to comment.