Skip to content

Commit d4dc710

Browse files
committed
more tests
1 parent 544c7ff commit d4dc710

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/thirdweb/src/wallets/manager/connection-manager.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,22 @@ describe.runIf(process.env.TW_SECRET_KEY)("Connection Manager", () => {
102102
"disconnected",
103103
);
104104
});
105+
106+
it("should throw an error if wallet has no account", async () => {
107+
const manager = createConnectionManager(storage);
108+
109+
wallet = {
110+
id: "wallet-id",
111+
getAccount: vi.fn().mockReturnValue(null),
112+
subscribe: vi.fn(),
113+
disconnect: vi.fn(),
114+
switchChain: vi.fn(),
115+
getChain: vi.fn().mockReturnValue(sepolia),
116+
getConfig: vi.fn(),
117+
} as unknown as Wallet;
118+
119+
await expect(manager.handleConnection(wallet, { client })).rejects.toThrow(
120+
"Cannot set a wallet without an account as active",
121+
);
122+
});
105123
});

packages/thirdweb/src/wallets/manager/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function createConnectionManager(storage: AsyncStorage) {
125125
) => {
126126
const account = wallet.getAccount();
127127
if (!account) {
128-
throw new Error("Can not set a wallet without an account as active");
128+
throw new Error("Cannot set a wallet without an account as active");
129129
}
130130

131131
const activeWallet = await (async () => {

0 commit comments

Comments
 (0)