import { test, expect } from "vitest"; import React from "react"; import "@testing-library/jest-dom/vitest"; import { ReportContext } from "../context/index.js"; import { renderHook } from "@testing-library/react"; import useSketchProperties from "./useSketchProperties.js"; const ContextWrapper: React.FunctionComponent<{ children?: any; }> = ({ children }) => { return ( {children} ); }; test("useSketchProperties passes sketch properties from context", () => { const { result: { current: [sketchProperties], }, } = renderHook(() => useSketchProperties(), { wrapper: ContextWrapper, }); expect(sketchProperties.name).toBe("My Sketch"); expect(sketchProperties.userAttributes[0].exportId).toBe("field1"); }); test("useSketchProperties provides a means of getting values by exportId", () => { const { result: { // eslint-disable-next-line @typescript-eslint/no-unused-vars current: [_, getByExportId], }, } = renderHook(() => useSketchProperties(), { wrapper: ContextWrapper, }); expect(getByExportId("field1")).toBe("hi there"); expect(getByExportId("field2")).toBe(1); });