Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: created tooltip component and test #5

Merged
merged 2 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export { default as DropList } from './dropList.svelte';
export { default as DropListItem } from './dropListItem.svelte';
export { default as DropListLink } from './dropListLink.svelte';
export { default as Collapsible } from './collapsible.svelte';
export { default as Tooltip } from './tooltip.svelte';
export { default as Avatar } from './avatar.svelte';
export { default as SwitchBox } from './switchBox.svelte';
export { default as SwitchBoxes } from './switchBoxes.svelte';
Expand Down
11 changes: 11 additions & 0 deletions src/lib/components/tooltip.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script lang="ts">
export let icon = 'info';
export let aria = 'info';
</script>

<button class="tooltip" aria-label={aria}>
<span class={`icon-${icon}`} aria-hidden="true" />
<span class="tooltip-popup" role="tooltip">
<slot />
</span>
</button>
9 changes: 9 additions & 0 deletions tests/unit/components/tooltip.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/svelte';
import { Tooltip } from '../../../src/lib/components';

test('shows tooltip', () => {
const { getByRole } = render(Tooltip);

expect(getByRole('tooltip')).toBeInTheDocument();
});