-
Notifications
You must be signed in to change notification settings - Fork 25
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 #382 from rebeccaalpert/response-action-clicked
feat(ResponseActions): Add click state
- Loading branch information
Showing
8 changed files
with
284 additions
and
51 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
52 changes: 52 additions & 0 deletions
52
packages/module/src/ResponseActions/ResponseActionButton.test.tsx
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 React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { DownloadIcon } from '@patternfly/react-icons'; | ||
import ResponseActionButton from './ResponseActionButton'; | ||
|
||
describe('ResponseActionButton', () => { | ||
it('renders aria-label correctly if not clicked', () => { | ||
render(<ResponseActionButton icon={<DownloadIcon />} ariaLabel="Download" clickedAriaLabel="Downloaded" />); | ||
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy(); | ||
}); | ||
it('renders aria-label correctly if clicked', () => { | ||
render( | ||
<ResponseActionButton icon={<DownloadIcon />} ariaLabel="Download" clickedAriaLabel="Downloaded" isClicked /> | ||
); | ||
expect(screen.getByRole('button', { name: 'Downloaded' })).toBeTruthy(); | ||
}); | ||
it('renders tooltip correctly if not clicked', async () => { | ||
render( | ||
<ResponseActionButton icon={<DownloadIcon />} tooltipContent="Download" clickedTooltipContent="Downloaded" /> | ||
); | ||
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy(); | ||
// clicking here just triggers the tooltip; in this button, the logic is divorced from whether it is actually clicked | ||
await userEvent.click(screen.getByRole('button', { name: 'Download' })); | ||
expect(screen.getByRole('tooltip', { name: 'Download' })).toBeTruthy(); | ||
}); | ||
it('renders tooltip correctly if clicked', async () => { | ||
render( | ||
<ResponseActionButton | ||
icon={<DownloadIcon />} | ||
tooltipContent="Download" | ||
clickedTooltipContent="Downloaded" | ||
isClicked | ||
/> | ||
); | ||
expect(screen.getByRole('button', { name: 'Downloaded' })).toBeTruthy(); | ||
// clicking here just triggers the tooltip; in this button, the logic is divorced from whether it is actually clicked | ||
await userEvent.click(screen.getByRole('button', { name: 'Downloaded' })); | ||
expect(screen.getByRole('tooltip', { name: 'Downloaded' })).toBeTruthy(); | ||
}); | ||
it('if clicked variant for tooltip is not supplied, it uses the default', async () => { | ||
render(<ResponseActionButton icon={<DownloadIcon />} tooltipContent="Download" isClicked />); | ||
// clicking here just triggers the tooltip; in this button, the logic is divorced from whether it is actually clicked | ||
await userEvent.click(screen.getByRole('button', { name: 'Download' })); | ||
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy(); | ||
}); | ||
it('if clicked variant for aria label is not supplied, it uses the default', async () => { | ||
render(<ResponseActionButton icon={<DownloadIcon />} ariaLabel="Download" isClicked />); | ||
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy(); | ||
}); | ||
}); |
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
Oops, something went wrong.