diff --git a/src/components/Stepper.test.tsx b/src/components/Stepper.test.tsx index 0f8363a08..276cc713d 100644 --- a/src/components/Stepper.test.tsx +++ b/src/components/Stepper.test.tsx @@ -2,7 +2,7 @@ import { Step, Stepper } from "src/components/Stepper"; import { click, render } from "src/utils/rtl"; import { zeroTo } from "src/utils/sb"; -describe(Stepper, () => { +describe("Stepper", () => { it("renders and invokes onChange", async () => { const onChange = jest.fn(); // Given the stepper with 3 steps. The first disabled and complete, the second incomplete, and the third in error state. diff --git a/src/components/SuperDrawer/useSuperDrawer.test.tsx b/src/components/SuperDrawer/useSuperDrawer.test.tsx index c0264a4ca..2c5a24a9c 100644 --- a/src/components/SuperDrawer/useSuperDrawer.test.tsx +++ b/src/components/SuperDrawer/useSuperDrawer.test.tsx @@ -39,7 +39,7 @@ describe("useSuperDrawer", () => { const canCloseDrawerCheck = jest.fn(() => true); // Given the useSuperDrawer hook - const hook = renderHook(useSuperDrawer, { wrapper }).result.current; + const hook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; // And a opened SuperDrawer act(() => hook.openInDrawer({ content: "content" })); @@ -55,8 +55,8 @@ describe("useSuperDrawer", () => { it("should not add canCloseDrawerCheck when SuperDrawer is closed", () => { // Given the useSuperDrawer hook - const superDrawerHook = renderHook(useSuperDrawer, { wrapper }).result.current; - const beamHook = renderHook(() => useBeamContext(), { wrapper }).result.current; + const superDrawerHook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; + const beamHook = renderHook(() => useBeamContext(), { wrapper: wrapper as any }).result.current; // When adding a canCloseDrawerCheck act(() => superDrawerHook.addCanCloseDrawerCheck(() => true)); @@ -69,7 +69,7 @@ describe("useSuperDrawer", () => { const canCloseDrawerDetailCheck = jest.fn(() => true); // Given the useSuperDrawer hook - const hook = renderHook(useSuperDrawer, { wrapper }).result.current; + const hook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; // And a opened SuperDrawer with a detail content act(() => { hook.openInDrawer({ content: "content" }); @@ -88,8 +88,8 @@ describe("useSuperDrawer", () => { it("should not add canCloseDrawerCheckDetail when SuperDrawer details is closed", () => { // Given the useSuperDrawer and beamContent hook - const superDrawerHook = renderHook(useSuperDrawer, { wrapper }).result.current; - const beamHook = renderHook(() => useBeamContext(), { wrapper }).result.current; + const superDrawerHook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; + const beamHook = renderHook(() => useBeamContext(), { wrapper: wrapper as any }).result.current; // And a opened SuperDrawer with no detail content act(() => { superDrawerHook.openInDrawer({ content: "content" }); @@ -104,7 +104,7 @@ describe("useSuperDrawer", () => { it("should show ConfirmCloseModal when a canCloseDrawerCheck fails", async () => { // Given a useSuperDrawer and BeamContext hook - const hook = renderHook(useSuperDrawer, { wrapper }).result.current; + const hook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; // And a opened SuperDrawer act(() => hook.openInDrawer({ content: "content" })); @@ -117,7 +117,7 @@ describe("useSuperDrawer", () => { it("should show ConfirmCloseModal when a canCloseDrawerDetailCheck fails", async () => { // Given a useSuperDrawer and BeamContext hook - const hook = renderHook(useSuperDrawer, { wrapper }).result.current; + const hook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; // And a opened SuperDrawer act(() => { hook.openInDrawer({ content: "content" }); @@ -135,7 +135,7 @@ describe("useSuperDrawer", () => { const onClose = jest.fn(); // Given the useSuperDrawer hook - const hook = renderHook(useSuperDrawer, { wrapper }).result.current; + const hook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; // When the drawer is opened and closed act(() => hook.openInDrawer({ content: "content", onClose })); @@ -149,7 +149,7 @@ describe("useSuperDrawer", () => { it("should not throw when attempting to closeDrawer with an empty content stack", () => { // Given a useSuperDrawer and BeamContext hook - const hook = renderHook(useSuperDrawer, { wrapper }).result.current; + const hook = renderHook(useSuperDrawer, { wrapper: wrapper as any }).result.current; // And a closed SuperDrawer // When we call onClose // Then we do not expect to have an error thrown diff --git a/src/components/Table/utils/RowStates.ts b/src/components/Table/utils/RowStates.ts index 41e009001..a57096898 100644 --- a/src/components/Table/utils/RowStates.ts +++ b/src/components/Table/utils/RowStates.ts @@ -93,7 +93,7 @@ export class RowStates { this.header.children = [this.keptGroupRow, ...this.topRows]; // Then mark any remaining as removed - for (const state of maybeKept) state.markRemoved(); + for (const state of maybeKept) (state as any).markRemoved(); // After the first load of real data, we detach collapse state, to respect // any incoming initCollapsed. diff --git a/src/components/Tabs.test.tsx b/src/components/Tabs.test.tsx index bd8811996..ddd41e9e7 100644 --- a/src/components/Tabs.test.tsx +++ b/src/components/Tabs.test.tsx @@ -110,7 +110,7 @@ describe("TabsWithContent", () => { it("renders tabs as links", async () => { const router = withRouter("/tab1"); // Given tabs with `path` values - const testTabs: RouteTabWithContent[] = [ + const testTabs: RouteTabWithContent[] = [ { name: "Tab A", path: "/tab1", href: "/tab1", render: () => }, { name: "Tab B", path: "/tab2", href: "/tab2", render: () => }, ]; @@ -125,9 +125,9 @@ describe("TabsWithContent", () => { it("can match tab based on multiple paths", async () => { // Given a route - const router = withRouter("/ce:1", "/:ceId"); + const router = withRouter("/ce:1"); // And a tab that supports multiple routes - const testTabs: RouteTabWithContent[] = [ + const testTabs: RouteTabWithContent[] = [ { name: "Tab A", path: "/:ceId/line-items", @@ -149,8 +149,8 @@ describe("TabsWithContent", () => { it("can navigate between tabs when rendered as links", async () => { // Given Route-able tabs, rendered at the first tab's route - const router = withRouter("/tab1", "/"); - const testTabs: RouteTabWithContent[] = [ + const router = withRouter("/tab1"); + const testTabs: RouteTabWithContent[] = [ { name: "Tab A", path: "/tab1", href: "/tab1", render: () => }, { name: "Tab B", path: "/tab2", href: "/tab2", render: () => }, ]; @@ -169,8 +169,8 @@ describe("TabsWithContent", () => { it("captures path parameters within Route context", async () => { // Given Route-able tabs with path parameters - const router = withRouter("/ce:1/overview", "/"); - const testTabs: RouteTabWithContent[] = [ + const router = withRouter("/ce:1/overview"); + const testTabs: RouteTabWithContent[] = [ { name: "Tab A", path: "/:ceId/overview", href: "/ce:1/overview", render: () => }, { name: "Tab B", @@ -192,13 +192,13 @@ describe("TabsWithContent", () => { it("renders a disabled route tab as a div", async () => { // Give a disabled tab (must include two non-disabled tabs to have tab-list show). - const testTabs: RouteTabWithContent[] = [ + const testTabs: RouteTabWithContent[] = [ { name: "Tab A", path: "/a", href: "/a", render: () => }, { name: "Tab B", path: "/b", href: "/b", render: () => }, { name: "Tab C", path: "/c", href: "/c", render: () => , disabled: true }, ]; - const r = await render(, withRouter("/a", "")); + const r = await render(, withRouter("/a")); // Then the disabled tab should be rendered as a div expect(r.tabs_tabC.tagName).toBe("DIV"); diff --git a/src/forms/BoundTreeSelectField.test.tsx b/src/forms/BoundTreeSelectField.test.tsx index 658c2d8e7..5e7e6134d 100644 --- a/src/forms/BoundTreeSelectField.test.tsx +++ b/src/forms/BoundTreeSelectField.test.tsx @@ -6,7 +6,7 @@ import { NestedOption } from "src/inputs"; import { HasIdAndName } from "src/types"; import { blur, click, focus, render } from "src/utils/rtl"; -describe(BoundTreeSelectField, () => { +describe("BoundTreeSelectField", () => { it("shows the current value and label", async () => { const author = createObjectState(formConfig, { favoriteGenres: ["g:4"] }); const r = await render(); diff --git a/src/forms/FormStateApp.tsx b/src/forms/FormStateApp.tsx index 178e86b17..9cb65625e 100644 --- a/src/forms/FormStateApp.tsx +++ b/src/forms/FormStateApp.tsx @@ -48,7 +48,7 @@ export function FormStateApp() { const formState = useFormState({ config: formConfig, - init: queryResponse, + init: { input: queryResponse }, addRules(state) { state.lastName.rules.push(() => { return state.firstName.value === state.lastName.value ? "Last name cannot equal first name" : undefined; diff --git a/src/inputs/NumberField.tsx b/src/inputs/NumberField.tsx index b186d185f..85f0c5b63 100644 --- a/src/inputs/NumberField.tsx +++ b/src/inputs/NumberField.tsx @@ -121,7 +121,7 @@ export function NumberField(props: NumberFieldProps) { ? { style: "unit", unit: "day", unitDisplay: "long" as const, maximumFractionDigits: 0 } : {}; - return { ...defaultFormatOptions, ...typeFormat }; + return { ...defaultFormatOptions, ...typeFormat } as any; }, [type, numberFormatOptions, defaultFormatOptions, numFractionDigits]); const numberParser = useMemo(() => new NumberParser(locale, formatOptions), [locale, formatOptions]); diff --git a/src/utils/rtl.tsx b/src/utils/rtl.tsx index 2fc66c8e9..c4d5731d2 100644 --- a/src/utils/rtl.tsx +++ b/src/utils/rtl.tsx @@ -64,7 +64,7 @@ export function render( wrappers = [ ...otherWrappers, ...(!omitBeamContext ? [withBeamRTL] : []), - ...(at ? [_withRouter(at.url, at.route)] : [_withRouter()]), + ...(at ? [_withRouter(at.url)] : [_withRouter()]), ]; } else { wrappers = [withBeamRTL]; diff --git a/src/utils/sb.tsx b/src/utils/sb.tsx index 6695437e9..91ca8da07 100644 --- a/src/utils/sb.tsx +++ b/src/utils/sb.tsx @@ -4,8 +4,8 @@ import { BeamProvider } from "src/components"; import { Css, Properties } from "src/Css"; import { withRouter as rtlWithRouter } from "src/utils/rtl"; -export function withRouter(url?: string, path?: string): Decorator { - return (Story: () => JSX.Element) => rtlWithRouter(url, path).wrap(); +export function withRouter(url?: string): Decorator { + return (Story: () => JSX.Element) => rtlWithRouter(url).wrap(); } /* Models our currently used parameters. */