-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: SliderWithLabelForm to fit into Question Schema
- Loading branch information
1 parent
b2d2546
commit 788ac0d
Showing
2 changed files
with
79 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/components/forms/__test__/SliderWithLabelForm.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { SetStateAction } from "react"; | ||
|
||
import { FormProps, FormState, Option } from "../FormRenderer"; | ||
import { SliderWithLabelForm } from "../SliderWithLabelForm"; | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
describe("<SliderWithLabelForm/>", () => { | ||
const formState = { | ||
"test-question-slider": [{ value: 2 }], | ||
}; | ||
const setFormState = jest.fn(); | ||
|
||
const options = [ | ||
{ label: "label1", value: 1 }, | ||
{ label: "label2", value: 2 }, | ||
{ label: "label3", value: 3 }, | ||
]; | ||
|
||
beforeAll(() => { | ||
global.ResizeObserver = class ResizeObserver { | ||
observe() {} | ||
unobserve() {} | ||
disconnect() {} | ||
}; | ||
}); | ||
|
||
beforeEach(() => { | ||
render( | ||
<SliderWithLabelForm | ||
questionText={"test-question-slider"} | ||
options={options} | ||
formState={formState} | ||
setFormState={setFormState} | ||
/>, | ||
); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test("should render Container properly", () => { | ||
expect(screen.getByTestId("slider-with-label-form")).toBeInTheDocument(); | ||
}); | ||
|
||
test("should render min, max label properly", () => { | ||
expect(screen.getByText("label1")).toBeInTheDocument(); | ||
expect(screen.getByText("label3")).toBeInTheDocument(); | ||
}); | ||
}); |