import React from 'react'; import { composeStories } from '@storybook/react-vite'; import { render as testRender } from '../../../vitest/render'; import * as stories from './DataList.stories'; const composedStories = composeStories(stories); describe('DataList Story Snapshots', () => { it('has tests for all stories', () => { const storyNames = Object.keys(composedStories); const testedStories = new Set([ 'Default', 'WithDescription', 'TwoColumns', 'ThreeCells', 'Sections', 'NativeHTMLItems', 'NativeHTMLItemCells', ]); const untestedStories = storyNames.filter(name => !testedStories.has(name)); expect(untestedStories).toEqual([]); }); it('renders Default story', () => { const Story = composedStories.Default; const { container } = testRender(); expect(container).toMatchInlineSnapshot(`
Apple
Banana
Cherry
Date
Elderberry
`); }); it('renders WithDescription story', () => { const Story = composedStories.WithDescription; const { container } = testRender(); expect(container).toMatchInlineSnapshot(`
Apple A sweet, edible fruit produced by an apple tree.
Banana An elongated, edible fruit produced by several kinds of large herbaceous flowering plants.
Cherry A small, round stone fruit that is typically bright or dark red.
Date The fruit of the date palm, a tree native to Northern Africa and the Middle East.
Elderberry A fruit of the elder tree, used in wines, syrups, and jams.
`); }); it('renders TwoColumns story', () => { const Story = composedStories.TwoColumns; const { container } = testRender(); expect(container).toMatchInlineSnapshot(`
Apple
A sweet, edible fruit produced by an apple tree.
Banana
An elongated, edible fruit produced by several kinds of large herbaceous flowering plants.
Cherry
A small, round stone fruit that is typically bright or dark red.
Date
The fruit of the date palm, a tree native to Northern Africa and the Middle East.
Elderberry
A fruit of the elder tree, used in wines, syrups, and jams.
`); }); it('renders ThreeCells story', () => { const Story = composedStories.ThreeCells; const { container } = testRender(); expect(container).toMatchInlineSnapshot(`
Apple A sweet, edible fruit produced by an apple tree.
Banana An elongated, edible fruit produced by several kinds of large herbaceous flowering plants.
Cherry A small, round stone fruit that is typically bright or dark red.
Date The fruit of the date palm, a tree native to Northern Africa and the Middle East.
Elderberry A fruit of the elder tree, used in wines, syrups, and jams.
`); }); it('renders Sections story', () => { const Story = composedStories.Sections; const { container } = testRender(); expect(container).toMatchInlineSnapshot(`
Select all
Fruits
Apple
Banana
Cherry
Date
Elderberry
Vegetables
Carrot
Broccoli
Spinach
Potato
Tomato
`); }); it('renders NativeHTMLItems story', () => { const Story = composedStories.NativeHTMLItems; const { container } = testRender(); expect(container).toMatchInlineSnapshot(`
HTML Anchor Element with href Anchor HTML Anchor Element (with no href) Anchor + aria-disabled HTML Anchor Element (with no href) Anchor + data-disabled
HTML Div Element Div
HTML Div Element Div + aria-disabled
HTML Div Element Div + data-disabled
`); }); it('renders NativeHTMLItemCells story', () => { const Story = composedStories.NativeHTMLItemCells; const { container } = testRender(); expect(container).toMatchInlineSnapshot(`
Active item Description
Disabled item Description
Disabled item Description
`); }); });