Skip to content

Commit

Permalink
add test for Story-level tags case
Browse files Browse the repository at this point in the history
  • Loading branch information
xeho91 committed Jan 17, 2025
1 parent e1ee0c0 commit 7c600a0
Showing 1 changed file with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,54 @@ describe(createNamedExportStory.name, () => {
}) as unknown as ESTreeAST.Program
).code;

expect(stringified).toMatchInlineSnapshot(`"export const Default = { ...__stories["Default"], tags: [] };"`);
expect(stringified).toMatchInlineSnapshot(
`"export const Default = { ...__stories["Default"], tags: [] };"`
);
});

it('allows passing Story-level tags', ({ expect }) => {
const stringified = print(
createNamedExportStory({
exportName: 'Default',
nodes: {
variable: createVariableFromRuntimeStoriesCall({
storiesFunctionDeclaration: {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'Example_stories',
},
body: {
type: 'BlockStatement',
body: [],
},
params: [],
},
}),
tags: {
type: 'ArrayExpression',
elements: [
{
type: 'Literal',
value: 'autodocs',
},
{
type: 'Literal',
value: '!test',
},
],
},
},
}) as unknown as ESTreeAST.Program
).code;

expect(stringified).toMatchInlineSnapshot(
`
"export const Default = {
...__stories["Default"],
tags: ["autodocs", "!test"]
};"
`
);
});
});

0 comments on commit 7c600a0

Please sign in to comment.