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

test: add test for toast #6

Merged
merged 1 commit into from
Oct 3, 2024
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 packages/ui-ingredients/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
"@sveltejs/vite-plugin-svelte": "4.0.0-next.6",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/svelte": "5.2.3",
"@testing-library/user-event": "14.5.2",
"@types/jsdom": "21.1.7",
"@untitled-theme/icons-svelte": "0.10.9",
"autoprefixer": "10.4.20",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {accordionAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Accordion from './accordion.svelte';
import {getAnatomySelector} from './utils.js';

const items = [
{value: '1', label: 'Item 1', content: 'Content 1'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {avatarAnatomy} from '$lib/index.js';
import {faker} from '@faker-js/faker';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Avatar from './avatar.svelte';
import {getAnatomySelector} from './utils.js';

const src = faker.image.avatar();
const name = faker.person.fullName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {carouselAnatomy} from '$lib/index.js';
import {faker} from '@faker-js/faker';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Carousel from './carousel.svelte';
import {getAnatomySelector} from './utils.js';

const images = Array.from({length: 5}).map(() => faker.image.url());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {checkboxAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Checkbox from './checkbox.svelte';
import {getAnatomySelector} from './utils.js';

describe('Checkbox', () => {
it.each(getAnatomySelector(checkboxAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {clipboardAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Clipboard from './clipboard.svelte';
import {getAnatomySelector} from './utils.js';

describe('Clipboard', () => {
it.each(getAnatomySelector(clipboardAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {collapsibleAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Collapsible from './collapsible.svelte';
import {getAnatomySelector} from './utils.js';

describe('Collapsible', () => {
it.each(getAnatomySelector(collapsibleAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {comboboxAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Combobox from './combobox.svelte';
import {getAnatomySelector} from './utils.js';

const items = [
{label: 'Item 1', value: '1'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {datePickerAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import DatePicker from './date-picker.svelte';
import {getAnatomySelector} from './utils.js';

describe('DatePicker', () => {
it.skip.each(getAnatomySelector(datePickerAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {dialogAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Dialog from './dialog.svelte';
import {getAnatomySelector} from './utils.js';

describe('Dialog', () => {
it.each(getAnatomySelector(dialogAnatomy))('should render %s', (selector) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {editableAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Editable from './editable.svelte';
import {getAnatomySelector} from './utils.js';

describe('Editable', () => {
it.each(getAnatomySelector(editableAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {fieldAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Field from './field.svelte';
import {getAnatomySelector} from './utils.js';

describe('Field', () => {
it.each(getAnatomySelector(fieldAnatomy))('should render %s', (selector) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {fileUploadAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import FileUpload from './file-upload.svelte';
import {getAnatomySelector} from './utils.js';

describe('FileUpload', () => {
it.each(getAnatomySelector(fileUploadAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {hoverCardAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import HoverCard from './hover-card.svelte';
import {getAnatomySelector} from './utils.js';

describe('HoverCard', () => {
it.each(getAnatomySelector(hoverCardAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {menuAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Menu from './menu.svelte';
import {getAnatomySelector} from './utils.js';

const items = [
{label: 'Item 1', value: '1'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {numberInputAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import NumberInput from './number-input.svelte';
import {getAnatomySelector} from './utils.js';

describe('NumberInput', () => {
it.each(getAnatomySelector(numberInputAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {paginationAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Pagination from './pagination.svelte';
import {getAnatomySelector} from './utils.js';

describe('Pagination', () => {
it.each(getAnatomySelector(paginationAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {pinInputAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import PinInput from './pin-input.svelte';
import {getAnatomySelector} from './utils.js';

describe('PinInput', () => {
it.each(getAnatomySelector(pinInputAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {popoverAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Popover from './popover.svelte';
import {getAnatomySelector} from './utils.js';

describe('Popover', () => {
it.each(getAnatomySelector(popoverAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {progressAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Progress from './progress.svelte';
import {getAnatomySelector} from './utils.js';

describe('Progress', () => {
it.each(getAnatomySelector(progressAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {qrCodeAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import QrCode from './qr-code.svelte';
import {getAnatomySelector} from './utils.js';

describe('QrCode', () => {
it.each(getAnatomySelector(qrCodeAnatomy))('should render %s', (selector) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {radioGroupAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import RadioGroup from './radio-group.svelte';
import {getAnatomySelector} from './utils.js';

const items = [
{value: '1', label: 'Item 1'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ratingGroupAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import RatingGroup from './rating-group.svelte';
import {getAnatomySelector} from './utils.js';

describe('RatingGroup', () => {
it.each(getAnatomySelector(ratingGroupAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {segmentGroupAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import SegmentGroup from './segment-group.svelte';
import {getAnatomySelector} from './utils.js';

const items = [
{value: '1', label: 'Item 1'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {selectAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Select from './select.svelte';
import {getAnatomySelector} from './utils.js';

const items = [
{value: '1', label: 'Option 1'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {signaturePadAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import SignaturePad from './signature-pad.svelte';
import {getAnatomySelector} from './utils.js';

describe('SignaturePad', () => {
it.each(getAnatomySelector(signaturePadAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {sliderAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Slider from './slider.svelte';
import {getAnatomySelector} from './utils.js';

describe('Slider', () => {
it.each(getAnatomySelector(sliderAnatomy))('should render %s', (selector) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {splitterAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Splitter from './splitter.svelte';
import {getAnatomySelector} from './utils.js';

describe('Splitter', () => {
it.each(getAnatomySelector(splitterAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { stepsAnatomy } from '$lib/index.js';
import { render } from '@testing-library/svelte';
import { axe } from 'vitest-axe';
import {stepsAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Steps from './steps.svelte';
import { getAnatomySelector } from './utils.js';

const items = [
{title: 'Step 1', content: 'Step 1 Content'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {switchAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Switch from './switch.svelte';
import {getAnatomySelector} from './utils.js';

describe('Switch', () => {
it.each(getAnatomySelector(switchAnatomy))('should render %s', (selector) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {tabsAnatomy} from '$lib/index.js';
import {faker} from '@faker-js/faker';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Tabs from './tabs.svelte';
import {getAnatomySelector} from './utils.js';

const items = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {tagsInputAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import TagsInput from './tags-input.svelte';
import {getAnatomySelector} from './utils.js';

describe('TagsInput', () => {
it.each(getAnatomySelector(tagsInputAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {timePickerAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import TimePicker from './time-picker.svelte';
import {getAnatomySelector} from './utils.js';

describe('TimePicker', () => {
it.each(getAnatomySelector(timePickerAnatomy))(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {timerAnatomy} from '$lib/index.js';
import {render} from '@testing-library/svelte';
import {axe} from 'vitest-axe';
import {getAnatomySelector} from '../utils.js';
import Timer from './timer.svelte';
import {getAnatomySelector} from './utils.js';

describe('Timer', () => {
it.each(getAnatomySelector(timerAnatomy))('should render %s', (selector) => {
Expand Down
27 changes: 27 additions & 0 deletions packages/ui-ingredients/src/tests/toast/toast.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts">
import {createToaster, Toast, Toaster} from '$lib/index.js';
export const toaster = createToaster({
duration: 5000,
});
</script>

<button
type="button"
onclick={() => {
toaster.create({
title: 'Title',
description: 'Description',
});
}}
aria-label="Create toast"
></button>

<Toaster {toaster}>
<Toast.Root>
<Toast.Title />
<Toast.Description />
<Toast.CloseTrigger>Close</Toast.CloseTrigger>
<Toast.ActionTrigger>Action</Toast.ActionTrigger>
</Toast.Root>
</Toaster>
Loading