Skip to content

Commit 934c92f

Browse files
author
WinHome Test
committed
test(ShareSheet): verify navigator.share is called
1 parent 6840ddd commit 934c92f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

components/dashboard/ShareSheet.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,27 @@ describe('ShareSheet', () => {
163163
expect(defaultProps.onClose).toHaveBeenCalled();
164164
});
165165

166+
it('handles Share via OS Sheet action', async () => {
167+
const shareMock = vi.fn().mockResolvedValue(undefined);
168+
Object.assign(navigator, {
169+
share: shareMock,
170+
});
171+
render(<ShareSheet {...defaultProps} />);
172+
const shareButton = screen.getByText('Share via OS Sheet').closest('button');
173+
fireEvent.click(shareButton!);
174+
await waitFor(() => {
175+
expect(shareMock).toHaveBeenCalled();
176+
});
177+
178+
expect(shareMock).toHaveBeenCalledWith(
179+
expect.objectContaining({
180+
title: expect.any(String),
181+
text: expect.any(String),
182+
url: expect.any(String),
183+
})
184+
);
185+
});
186+
166187
it('handles Download PNG action', async () => {
167188
render(<ShareSheet {...defaultProps} />);
168189

0 commit comments

Comments
 (0)