Skip to content

Commit 6306a6e

Browse files
hi-ogawaclaude
andcommitted
simplify test runtime calls and remove unused options
- Change __registerServerReference to 81712register for cleaner snapshots - Remove unused testTransform options (rejectNonAsyncFunction, encode) - Simplify testTransform function signature to just accept input string - All tests continue to pass with simplified assertions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 5d3c4db commit 6306a6e

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

packages/plugin-rsc/src/transforms/server-action.test.ts

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,11 @@ import { transformServerActionServer } from './server-action'
44
import { debugSourceMap } from './test-utils'
55

66
describe('transformServerActionServer', () => {
7-
async function testTransform(
8-
input: string,
9-
options?: {
10-
rejectNonAsyncFunction?: boolean
11-
encode?: boolean
12-
},
13-
) {
7+
async function testTransform(input: string) {
148
const ast = await parseAstAsync(input)
159
const result = transformServerActionServer(input, ast, {
1610
runtime: (value, name) =>
17-
`__registerServerReference(${value}, "<id>", ${JSON.stringify(name)})`,
18-
rejectNonAsyncFunction: options?.rejectNonAsyncFunction,
19-
encode: options?.encode ? (v) => `__enc(${v})` : undefined,
20-
decode: options?.encode ? (v) => `__dec(${v})` : undefined,
11+
`$$register(${value}, "<id>", ${JSON.stringify(name)})`,
2112
})
2213

2314
if (!('output' in result) || !result.output.hasChanged()) {
@@ -75,12 +66,12 @@ export default async function() {
7566
const $$default = async function() {
7667
return Date.now();
7768
}
78-
log = /* #__PURE__ */ __registerServerReference(log, "<id>", "log");
69+
log = /* #__PURE__ */ $$register(log, "<id>", "log");
7970
export { log };
80-
greet = /* #__PURE__ */ __registerServerReference(greet, "<id>", "greet");
71+
greet = /* #__PURE__ */ $$register(greet, "<id>", "greet");
8172
export { greet };
8273
;
83-
const $$wrap_$$default = /* #__PURE__ */ __registerServerReference($$default, "<id>", "default");
74+
const $$wrap_$$default = /* #__PURE__ */ $$register($$default, "<id>", "default");
8475
export { $$wrap_$$default as default };
8576
"
8677
`)
@@ -105,7 +96,7 @@ export function ServerProvider() {
10596
"
10697
const AI = {
10798
actions: {
108-
foo: /* #__PURE__ */ __registerServerReference($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function"),
99+
foo: /* #__PURE__ */ $$register($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function"),
109100
},
110101
};
111102
@@ -161,10 +152,10 @@ export default async () => null;
161152
}
162153
163154
const $$default = async () => null;
164-
exportedAction = /* #__PURE__ */ __registerServerReference(exportedAction, "<id>", "exportedAction");
155+
exportedAction = /* #__PURE__ */ $$register(exportedAction, "<id>", "exportedAction");
165156
export { exportedAction };
166157
;
167-
const $$wrap_$$default = /* #__PURE__ */ __registerServerReference($$default, "<id>", "default");
158+
const $$wrap_$$default = /* #__PURE__ */ $$register($$default, "<id>", "default");
168159
export { $$wrap_$$default as default };
169160
"
170161
`)
@@ -185,7 +176,7 @@ export default function App() {
185176
"
186177
export default function App() {
187178
const a = 'test';
188-
const log = /* #__PURE__ */ __registerServerReference($$hoist_0_log, "<id>", "$$hoist_0_log").bind(null, a);
179+
const log = /* #__PURE__ */ $$register($$hoist_0_log, "<id>", "$$hoist_0_log").bind(null, a);
189180
return log;
190181
}
191182
@@ -213,7 +204,7 @@ export default function App() {
213204
"
214205
export default function App() {
215206
const rand = Math.random();
216-
const log = /* #__PURE__ */ __registerServerReference($$hoist_0_log, "<id>", "$$hoist_0_log").bind(null, rand);
207+
const log = /* #__PURE__ */ $$register($$hoist_0_log, "<id>", "$$hoist_0_log").bind(null, rand);
217208
return log;
218209
}
219210
@@ -241,7 +232,7 @@ export default function App() {
241232
"
242233
const now = Date.now();
243234
export default function App() {
244-
const log = /* #__PURE__ */ __registerServerReference($$hoist_0_log, "<id>", "$$hoist_0_log");
235+
const log = /* #__PURE__ */ $$register($$hoist_0_log, "<id>", "$$hoist_0_log");
245236
return log;
246237
}
247238
@@ -268,7 +259,7 @@ export default function App() {
268259
"
269260
const now = Date.now();
270261
export default function App() {
271-
return /* #__PURE__ */ __registerServerReference($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function");
262+
return /* #__PURE__ */ $$register($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function");
272263
}
273264
274265
;export function $$hoist_0_anonymous_server_function(mesg) {
@@ -314,16 +305,16 @@ export default defaultFn;
314305
expect(await testTransform(input)).toMatchInlineSnapshot(`
315306
"
316307
const actions = {
317-
log: /* #__PURE__ */ __registerServerReference($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function"),
308+
log: /* #__PURE__ */ $$register($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function"),
318309
};
319310
320-
const log2 = /* #__PURE__ */ __registerServerReference($$hoist_1_log2, "<id>", "$$hoist_1_log2");
311+
const log2 = /* #__PURE__ */ $$register($$hoist_1_log2, "<id>", "$$hoist_1_log2");
321312
322-
const log3 = /* #__PURE__ */ __registerServerReference($$hoist_2_log3, "<id>", "$$hoist_2_log3")
313+
const log3 = /* #__PURE__ */ $$register($$hoist_2_log3, "<id>", "$$hoist_2_log3")
323314
324-
const log4 = /* #__PURE__ */ __registerServerReference($$hoist_3_log4, "<id>", "$$hoist_3_log4");
315+
const log4 = /* #__PURE__ */ $$register($$hoist_3_log4, "<id>", "$$hoist_3_log4");
325316
326-
const defaultFn = /* #__PURE__ */ __registerServerReference($$hoist_4_defaultFn, "<id>", "$$hoist_4_defaultFn")
317+
const defaultFn = /* #__PURE__ */ $$register($$hoist_4_defaultFn, "<id>", "$$hoist_4_defaultFn")
327318
328319
export default defaultFn;
329320

0 commit comments

Comments
 (0)