-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storybook): interaction tests generators for angular
- Loading branch information
Showing
47 changed files
with
777 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
packages/angular/src/generators/component-story/__snapshots__/component-story.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 25 additions & 10 deletions
35
...ges/angular/src/generators/component-story/files/__componentFileName__.stories.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
import { Meta } from '@storybook/angular'; | ||
import type { Meta, StoryObj } from '@storybook/angular'; | ||
import { <%=componentName%> } from './<%=componentFileName%>'; | ||
<% if ( interactionTests ) { %> | ||
import { within } from '@storybook/testing-library'; | ||
import { expect } from '@storybook/jest'; | ||
<% } %> | ||
|
||
export default { | ||
title: '<%=componentName%>', | ||
component: <%=componentName%> | ||
} as Meta<<%=componentName%>>; | ||
const meta: Meta<<%= componentName %>> = { | ||
component: <%= componentName %>, | ||
title: '<%= componentName %>', | ||
}; | ||
export default meta; | ||
type Story = StoryObj<<%=componentName%>>; | ||
|
||
export const Primary = { | ||
render: (args: <%=componentName%>) => ({ | ||
props: args, | ||
}), | ||
export const Primary: Story = { | ||
args: {<% for (let prop of props) { %> | ||
<%= prop.name %>: <%- prop.defaultValue %>,<% } %> | ||
}, | ||
}; | ||
}; | ||
|
||
<% if ( interactionTests ) { %> | ||
export const Heading: Story = { | ||
args: {<% for (let prop of props) { %> | ||
<%= prop.name %>: <%- prop.defaultValue %>,<% } %> | ||
}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
expect(canvas.getByText(/<%=componentNameSimple%> works!/gi)).toBeTruthy(); | ||
}, | ||
}; | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.