-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into M3-8945-update-yup-to-v1
- Loading branch information
Showing
6 changed files
with
123 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/api-v4": Added | ||
--- | ||
|
||
Linter rules for naming convention ([#11337](https://github.com/linode/manager/pull/11337)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
unit test cases for `DocsLink` component ([#11336](https://github.com/linode/manager/pull/11336)) |
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,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
Linter rules for naming convention ([#11337](https://github.com/linode/manager/pull/11337)) |
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
45 changes: 45 additions & 0 deletions
45
packages/manager/src/components/DocsLink/DocsLink.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,45 @@ | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { sendHelpButtonClickEvent } from 'src/utilities/analytics/customEventAnalytics'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { DocsLink } from './DocsLink'; | ||
|
||
import type { DocsLinkProps } from './DocsLink'; | ||
|
||
vi.mock('src/utilities/analytics/customEventAnalytics', () => ({ | ||
sendHelpButtonClickEvent: vi.fn(), | ||
})); | ||
|
||
const mockLabel = 'Custom Doc Link Label'; | ||
const mockHref = | ||
'https://techdocs.akamai.com/cloud-computing/docs/faqs-for-compute-instances'; | ||
const mockAnalyticsLabel = 'Label'; | ||
|
||
const defaultProps: DocsLinkProps = { | ||
analyticsLabel: mockAnalyticsLabel, | ||
href: mockHref, | ||
label: mockLabel, | ||
}; | ||
|
||
describe('DocsLink', () => { | ||
it('should render the label', () => { | ||
const { getByText } = renderWithTheme(<DocsLink {...defaultProps} />); | ||
expect(getByText(mockLabel)).toBeVisible(); | ||
}); | ||
|
||
it('should allow user to click the label and redirect to the url', async () => { | ||
const { getByRole } = renderWithTheme(<DocsLink {...defaultProps} />); | ||
const link = getByRole('link', { | ||
name: 'Custom Doc Link Label - link opens in a new tab', | ||
}); | ||
expect(link).toBeInTheDocument(); | ||
await userEvent.click(link); | ||
expect(sendHelpButtonClickEvent).toHaveBeenCalledTimes(1); | ||
expect(sendHelpButtonClickEvent).toHaveBeenCalledWith( | ||
mockHref, | ||
mockAnalyticsLabel | ||
); | ||
}); | ||
}); |