@@ -34,6 +34,7 @@ import type {
34
34
AgnosticNonIndexRouteObject,
35
35
AgnosticRouteObject,
36
36
DeferredData,
37
+ ShouldRevalidateFunctionArgs,
37
38
TrackedPromise,
38
39
} from "../utils";
39
40
import {
@@ -1860,7 +1861,7 @@ describe("a router", () => {
1860
1861
router.navigate("/params/aValue/bValue");
1861
1862
await tick();
1862
1863
expect(rootLoader.mock.calls.length).toBe(1);
1863
- expect(shouldRevalidate.mock.calls[0][0]).toMatchObject( {
1864
+ let expectedArg: ShouldRevalidateFunctionArgs = {
1864
1865
currentParams: {},
1865
1866
currentUrl: expect.URL("http://localhost/child"),
1866
1867
nextParams: {
@@ -1870,7 +1871,8 @@ describe("a router", () => {
1870
1871
nextUrl: expect.URL("http://localhost/params/aValue/bValue"),
1871
1872
defaultShouldRevalidate: false,
1872
1873
actionResult: undefined,
1873
- });
1874
+ };
1875
+ expect(shouldRevalidate.mock.calls[0][0]).toMatchObject(expectedArg);
1874
1876
rootLoader.mockClear();
1875
1877
shouldRevalidate.mockClear();
1876
1878
@@ -1924,7 +1926,7 @@ describe("a router", () => {
1924
1926
expect(shouldRevalidate.mock.calls.length).toBe(1);
1925
1927
// @ts-expect-error
1926
1928
let arg = shouldRevalidate.mock.calls[0][0];
1927
- expect(arg).toMatchObject( {
1929
+ let expectedArg: ShouldRevalidateFunctionArgs = {
1928
1930
currentParams: {},
1929
1931
currentUrl: expect.URL("http://localhost/child"),
1930
1932
nextParams: {},
@@ -1934,7 +1936,8 @@ describe("a router", () => {
1934
1936
formAction: "/child",
1935
1937
formEncType: "application/x-www-form-urlencoded",
1936
1938
actionResult: "ACTION",
1937
- });
1939
+ };
1940
+ expect(arg).toMatchObject(expectedArg);
1938
1941
// @ts-expect-error
1939
1942
expect(Object.fromEntries(arg.formData)).toEqual({ key: "value" });
1940
1943
@@ -1977,7 +1980,7 @@ describe("a router", () => {
1977
1980
expect(shouldRevalidate.mock.calls.length).toBe(1);
1978
1981
// @ts-expect-error
1979
1982
let arg = shouldRevalidate.mock.calls[0][0];
1980
- expect(arg).toMatchObject( {
1983
+ let expectedArg: ShouldRevalidateFunctionArgs = {
1981
1984
currentParams: {},
1982
1985
currentUrl: expect.URL("http://localhost/child"),
1983
1986
nextParams: {},
@@ -1987,7 +1990,8 @@ describe("a router", () => {
1987
1990
formAction: "/child",
1988
1991
formEncType: "application/x-www-form-urlencoded",
1989
1992
actionResult: undefined,
1990
- });
1993
+ };
1994
+ expect(arg).toMatchObject(expectedArg);
1991
1995
// @ts-expect-error
1992
1996
expect(Object.fromEntries(arg.formData)).toEqual({ key: "value" });
1993
1997
@@ -2022,15 +2026,16 @@ describe("a router", () => {
2022
2026
expect(shouldRevalidate.mock.calls.length).toBe(1);
2023
2027
// @ts-expect-error
2024
2028
let arg = shouldRevalidate.mock.calls[0][0];
2025
- expect(arg).toMatchObject( {
2029
+ let expectedArg: Partial<ShouldRevalidateFunctionArgs> = {
2026
2030
formMethod: "post",
2027
2031
formAction: "/",
2028
2032
formEncType: "application/json",
2029
2033
text: undefined,
2030
2034
formData: undefined,
2031
2035
json: { key: "value" },
2032
2036
actionResult: "ACTION",
2033
- });
2037
+ };
2038
+ expect(arg).toMatchObject(expectedArg);
2034
2039
2035
2040
router.dispose();
2036
2041
});
@@ -2063,15 +2068,16 @@ describe("a router", () => {
2063
2068
expect(shouldRevalidate.mock.calls.length).toBe(1);
2064
2069
// @ts-expect-error
2065
2070
let arg = shouldRevalidate.mock.calls[0][0];
2066
- expect(arg).toMatchObject( {
2071
+ let expectedArg: Partial<ShouldRevalidateFunctionArgs> = {
2067
2072
formMethod: "post",
2068
2073
formAction: "/",
2069
2074
formEncType: "text/plain",
2070
2075
text: "hello world",
2071
2076
formData: undefined,
2072
2077
json: undefined,
2073
2078
actionResult: "ACTION",
2074
- });
2079
+ };
2080
+ expect(arg).toMatchObject(expectedArg);
2075
2081
2076
2082
router.dispose();
2077
2083
});
0 commit comments