import * as React from "react"; import { render, screen, fireEvent, cleanup } from "@testing-library/react"; import reactToCSS from "react-style-object-to-css"; import { styleClean } from "@sc/utils"; import LinearScaleField from "./LinearScaleField"; import { EditorMode } from "../../../../Editor/types"; import { AttributeContainer } from "@sc/modules/v2/CRUD/AttributeBuilder"; import { AttributeNames } from "@sc/modules/v2/CRUD/AttributeBuilder/types"; import { LinearScaleDisplayType } from "../types"; import { styleData } from "../../FormBuilder.stories"; import { IconTypes } from "@sc/plugins/webcomponents/v2/Icon"; const testId = "FormBuilder-FormFields-LinearScaleField"; const props = { styles: styleData, attributeContainerDataSettings: { hide: false }, }; describe(" Rendering Tests", () => { afterEach(cleanup); it(`Should render in the dom`, () => { render(); expect(screen.queryByTestId(testId)).toBeTruthy(); }); it(`Should render an EDITOR or LIVE version of the component based on the value of the mode prop`, () => { const testIdLive = "FormBuilder-FormFields-LinearScaleField-LIVE"; const testIdEditor = "FormBuilder-FormFields-LinearScaleField-EDITOR"; const { rerender } = render( ); expect(screen.queryByTestId(testIdLive)).toBeTruthy(); rerender(); expect(screen.queryByTestId(testIdEditor)).toBeTruthy(); }); it(`Should render some radio buttons when the mode is live. The amount should match the max value prop`, () => { const testIdLive = "FormBuilder-FormFields-LinearScaleField-LIVE"; const min = 1; const max = 5; render(); expect( screen.queryByTestId(testIdLive).querySelectorAll("input").length ).toEqual(max - min + 1); }); it(`Should render the AttributeContainer component when the mode is edit`, () => { const attrTestId = "FormBuilder-AttributeContainer"; render(); expect(screen.queryByTestId(attrTestId)).toBeTruthy(); }); it(`Should see that the