@@ -86,6 +86,90 @@ export default async function() {
8686    ` ) 
8787  } ) 
8888
89+   test ( 'server action in object' ,  async  ( )  =>  { 
90+     const  input  =  ` 
91+ const AI = { 
92+   actions: { 
93+     foo: async () => { 
94+       'use server'; 
95+       return 0; 
96+     }, 
97+   }, 
98+ }; 
99+ 
100+ export function ServerProvider() { 
101+   return AI; 
102+ } 
103+ ` 
104+     expect ( await  testTransform ( input ) ) . toMatchInlineSnapshot ( ` 
105+       " 
106+       const AI = { 
107+         actions: { 
108+           foo: /* #__PURE__ */ __registerServerReference($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function"), 
109+         }, 
110+       }; 
111+ 
112+       export function ServerProvider() { 
113+         return AI; 
114+       } 
115+ 
116+       ;export async function $$hoist_0_anonymous_server_function() { 
117+             'use server'; 
118+             return 0; 
119+           }; 
120+       /* #__PURE__ */ Object.defineProperty($$hoist_0_anonymous_server_function, "name", { value: "anonymous_server_function" }); 
121+       " 
122+     ` ) 
123+   } ) 
124+ 
125+   test ( 'top-level use server and inline use server' ,  async  ( )  =>  { 
126+     const  input  =  ` 
127+ 'use server'; 
128+ 
129+ async function innerAction(action, ...args) { 
130+   'use server'; 
131+   return await action(...args); 
132+ } 
133+ 
134+ function wrapAction(action) { 
135+   return innerAction.bind(null, action); 
136+ } 
137+ 
138+ export async function exportedAction() { 
139+   'use server'; 
140+   return null; 
141+ } 
142+ 
143+ export default async () => null; 
144+ ` 
145+     expect ( await  testTransform ( input ) ) . toMatchInlineSnapshot ( ` 
146+       " 
147+       'use server'; 
148+ 
149+       async function innerAction(action, ...args) { 
150+         'use server'; 
151+         return await action(...args); 
152+       } 
153+ 
154+       function wrapAction(action) { 
155+         return innerAction.bind(null, action); 
156+       } 
157+ 
158+       async function exportedAction() { 
159+         'use server'; 
160+         return null; 
161+       } 
162+ 
163+       const $$default = async () => null; 
164+       exportedAction = /* #__PURE__ */ __registerServerReference(exportedAction, "<id>", "exportedAction"); 
165+       export { exportedAction }; 
166+       ; 
167+       const $$wrap_$$default = /* #__PURE__ */ __registerServerReference($$default, "<id>", "default"); 
168+       export { $$wrap_$$default as default }; 
169+       " 
170+     ` ) 
171+   } ) 
172+ 
89173  test ( 'inline use server (function declaration)' ,  async  ( )  =>  { 
90174    const  input  =  ` 
91175export default function App() { 
@@ -196,42 +280,6 @@ export default function App() {
196280    ` ) 
197281  } ) 
198282
199-   test ( 'server action in object' ,  async  ( )  =>  { 
200-     const  input  =  ` 
201- const AI = { 
202-   actions: { 
203-     foo: async () => { 
204-       'use server'; 
205-       return 0; 
206-     }, 
207-   }, 
208- }; 
209- 
210- export function ServerProvider() { 
211-   return AI; 
212- } 
213- ` 
214-     expect ( await  testTransform ( input ) ) . toMatchInlineSnapshot ( ` 
215-       " 
216-       const AI = { 
217-         actions: { 
218-           foo: /* #__PURE__ */ __registerServerReference($$hoist_0_anonymous_server_function, "<id>", "$$hoist_0_anonymous_server_function"), 
219-         }, 
220-       }; 
221- 
222-       export function ServerProvider() { 
223-         return AI; 
224-       } 
225- 
226-       ;export async function $$hoist_0_anonymous_server_function() { 
227-             'use server'; 
228-             return 0; 
229-           }; 
230-       /* #__PURE__ */ Object.defineProperty($$hoist_0_anonymous_server_function, "name", { value: "anonymous_server_function" }); 
231-       " 
232-     ` ) 
233-   } ) 
234- 
235283  test ( 'inline use server (various patterns)' ,  async  ( )  =>  { 
236284    const  input  =  ` 
237285const actions = { 
@@ -311,54 +359,6 @@ export default defaultFn;
311359      " 
312360    ` ) 
313361  } ) 
314- 
315-   test ( 'top-level use server and inline use server' ,  async  ( )  =>  { 
316-     const  input  =  ` 
317- 'use server'; 
318- 
319- async function innerAction(action, ...args) { 
320-   'use server'; 
321-   return await action(...args); 
322- } 
323- 
324- function wrapAction(action) { 
325-   return innerAction.bind(null, action); 
326- } 
327- 
328- export async function exportedAction() { 
329-   'use server'; 
330-   return null; 
331- } 
332- 
333- export default async () => null; 
334- ` 
335-     expect ( await  testTransform ( input ) ) . toMatchInlineSnapshot ( ` 
336-       " 
337-       'use server'; 
338- 
339-       async function innerAction(action, ...args) { 
340-         'use server'; 
341-         return await action(...args); 
342-       } 
343- 
344-       function wrapAction(action) { 
345-         return innerAction.bind(null, action); 
346-       } 
347- 
348-       async function exportedAction() { 
349-         'use server'; 
350-         return null; 
351-       } 
352- 
353-       const $$default = async () => null; 
354-       exportedAction = /* #__PURE__ */ __registerServerReference(exportedAction, "<id>", "exportedAction"); 
355-       export { exportedAction }; 
356-       ; 
357-       const $$wrap_$$default = /* #__PURE__ */ __registerServerReference($$default, "<id>", "default"); 
358-       export { $$wrap_$$default as default }; 
359-       " 
360-     ` ) 
361-   } ) 
362362} ) 
363363
364364// Client transform tests for documentation (from Waku) 
0 commit comments