Skip to content

Commit 6dafe73

Browse files
test(sharesheet): add Reddit share URL assertions
1 parent 08d93bb commit 6dafe73

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

components/dashboard/ShareSheet.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,30 @@ describe('ShareSheet', () => {
230230
});
231231
});
232232

233+
it('handles Reddit share URL correctly', async () => {
234+
render(<ShareSheet {...defaultProps} />);
235+
236+
const redditButton = screen.getByText('Reddit').closest('button');
237+
238+
fireEvent.click(redditButton!);
239+
240+
await waitFor(() => {
241+
expect(window.open).toHaveBeenCalled();
242+
});
243+
244+
expect(window.open).toHaveBeenCalledWith(
245+
expect.stringContaining('reddit.com/submit'),
246+
'_blank',
247+
'noopener,noreferrer'
248+
);
249+
250+
const calledUrl = vi.mocked(window.open).mock.calls[0][0] as string;
251+
252+
expect(calledUrl).toContain(encodeURIComponent(`/dashboard/${defaultProps.username}`));
253+
254+
expect(calledUrl).toContain('title=');
255+
});
256+
233257
it('handles Download SVG action', async () => {
234258
// Mock fetch
235259
global.fetch = vi.fn().mockResolvedValue({

story-spark-ai

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8ee415e977aa4983793e53bd06ec01eb1b3b1524

0 commit comments

Comments
 (0)