-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1265 from rainlanguage/2024-02-11-url-state
updating url with state
- Loading branch information
Showing
23 changed files
with
305 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/ui-components/src/__tests__/ShareChoicesButton.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { render, fireEvent, screen } from '@testing-library/svelte'; | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import ShareChoicesButton from '../lib/components/deployment/ShareChoicesButton.svelte'; | ||
|
||
describe('ShareChoicesButton', () => { | ||
const mockHandleShareChoices = vi.fn(); | ||
|
||
it('calls handleShareChoices when clicked', async () => { | ||
render(ShareChoicesButton, { | ||
props: { | ||
handleShareChoices: mockHandleShareChoices | ||
} | ||
}); | ||
|
||
await fireEvent.click(screen.getByTestId('review-choices-button')); | ||
expect(mockHandleShareChoices).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('shows and hides copied message when clicked', async () => { | ||
render(ShareChoicesButton, { | ||
props: { | ||
handleShareChoices: mockHandleShareChoices | ||
} | ||
}); | ||
|
||
// Message should not be visible initially | ||
expect(screen.queryByText('Shareable URL copied to clipboard')).not.toBeInTheDocument(); | ||
|
||
// Click the button | ||
await fireEvent.click(screen.getByTestId('review-choices-button')); | ||
|
||
// Message should be visible | ||
expect(screen.getByText('Shareable URL copied to clipboard')).toBeInTheDocument(); | ||
|
||
// Wait for 5 seconds | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
|
||
// Message should be gone | ||
expect(screen.queryByText('Shareable URL copied to clipboard')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the share button correctly', () => { | ||
render(ShareChoicesButton, { | ||
props: { | ||
handleShareChoices: mockHandleShareChoices | ||
} | ||
}); | ||
|
||
expect(screen.getByText('Share these choices')).toBeInTheDocument(); | ||
expect(screen.getByTestId('review-choices-button')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.