-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature - Added content prop to Tooltips with the possibility to rend…
…er ReactNode (#77) * ci: Fixed chromatic workflow's name * feat: added content prop to Tooltip.Hover * feat: add content prop to Tooltip.Close * feat: added content prop to Tooltip.Step * test: added clsx mock to jest setup * test: tests for tooltip Hover component * test: tests for Tooltip Close component * test: tests for Tooltip Step component * docs: updated Tooltip Hover story * docs: updated Tooltip Close story * docs: updated Tooltip Step story --------- Co-authored-by: Leandro Pedroso <lpedroso@meudroz.com>
- Loading branch information
1 parent
cdc23fb
commit 2f6f0cc
Showing
11 changed files
with
409 additions
and
81 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Publish Github Packages | ||
name: Publish Chromatic | ||
|
||
on: | ||
release: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
import '@testing-library/jest-dom/extend-expect' | ||
import clsx from 'clsx' | ||
|
||
global.ResizeObserver = jest.fn().mockImplementation(() => ({ | ||
observe: jest.fn(), | ||
unobserve: jest.fn(), | ||
disconnect: jest.fn(), | ||
})) | ||
|
||
jest.mock('clsx', () => { | ||
return { | ||
clsx: jest.fn().mockImplementation(() => clsx), | ||
} | ||
}) |
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 |
---|---|---|
@@ -1,23 +1,63 @@ | ||
import { Tooltip } from '@library' | ||
import { render, screen } from '@testing-library/react' | ||
import { clsx } from 'clsx' | ||
|
||
jest.mock('clsx', () => { | ||
return { | ||
clsx: jest.fn().mockImplementation(() => clsx), | ||
} | ||
}) | ||
import { fireEvent, render, screen, waitFor } from '@testing-library/react' | ||
|
||
// Testes limitados por conta do Radix | ||
describe('TooltipClose tests', () => { | ||
it('Should render a TooltipClose element', () => { | ||
render( | ||
<Tooltip.Close text="Close" data-testid="element"> | ||
<div>Hello</div> | ||
</Tooltip.Close> | ||
<Tooltip.Close content="Close"> | ||
<div data-testid="element">Hello</div> | ||
</Tooltip.Close>, | ||
) | ||
const element = screen.getByTestId('element') | ||
|
||
expect(element).toBeInTheDocument() | ||
}) | ||
|
||
it('Should render a text with the prop "content"', async () => { | ||
render( | ||
<Tooltip.Close content="Text1"> | ||
<div data-testid="element">Hello</div> | ||
</Tooltip.Close>, | ||
) | ||
const element = screen.getByTestId('element') | ||
fireEvent.click(element) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByRole('dialog')).toHaveTextContent('Text1') | ||
}) | ||
}) | ||
|
||
it('Should render a ReactNode content with the prop "content"', async () => { | ||
render( | ||
<Tooltip.Close content={<span data-testid="content">Text1</span>}> | ||
<div data-testid="element">Hello</div> | ||
</Tooltip.Close>, | ||
) | ||
const element = screen.getByTestId('element') | ||
fireEvent.click(element) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByRole('dialog')).toContainHTML( | ||
'<span data-testid="content">Text1</span>', | ||
) | ||
}) | ||
}) | ||
|
||
/** | ||
* @deprecated - Teste para uma propriedade deprecated | ||
*/ | ||
it('Should render a text with the prop "text"', async () => { | ||
render( | ||
<Tooltip.Close text="Text1"> | ||
<div data-testid="element">Hello</div> | ||
</Tooltip.Close>, | ||
) | ||
const element = screen.queryByTestId('element') | ||
const element = screen.getByTestId('element') | ||
fireEvent.click(element) | ||
|
||
expect(element).toBeDefined() | ||
await waitFor(() => { | ||
expect(screen.getByRole('dialog')).toHaveTextContent('Text1') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.