diff --git a/src/separated-path-of.ts b/src/separated-path-of.ts index fd260ed..fb24bbe 100644 --- a/src/separated-path-of.ts +++ b/src/separated-path-of.ts @@ -34,7 +34,7 @@ export function separatedPathOf( const proxy = new Proxy({}, handler); const callback = ( - typeof arg1 === "function" ? arg1 : arg2 + typeof arg2 === "function" ? arg2 : arg1 ) as CallBackForPropertyAccess; callback(proxy as T); diff --git a/test/name-of.test.ts b/test/name-of.test.ts index 00d8417..bad3b80 100644 --- a/test/name-of.test.ts +++ b/test/name-of.test.ts @@ -17,4 +17,12 @@ describe("nameOf", () => { expect(age).toBe("age"); expect(length).toBe("length"); }); + + test("Get the property name of the function", () => { + const name = nameOf( + (foo) => foo.bar, + (fn) => fn.call + ); + expect(name).toBe("call"); + }); }); diff --git a/test/path-of.test.ts b/test/path-of.test.ts index c33b1d0..e8030f2 100644 --- a/test/path-of.test.ts +++ b/test/path-of.test.ts @@ -11,4 +11,12 @@ describe("pathOf", () => { const path = pathOf((s) => s.name[0]); expect(path).toBe("['name']['0']"); }); + + test("Get the path of the function", () => { + const path = pathOf( + (foo) => foo.bar, + (fn) => fn.call + ); + expect(path).toBe("['call']"); + }); }); diff --git a/test/separated-path-of.test.ts b/test/separated-path-of.test.ts index 757beba..f406cb7 100644 --- a/test/separated-path-of.test.ts +++ b/test/separated-path-of.test.ts @@ -24,4 +24,12 @@ describe("separatedPathOf", () => { expect(separatedPathIncludesAge).toEqual(["age"]); expect(separatedPathIncludesNameAndZero).toEqual(["name", "0"]); }); + + test("Get the separated path of the function", () => { + const separatedPathIncludesCall = separatedPathOf( + (foo) => foo.bar, + (fn) => fn.call + ); + expect(separatedPathIncludesCall).toStrictEqual(["call"]); + }); });