useProjectForm Hook
Overview
This test suite covers the functionality of the useProjectForm hook, which is responsible for handling the logic behind project forms.
Test cases
Test: Initialize form with initial values
- Description: Verifies that a form is created with the initial values provided.
- Setup: Mock the
useProjectFormhook to return a mock form object with the initial values. - Expectation: The hook creates a new form with the initial values using the
useFormfunction.
Test: Handle Custom Images
- Description: Verifies that a form's image is changed successfully when there is a custom file input.
- Setup: Mock the
useProjectFormhook to return a mock form object with no initial values. - Expectation: The form's image and defaultImage value change to the File input and false respectively.
Test: Handle Default Images
- Description: Verifies that a form's image is changed successfully when there is a default image input.
- Setup: Mock the
useProjectFormhook to return a mock form object with no initial values. - Expectation: The form's image and defaultImage value change to the path of the selected default image and true respectively.
Test: Clear Image
- Description: Verifies that a form's image can be cleared successfully.
- Setup: Mock the
useProjectFormhook to return a mock form object with no initial values. - Expectation: The form's image and defaultImage value change to the path of the first selected default image and true respectively.
Test: Reset Form
- Description: Verifies that the form's value is cleared.
- Setup: Mock the
useProjectFormhook to return a mock form object with no initial values. - Expectation: The
resetfunction of useForm and themodals.closeAllfunction is called.
Test: Submit Form ( Create ) successfully
- Description: Verifies that the form's submit function for creating form is called successfully.
- Setup: Mock the
useProjectFormhook with no initial values andaddProjectMutationfunction. - Expectation: The
addProjectMutationfunction is called successfully.
Test: Submit Form ( Edit ) successfully
- Description: Verifies that the form's submit function for editing form is called successfully.
- Setup: Mock the
useProjectFormhook with initial values andeditProjectMutationfunction. - Expectation: The
editProjectMutationfunction is called successfully.