@@ -79,7 +79,7 @@ If you use the composed story (e.g. PrimaryButton), the component will render wi
79
79
import { render , screen } from ' @testing-library/angular' ;
80
80
import {
81
81
composeStories ,
82
- createMountableStoryComponent ,
82
+ createMountable ,
83
83
} from ' @storybook/testing-angular' ;
84
84
import * as stories from ' ./button.stories' ; // import all stories from the stories file
85
85
import Meta from ' ./button.stories' ;
@@ -89,9 +89,8 @@ const { Primary, Secondary } = composeStories(stories);
89
89
90
90
describe (' button' , () => {
91
91
it (' renders primary button with default args' , () => {
92
- const { component, applicationConfig } = createMountableStoryComponent (
93
- Primary ({}, {} as any ),
94
- Meta .component ,
92
+ const { component, applicationConfig } = createMountable (
93
+ Primary ({}, {} as any )
95
94
);
96
95
await render (component , { providers: applicationConfig .providers });
97
96
const buttonElement = screen .getByText (
@@ -101,9 +100,8 @@ describe('button', () => {
101
100
});
102
101
103
102
it (' renders primary button with overriden props' , () => {
104
- const { component, applicationConfig } = createMountableStoryComponent (
105
- Primary ({ label: ' Hello world' }, {} as any ),
106
- Meta .component ,
103
+ const { component, applicationConfig } = createMountable (
104
+ Primary ({ label: ' Hello world' }, {} as any )
107
105
); // you can override props and they will get merged with values from the Story's args
108
106
await render (component , { providers: applicationConfig .providers });
109
107
const buttonElement = screen .getByText (/ Hello world/ i );
@@ -120,7 +118,7 @@ You can use `composeStory` if you wish to apply it for a single story rather tha
120
118
import { render , screen } from ' @testing-library/angular' ;
121
119
import {
122
120
composeStory ,
123
- createMountableStoryComponent ,
121
+ createMountable ,
124
122
} from ' @storybook/testing-angular' ;
125
123
import Meta , { Primary as PrimaryStory } from ' ./button.stories' ;
126
124
@@ -130,9 +128,8 @@ const Primary = composeStory(PrimaryStory, Meta);
130
128
describe (' button' , () => {
131
129
it (' onclick handler is called' , async () => {
132
130
const onClickSpy = jasmine .createSpy ();
133
- const { component, applicationConfig } = createMountableStoryComponent (
134
- Primary ({ onClick: onClickSpy }, {} as any ),
135
- Meta .component ,
131
+ const { component, applicationConfig } = createMountable (
132
+ Primary ({ onClick: onClickSpy }, {} as any )
136
133
);
137
134
await render (component , { provider: applicationConfig .provider });
138
135
const buttonElement = screen .getByText (Primary .args ?.label ! );
@@ -150,7 +147,7 @@ The components returned by `composeStories` or `composeStory` not only can be re
150
147
import { render , screen } from ' @testing-library/angular' ;
151
148
import {
152
149
composeStory ,
153
- createMountableStoryComponent ,
150
+ createMountable ,
154
151
} from ' @storybook/testing-angular' ;
155
152
import * as stories from ' ./button.stories' ;
156
153
import Meta from ' ./button.stories' ;
@@ -159,10 +156,7 @@ const { Primary } = composeStories(stories);
159
156
160
157
describe (' button' , () => {
161
158
it (' reuses args from composed story' , async () => {
162
- const { component, applicationConfig } = createMountableStoryComponent (
163
- Primary ({}, {} as any ),
164
- Meta .component
165
- );
159
+ const { component, applicationConfig } = createMountable (Primary ({}, {} as any ));
166
160
await render (component , { providers: applicationConfig .providers });
167
161
expect (screen .getByText (Primary .args ?.label ! )).not .toBeNull ();
168
162
});
0 commit comments