-
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.
- Loading branch information
1 parent
e878bb6
commit 68d32d6
Showing
2 changed files
with
60 additions
and
21 deletions.
There are no files selected for viewing
50 changes: 48 additions & 2 deletions
50
packages/core/src/components/rich-tooltip/rich-tooltip.spec.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 |
---|---|---|
@@ -1,3 +1,49 @@ | ||
describe('RichTooltip', () => { | ||
it.todo('test') | ||
import { newSpecPage } from '@stencil/core/testing' | ||
|
||
import { AtomRichTooltip } from './rich-tooltip' | ||
|
||
describe('AtomRichTooltip', () => { | ||
it('should render correctly', async () => { | ||
const page = await newSpecPage({ | ||
components: [AtomRichTooltip], | ||
html: `<atom-rich-tooltip element="test-element" title="Test Title" actiontext="Click me">Tooltip content</atom-rich-tooltip>`, | ||
}) | ||
|
||
expect(page.root).toEqualHtml(` | ||
<atom-rich-tooltip element="test-element" title="Test Title" actiontext="Click me" role="tooltip"> | ||
<mock:shadow-root> | ||
<atom-tooltip element="test-element" placement="top" action="hover" class="rich-tooltip"> | ||
<div class="rich-tooltip__content"> | ||
<h1 class="title">Test Title</h1> | ||
<p class="text"> | ||
<slot></slot> | ||
</p> | ||
</div> | ||
</atom-tooltip> | ||
</mock:shadow-root> | ||
Tooltip content | ||
</atom-rich-tooltip> | ||
`) | ||
}) | ||
|
||
it('should display action text when action is click', async () => { | ||
const page = await newSpecPage({ | ||
components: [AtomRichTooltip], | ||
html: `<atom-rich-tooltip element="test-element" title="Test Title" action="click" actiontext="Click me">Tooltip content</atom-rich-tooltip>`, | ||
}) | ||
|
||
expect(page.root?.shadowRoot?.querySelector('.action')).not.toBeNull() | ||
expect(page.root?.shadowRoot?.querySelector('.action')?.textContent).toBe( | ||
'Click me' | ||
) | ||
}) | ||
|
||
it('should not display action text when action is hover', async () => { | ||
const page = await newSpecPage({ | ||
components: [AtomRichTooltip], | ||
html: `<atom-rich-tooltip element="test-element" title="Test Title" action="hover" actiontext="Click me">Tooltip content</atom-rich-tooltip>`, | ||
}) | ||
|
||
expect(page.root?.shadowRoot?.querySelector('.action')).toBeNull() | ||
}) | ||
}) |
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