Skip to content

Commit c2968fb

Browse files
committed
use user provided name in action
1 parent 8074e91 commit c2968fb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/data/action.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ describe("action", () => {
5252
expect((testAction as any).name).toMatch(/^-?\d+$/);
5353
});
5454

55-
test.skip("should use it as `name` when `options` are provided as a string", () => {
55+
test("should use it as `name` when `options` are provided as a string", () => {
5656
const testFn = async (data: string) => `result: ${data}`;
5757
const testAction = action(testFn, "test-action");
5858

5959
expect(testAction.url).toMatch("https://action/test-action");
6060
expect((testAction as any).name).toBe("test-action");
6161
});
6262

63-
test.skip("should use `name` when provided in object options", () => {
63+
test("should use `name` when provided in object options", () => {
6464
const testFn = async (data: string) => `result: ${data}`;
6565
const testAction = action(testFn, { name: "test-action" });
6666

src/data/action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export function action<T extends Array<any>, U = void>(
140140
(o.name && `https://action/${o.name}`) ||
141141
(!isServer ? `https://action/${hashString(fn.toString())}` : "");
142142
mutate.base = url;
143+
if (o.name) Object.defineProperty(mutate, 'name', { value: o.name, writable: false, configurable: true });
143144
return toAction(mutate, url);
144145
}
145146

0 commit comments

Comments
 (0)