From 8af4130891344f7efea0a8d4c604590f55067a3b Mon Sep 17 00:00:00 2001 From: Valazan Date: Wed, 22 Nov 2023 11:57:42 +0100 Subject: [PATCH] test: disconnect button in connected address modal --- .../test/connect-button-with-modal.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/dapp-kit-ui/test/connect-button-with-modal.test.ts b/packages/dapp-kit-ui/test/connect-button-with-modal.test.ts index d9789530..b683f39d 100644 --- a/packages/dapp-kit-ui/test/connect-button-with-modal.test.ts +++ b/packages/dapp-kit-ui/test/connect-button-with-modal.test.ts @@ -1,4 +1,4 @@ -import { beforeEach, describe, expect, it } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { ConnectButton, @@ -61,6 +61,7 @@ describe('connect-button-with-modal', () => { // testing the connected address badge + // mock a connection to the wallet by setting the address element.address = '0x00000'; const connectedAddressBadgeWithModal = @@ -73,12 +74,19 @@ describe('connect-button-with-modal', () => { expect(connectedAddressBadge).toBeDefined(); + // open the connected address modal connectedAddressBadge.shadowRoot?.querySelector('div')?.click(); - const ConnectedAddressModal = + const connectedAddressModal = (await elementQueries.getConnectedAddressModal()) as ConnectedAddressModal; - expect(ConnectedAddressModal).toBeDefined(); - expect(ConnectedAddressModal.open).toBe(true); + expect(connectedAddressModal).toBeDefined(); + + // disconnect from the wallet by clicking the disconnect button + connectedAddressModal.shadowRoot?.querySelector('button')?.click(); + + await element.updateComplete; + + expect(element.address).toBeUndefined(); }); });