Skip to content

Commit

Permalink
Added test + typescript support (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonahPlusPlus authored Nov 12, 2024
1 parent 546e301 commit fd2dfec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/frameworks/solid-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "storybook-solidjs-vite",
"type": "module",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.5",
"description": "Storybook for SolidJS and Vite: Develop SolidJS in isolation with Hot Reloading.",
"keywords": [
"storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/renderers/solid/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "storybook-solidjs",
"type": "module",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.5",
"description": "Storybook SolidJS renderer",
"keywords": [
"storybook"
Expand Down
13 changes: 13 additions & 0 deletions packages/renderers/solid/src/docs/sourceDecorator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ test('component with method prop', () => {
`);
});

test('component with typescript', () => {
const newSrc = generateSolidSource(
'Component',
'{ args: { double: (x: number) => { return x * 2; } } }',
);

expect(newSrc).toMatchInlineSnapshot(`
"<Component double={(x: number) => {
return x * 2;
}} />"
`);
});

test('component missing story config', () => {
const newSrc = () => generateSolidSource('Component', '5 + 4');

Expand Down
2 changes: 1 addition & 1 deletion packages/renderers/solid/src/docs/sourceDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ interface SolidProps {
* The source code will be in the form of a `Story` object.
*/
function parseProps(src: string): SolidProps {
const ast = parser.parseExpression(src, { plugins: ['jsx'] });
const ast = parser.parseExpression(src, { plugins: ['jsx', 'typescript'] });
if (ast.type != 'ObjectExpression') throw 'Expected `ObjectExpression` type';
// Find args property.
const args_prop = ast.properties.find((v: any) => {
Expand Down

0 comments on commit fd2dfec

Please sign in to comment.