Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-jake committed Jan 8, 2025
1 parent a01ee7f commit 4759b97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ describe('Communicator', () => {

const popup = await communicator.waitForPopupLoaded();

expect(openPopup).toHaveBeenCalledWith(new URL(CB_KEYS_URL));
expect(openPopup).toHaveBeenCalledWith(
new URL(CB_KEYS_URL),
expect.stringContaining('wallet_')
);
expect(mockPopup.postMessage).toHaveBeenNthCalledWith(
1,
{
Expand Down
8 changes: 5 additions & 3 deletions packages/wallet-sdk/src/util/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ vi.mock('./checkCrossOriginOpenerPolicy');

const mockOrigin = 'http://localhost';

const mockId = 'wallet_123';

describe('PopupManager', () => {
beforeAll(() => {
global.window = Object.create(window);
Expand All @@ -32,12 +34,12 @@ describe('PopupManager', () => {
const url = new URL('https://example.com');
(window.open as Mock).mockReturnValue({ focus: vi.fn() });

const popup = openPopup(url);
const popup = openPopup(url, mockId);

expect(window.open).toHaveBeenNthCalledWith(
1,
url,
'Smart Wallet',
mockId,
'width=420, height=540, left=302, top=114'
);
expect(popup.focus).toHaveBeenCalledTimes(1);
Expand All @@ -51,7 +53,7 @@ describe('PopupManager', () => {
it('should throw an error if popup fails to open', () => {
(window.open as Mock).mockReturnValue(null);

expect(() => openPopup(new URL('https://example.com'))).toThrow(
expect(() => openPopup(new URL('https://example.com'), mockId)).toThrow(
standardErrors.rpc.internal('Pop up window failed to open')
);
});
Expand Down

0 comments on commit 4759b97

Please sign in to comment.