diff --git a/code/renderers/react/src/componentManifest/generateCodeSnippet.test.tsx b/code/renderers/react/src/componentManifest/generateCodeSnippet.test.tsx index 2b4272a0a0c8..9c8662fa2ace 100644 --- a/code/renderers/react/src/componentManifest/generateCodeSnippet.test.tsx +++ b/code/renderers/react/src/componentManifest/generateCodeSnippet.test.tsx @@ -59,6 +59,21 @@ test('Default', () => { ); }); +test('Synthesizes self-closing when no children', () => { + const input = dedent` + import type { Meta } from '@storybook/react'; + import { Button } from '@design-system/button'; + + const meta: Meta = { + component: Button, + }; + export default meta; + + export const NoChildren: Story = {}; + `; + expect(generateExample(input)).toMatchInlineSnapshot(`"const NoChildren = () => ;", - "summary": undefined, - }, - { - "description": undefined, - "name": "Secondary", - "snippet": "const Secondary = () => ;", - "summary": undefined, - }, - { - "description": undefined, - "name": "Large", - "snippet": "const Large = () => ;", - "summary": undefined, - }, - { - "description": undefined, - "name": "Small", - "snippet": "const Small = () => ;", - "summary": undefined, + "size": { + "defaultValue": { + "computed": false, + "value": "'medium'", + }, + "description": "", + "required": false, + "tsType": { + "elements": [ + { + "name": "literal", + "value": "'small'", + }, + { + "name": "literal", + "value": "'medium'", + }, + { + "name": "literal", + "value": "'large'", + }, + ], + "name": "union", + "raw": "'small' | 'medium' | 'large'", + }, }, - ], - "summary": undefined, + }, }, - "example-header": { - "description": "Description from meta and very long.", - "error": undefined, - "id": "example-header", - "import": "import { Header } from "some-package";", - "jsDocTags": { - "summary": [ - "Component summary", - ], + "stories": [ + { + "description": undefined, + "name": "Primary", + "snippet": "const Primary = () => ;\\n", + code: "const Primary = () => ;\\n", + code: "const Secondary = () =>