From bc59efbe59b7092e1af48d0bb73c6ce2f7adfd73 Mon Sep 17 00:00:00 2001 From: Qaisar Irfan Date: Mon, 10 Mar 2025 19:05:48 +0500 Subject: [PATCH] test: add Jest unit test for Select Dropdown --- .../Select/__snapshots__/select.test.tsx.snap | 57 ++++++++++++ src/components/Select/select.test.tsx | 60 +++++++++++++ src/components/Select/select.tsx | 4 +- src/components/Select/styled.tsx | 10 +-- .../__snapshots__/videoCard.test.tsx.snap | 2 +- src/components/VideoCard/styled.tsx | 4 +- src/redux/login/login.test.tsx | 86 ------------------- src/redux/parseError.test.ts | 61 +++++++++++++ src/redux/parseError.ts | 17 ---- src/redux/store/redux.test.ts | 21 +++++ 10 files changed, 210 insertions(+), 112 deletions(-) create mode 100644 src/components/Select/__snapshots__/select.test.tsx.snap create mode 100644 src/components/Select/select.test.tsx create mode 100644 src/redux/parseError.test.ts diff --git a/src/components/Select/__snapshots__/select.test.tsx.snap b/src/components/Select/__snapshots__/select.test.tsx.snap new file mode 100644 index 0000000..69b5515 --- /dev/null +++ b/src/components/Select/__snapshots__/select.test.tsx.snap @@ -0,0 +1,57 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Select Component should match snapshot 1`] = ` + +
+
+ + + + +
+
+
+`; diff --git a/src/components/Select/select.test.tsx b/src/components/Select/select.test.tsx new file mode 100644 index 0000000..47c6c2c --- /dev/null +++ b/src/components/Select/select.test.tsx @@ -0,0 +1,60 @@ +import React from "react"; + +import { act, customRender, fireEvent, screen } from "@/jest/utils/testUtils"; + +import Select from "./select"; +import { SelectProps } from "./types"; + +describe("Select Component", () => { + const mockHandleChange = jest.fn(); + + const setup = (props?: Partial) => { + const defaultProps: SelectProps = { + menuItems: ["Option 1", "Option 2", "Option 3"], + handleChange: mockHandleChange, + value: "", + }; + + return customRender(