Rollback unarrowing of the getKcContextMock return type
This commit is contained in:
parent
f488327885
commit
148f7fa316
@ -47,9 +47,7 @@ export function createGetKcContextMock<
|
|||||||
>(params: {
|
>(params: {
|
||||||
pageId: PageId;
|
pageId: PageId;
|
||||||
overrides?: DeepPartial<Extract<KcContext, { pageId: PageId }>>;
|
overrides?: DeepPartial<Extract<KcContext, { pageId: PageId }>>;
|
||||||
// NOTE: We choose to have a return type less precise than Extract<KcContext, { pageId: PageId }> {
|
}): Extract<KcContext, { pageId: PageId }> {
|
||||||
// because we want to be able to use the mock just as the real KcContext.
|
|
||||||
}): KcContext {
|
|
||||||
const { pageId, overrides } = params;
|
const { pageId, overrides } = params;
|
||||||
|
|
||||||
const kcContextMock = structuredCloneButFunctions(
|
const kcContextMock = structuredCloneButFunctions(
|
||||||
|
@ -47,9 +47,7 @@ export function createGetKcContextMock<
|
|||||||
>(params: {
|
>(params: {
|
||||||
pageId: PageId;
|
pageId: PageId;
|
||||||
overrides?: DeepPartial<Extract<KcContext, { pageId: PageId }>>;
|
overrides?: DeepPartial<Extract<KcContext, { pageId: PageId }>>;
|
||||||
// NOTE: We choose to have a return type less precise than Extract<KcContext, { pageId: PageId }> {
|
}): Extract<KcContext, { pageId: PageId }> {
|
||||||
// because we want to be able to use the mock just as the real KcContext.
|
|
||||||
}): KcContext {
|
|
||||||
const { pageId, overrides } = params;
|
const { pageId, overrides } = params;
|
||||||
|
|
||||||
const kcContextMock = structuredCloneButFunctions(
|
const kcContextMock = structuredCloneButFunctions(
|
||||||
|
@ -64,7 +64,7 @@ import { Reflect } from "tsafe/Reflect";
|
|||||||
pageId: "login.ftl"
|
pageId: "login.ftl"
|
||||||
});
|
});
|
||||||
|
|
||||||
type Expected = KcContext;
|
type Expected = Extract<KcContext, { pageId: "login.ftl" }>;
|
||||||
|
|
||||||
assert<Equals<typeof got, Expected>>();
|
assert<Equals<typeof got, Expected>>();
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ import { Reflect } from "tsafe/Reflect";
|
|||||||
pageId: "register.ftl"
|
pageId: "register.ftl"
|
||||||
});
|
});
|
||||||
|
|
||||||
type Expected = KcContext;
|
type Expected = Extract<KcContext, { pageId: "register.ftl" }>;
|
||||||
|
|
||||||
assert<Equals<typeof got, Expected>>();
|
assert<Equals<typeof got, Expected>>();
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ import { Reflect } from "tsafe/Reflect";
|
|||||||
pageId: "my-custom-page.ftl"
|
pageId: "my-custom-page.ftl"
|
||||||
});
|
});
|
||||||
|
|
||||||
type Expected = KcContext;
|
type Expected = Extract<KcContext, { pageId: "my-custom-page.ftl" }>;
|
||||||
|
|
||||||
assert<Equals<typeof got, Expected>>();
|
assert<Equals<typeof got, Expected>>();
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ import { Reflect } from "tsafe/Reflect";
|
|||||||
pageId: "login.ftl"
|
pageId: "login.ftl"
|
||||||
});
|
});
|
||||||
|
|
||||||
type Expected = KcContext;
|
type Expected = Extract<KcContext, { pageId: "login.ftl" }>;
|
||||||
|
|
||||||
assert<Equals<typeof got, Expected>>();
|
assert<Equals<typeof got, Expected>>();
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ import { Reflect } from "tsafe/Reflect";
|
|||||||
pageId: "register.ftl"
|
pageId: "register.ftl"
|
||||||
});
|
});
|
||||||
|
|
||||||
type Expected = KcContext;
|
type Expected = Extract<KcContext, { pageId: "register.ftl" }>;
|
||||||
|
|
||||||
assert<Equals<typeof got, Expected>>();
|
assert<Equals<typeof got, Expected>>();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user