mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
adds tests to the surveys package
This commit is contained in:
@@ -210,6 +210,36 @@ describe("SurveyContainer", () => {
|
||||
expect(onCloseMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("triggers clickOutside logic if ignorePlacementForClickOutside is true and placement is not center", () => {
|
||||
render(
|
||||
<SurveyContainer
|
||||
mode="modal"
|
||||
placement="bottomRight"
|
||||
clickOutside={true}
|
||||
onClose={onCloseMock}
|
||||
ignorePlacementForClickOutside={true}>
|
||||
{(<TestChild />) as any}
|
||||
</SurveyContainer>
|
||||
);
|
||||
fireEvent.mouseDown(document.body);
|
||||
expect(onCloseMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("does not trigger clickOutside logic if ignorePlacementForClickOutside is true and placement is center", () => {
|
||||
render(
|
||||
<SurveyContainer
|
||||
mode="modal"
|
||||
placement="center"
|
||||
clickOutside={false}
|
||||
onClose={onCloseMock}
|
||||
ignorePlacementForClickOutside={true}>
|
||||
{(<TestChild />) as any}
|
||||
</SurveyContainer>
|
||||
);
|
||||
fireEvent.mouseDown(document.body);
|
||||
expect(onCloseMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("does not trigger clickOutside logic if mode is not modal", () => {
|
||||
render(
|
||||
<SurveyContainer mode="inline" placement="center" clickOutside={true} onClose={onCloseMock}>
|
||||
@@ -234,6 +264,7 @@ describe("SurveyContainer", () => {
|
||||
unmount();
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledWith("mousedown", expect.any(Function));
|
||||
});
|
||||
|
||||
test("does not call onClose when modal is not shown (show=false)", () => {
|
||||
render(
|
||||
<SurveyContainer
|
||||
|
||||
Reference in New Issue
Block a user