Skip to content

Commit 8b588ac

Browse files
committed
update transform tests to match updated Example.stories.svelte
1 parent 4ddf216 commit 8b588ac

File tree

4 files changed

+33
-61
lines changed

4 files changed

+33
-61
lines changed

src/compiler/post-transform/define-meta/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ describe(createMetaVariableDeclaration.name, () => {
102102
component: Example,
103103
tags: ['autodocs'],
104104
args: {
105-
onclick: action('onclick'),
106-
onmouseenter: action('onmouseenter'),
107-
onmouseleave: action('onmouseleave')
105+
onclick: fn(),
106+
onmouseenter: fn(),
107+
onmouseleave: fn()
108108
},
109109
parameters: {
110110
docs: {

src/compiler/post-transform/index.test.ts

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe(transformStoriesCode.name, () => {
5151
Example_stories[$.FILENAME] = 'tests/stories/Example.stories.svelte';
5252
5353
import * as $ from 'svelte/internal/client';
54-
import { action } from '@storybook/addon-actions';
54+
import { fn } from 'storybook/test';
5555
import { defineMeta } from '@storybook/addon-svelte-csf';
5656
import Example from './Example.svelte';
5757
@@ -69,9 +69,9 @@ describe(transformStoriesCode.name, () => {
6969
component: Example,
7070
tags: ['autodocs'],
7171
args: {
72-
onclick: action('onclick'),
73-
onmouseenter: action('onmouseenter'),
74-
onmouseleave: action('onmouseleave')
72+
onclick: fn(),
73+
onmouseenter: fn(),
74+
onmouseleave: fn()
7575
},
7676
parameters: {
7777
docs: {
@@ -83,24 +83,16 @@ describe(transformStoriesCode.name, () => {
8383
};
8484
const { Story } = defineMeta($__meta);
8585
86-
var root_2 = $.add_locations($.template(\`<p> </p> <p> </p> <br>\`, 1), Example_stories[$.FILENAME], [[41, 2], [42, 2], [42, 44]]);
86+
var root_2 = $.add_locations($.template(\`<p> </p> <br>\`, 1), Example_stories[$.FILENAME], [[37, 2], [37, 44]]);
8787
var root = $.add_locations($.template(\`<!> <!> <!> <!> <!>\`, 1), Example_stories[$.FILENAME], []);
8888
8989
function Example_stories($$anchor, $$props) {
9090
$.check_target(new.target);
9191
$.push($$props, true, Example_stories);
9292
93-
const template = $.wrap_snippet(Example_stories, function ($$anchor, $$arg0, context = $.noop) {
93+
const template = $.wrap_snippet(Example_stories, function ($$anchor, args = $.noop, context = $.noop) {
9494
$.validate_snippet_args(...arguments);
9595
96-
let _ = () => $$arg0?.().children;
97-
98-
_();
99-
100-
let args = () => $.exclude_from_object($$arg0?.(), ['children']);
101-
102-
args();
103-
10496
var fragment = $.comment();
10597
var node = $.first_child(fragment);
10698
@@ -113,19 +105,13 @@ describe(transformStoriesCode.name, () => {
113105
114106
$.reset(p);
115107
116-
var p_1 = $.sibling(p, 2);
117-
var text_1 = $.child(p_1, true);
118-
119-
$.reset(p_1);
120-
121-
var text_2 = $.sibling(p_1);
108+
var text_1 = $.sibling(p);
122109
123110
$.next();
124111
125112
$.template_effect(() => {
126-
$.set_text(text, args().id);
127-
$.set_text(text_1, context().name);
128-
$.set_text(text_2, \` You clicked: \${$.get(count) ?? ''}\`);
113+
$.set_text(text, context().name);
114+
$.set_text(text_1, \` You clicked: \${$.get(count) ?? ''}\`);
129115
});
130116
131117
$.append($$anchor, fragment_1);
@@ -203,9 +189,9 @@ describe(transformStoriesCode.name, () => {
203189
children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
204190
$.next();
205191
206-
var text_3 = $.text('Label');
192+
var text_2 = $.text('Label');
207193
208-
$.append($$anchor, text_3);
194+
$.append($$anchor, text_2);
209195
}),
210196
$$slots: { default: true }
211197
});
@@ -225,9 +211,9 @@ describe(transformStoriesCode.name, () => {
225211
children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
226212
$.next();
227213
228-
var text_4 = $.text('Forwarded label');
214+
var text_3 = $.text('Forwarded label');
229215
230-
$.append($$anchor, text_4);
216+
$.append($$anchor, text_3);
231217
}),
232218
$$slots: { default: true },
233219
parameters: {

src/compiler/post-transform/story/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ describe(transformStory.name, () => {
126126
children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
127127
$.next();
128128
129-
var text_3 = $.text('Label');
129+
var text_2 = $.text('Label');
130130
131-
$.append($$anchor, text_3);
131+
$.append($$anchor, text_2);
132132
}),
133133
$$slots: { default: true }
134134
});
@@ -147,9 +147,9 @@ describe(transformStory.name, () => {
147147
children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
148148
$.next();
149149
150-
var text_4 = $.text('Forwarded label');
150+
var text_3 = $.text('Forwarded label');
151151
152-
$.append($$anchor, text_4);
152+
$.append($$anchor, text_3);
153153
}),
154154
$$slots: { default: true },
155155
parameters: {

tests/__compiled__/pre-transform/Example.stories.dev.js

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'svelte/internal/disclose-version';
33
Example_stories[$.FILENAME] = 'tests/stories/Example.stories.svelte';
44

55
import * as $ from 'svelte/internal/client';
6-
import { action } from '@storybook/addon-actions';
6+
import { fn } from 'storybook/test';
77
import { defineMeta } from '@storybook/addon-svelte-csf';
88
import Example from './Example.svelte';
99

@@ -21,30 +21,22 @@ const { Story } = defineMeta({
2121
component: Example,
2222
tags: ['autodocs'],
2323
args: {
24-
onclick: action('onclick'),
25-
onmouseenter: action('onmouseenter'),
26-
onmouseleave: action('onmouseleave')
24+
onclick: fn(),
25+
onmouseenter: fn(),
26+
onmouseleave: fn()
2727
}
2828
});
2929

30-
var root_2 = $.add_locations($.template(`<p> </p> <p> </p> <br>`, 1), Example_stories[$.FILENAME], [[41, 2], [42, 2], [42, 44]]);
30+
var root_2 = $.add_locations($.template(`<p> </p> <br>`, 1), Example_stories[$.FILENAME], [[37, 2], [37, 44]]);
3131
var root = $.add_locations($.template(`<!> <!> <!> <!> <!>`, 1), Example_stories[$.FILENAME], []);
3232

3333
function Example_stories($$anchor, $$props) {
3434
$.check_target(new.target);
3535
$.push($$props, true, Example_stories);
3636

37-
const template = $.wrap_snippet(Example_stories, function ($$anchor, $$arg0, context = $.noop) {
37+
const template = $.wrap_snippet(Example_stories, function ($$anchor, args = $.noop, context = $.noop) {
3838
$.validate_snippet_args(...arguments);
3939

40-
let _ = () => $$arg0?.().children;
41-
42-
_();
43-
44-
let args = () => $.exclude_from_object($$arg0?.(), ['children']);
45-
46-
args();
47-
4840
var fragment = $.comment();
4941
var node = $.first_child(fragment);
5042

@@ -57,19 +49,13 @@ function Example_stories($$anchor, $$props) {
5749

5850
$.reset(p);
5951

60-
var p_1 = $.sibling(p, 2);
61-
var text_1 = $.child(p_1, true);
62-
63-
$.reset(p_1);
64-
65-
var text_2 = $.sibling(p_1);
52+
var text_1 = $.sibling(p);
6653

6754
$.next();
6855

6956
$.template_effect(() => {
70-
$.set_text(text, args().id);
71-
$.set_text(text_1, context().name);
72-
$.set_text(text_2, ` You clicked: ${$.get(count) ?? ''}`);
57+
$.set_text(text, context().name);
58+
$.set_text(text_1, ` You clicked: ${$.get(count) ?? ''}`);
7359
});
7460

7561
$.append($$anchor, fragment_1);
@@ -120,9 +106,9 @@ function Example_stories($$anchor, $$props) {
120106
children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
121107
$.next();
122108

123-
var text_3 = $.text('Label');
109+
var text_2 = $.text('Label');
124110

125-
$.append($$anchor, text_3);
111+
$.append($$anchor, text_2);
126112
}),
127113
$$slots: { default: true }
128114
});
@@ -139,9 +125,9 @@ function Example_stories($$anchor, $$props) {
139125
children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
140126
$.next();
141127

142-
var text_4 = $.text('Forwarded label');
128+
var text_3 = $.text('Forwarded label');
143129

144-
$.append($$anchor, text_4);
130+
$.append($$anchor, text_3);
145131
}),
146132
$$slots: { default: true }
147133
});

0 commit comments

Comments
 (0)