diff --git a/__mocks__/fixtures/referrals.ts b/__mocks__/fixtures/referrals.ts
index 9fcf4d6e8..90c8a8f5f 100644
--- a/__mocks__/fixtures/referrals.ts
+++ b/__mocks__/fixtures/referrals.ts
@@ -9,12 +9,12 @@ const referralSubmission = () => Object.assign(getMockSubmission, { challengeDat
const userReferral: UserReferral = Object.assign(mockUser, { submissions: [referralSubmission()] });
export const mockReferral: Referral = {
- id: "",
- name: "",
- ref: "",
+ id: "ee",
+ name: "test name",
+ ref: "sddf",
created_at: new Date("2022-05-01T12:00:00Z"),
updated_at: new Date("2022-05-01T12:00:00Z"),
- title: "",
+ title: "test referral",
community,
timestamp: 0,
reward: reward,
diff --git a/__tests__/components/popups/referral/Box.test.tsx b/__tests__/components/popups/referral/Box.test.tsx
new file mode 100644
index 000000000..458ed96d6
--- /dev/null
+++ b/__tests__/components/popups/referral/Box.test.tsx
@@ -0,0 +1,39 @@
+
+import Box from "@/components/popups/referral/Box";
+import { renderWithRedux } from "@__mocks__/renderWithRedux";
+import "@testing-library/jest-dom";
+import { screen, fireEvent, act } from "@testing-library/react";
+
+describe("Box component", () => {
+ it('Should render the box component with label and value', () => {
+ renderWithRedux()
+ expect(screen.getByTestId("referral-box")).toBeInTheDocument()
+ expect(screen.getByText("Test Value")).toBeInTheDocument();
+ expect(screen.getByText("test label")).toBeInTheDocument();
+ });
+
+ it("Should copy text to clipboard when the copy button is clicked", () => {
+ renderWithRedux()
+ const copyButton = screen.getByTestId("button");
+ const mockClipboard = {
+ writeText: jest.fn(() => Promise.resolve()),
+ }
+ Object.assign(navigator, { clipboard: mockClipboard });
+ fireEvent.click(copyButton);
+ expect(mockClipboard.writeText).toHaveBeenCalledWith("Test Value");
+ });
+
+ it("Should change the text to 'copied' when the copy button is clicked and change it back to 'copy' after 500ms", async () => {
+ renderWithRedux()
+ const copyButton = screen.getByTestId("button");
+ fireEvent.click(copyButton);
+ expect(await screen.findByText("modal.referral.button.copied")).toBeInTheDocument()
+ // Wait for the button text to change back to "Copy" after 600ms
+ await act(async () => {
+ await new Promise((resolve) => setTimeout(resolve, 600));
+
+ });
+ expect(await screen.findByText("modal.referral.button.copy")).toBeInTheDocument()
+ })
+
+})
\ No newline at end of file
diff --git a/__tests__/components/popups/referral/List.test.tsx b/__tests__/components/popups/referral/List.test.tsx
new file mode 100644
index 000000000..2bf315663
--- /dev/null
+++ b/__tests__/components/popups/referral/List.test.tsx
@@ -0,0 +1,25 @@
+import { mockReferral } from "@__mocks__/fixtures/referrals";
+import { renderWithRedux } from "@__mocks__/renderWithRedux";
+import "@testing-library/jest-dom";
+import { screen } from "@testing-library/react";
+import ReferralList from "@/components/popups/referral/List";
+
+describe("Referral list", () => {
+ it("should render the bounty and the referral titles", () => {
+ renderWithRedux()
+ expect(screen.getByText('modal.referral.list.bounty_title')).toBeInTheDocument();
+ expect(screen.getByText('modal.referral.list.reward')).toBeInTheDocument();
+ });
+ it("should show render as many as the referrals as it received", () => {
+ renderWithRedux(,
+ {
+ referrals:
+ {
+ list: [mockReferral],
+ filteredList: [mockReferral]
+ },
+ })
+ expect(screen.getAllByTestId('referral-bounty-item')).toHaveLength(1)
+ })
+
+})
\ No newline at end of file
diff --git a/__tests__/components/popups/referral/ListItem.test.tsx b/__tests__/components/popups/referral/ListItem.test.tsx
new file mode 100644
index 000000000..c9009526a
--- /dev/null
+++ b/__tests__/components/popups/referral/ListItem.test.tsx
@@ -0,0 +1,26 @@
+import { mockReferral } from "@__mocks__/fixtures/referrals";
+import { renderWithRedux } from "@__mocks__/renderWithRedux";
+import "@testing-library/jest-dom";
+import ReferralListItem from "@/components/popups/referral/ListItem";
+import { screen } from "@testing-library/react";
+
+
+describe("ReferralBountyItem", () => {
+ it("Should render the bounty list item", () => {
+ renderWithRedux()
+ expect(screen.getByTestId("referral-bounty-item")).toBeInTheDocument()
+ });
+ it("Should show the user avatar", () => {
+ renderWithRedux()
+ const avatar = screen.getByTestId("avatar");
+ expect(avatar).toBeInTheDocument();
+ });
+ it("should show the community name when its not a referral bounty", () => {
+ renderWithRedux();
+ expect(screen.getByText(mockReferral.title)).toBeInTheDocument();
+ });
+ it("should display the referral title when its a referral bounty", () => {
+ renderWithRedux();
+ expect(screen.getByText(mockReferral.community.name)).toBeInTheDocument();
+ });
+})
\ No newline at end of file
diff --git a/__tests__/components/ui/SideNavigation/_partials/SideNavLink.test.tsx b/__tests__/components/ui/SideNavigation/_partials/SideNavLink.test.tsx
index c669c1af9..1ece9d70c 100644
--- a/__tests__/components/ui/SideNavigation/_partials/SideNavLink.test.tsx
+++ b/__tests__/components/ui/SideNavigation/_partials/SideNavLink.test.tsx
@@ -29,6 +29,7 @@ describe("SideNavLink", () => {
colors: colors,
locked: false,
showReferralPopup: false,
+ showJobOffersPopup: false,
},
});
const courseLink = screen.getByTestId("courseLinkId");
diff --git a/jest.polyfills.js b/jest.polyfills.js
index c53fcc585..bc857172f 100644
--- a/jest.polyfills.js
+++ b/jest.polyfills.js
@@ -21,6 +21,7 @@ Object.defineProperties(globalThis, {
const { Blob, File } = require("node:buffer");
const { fetch, Headers, FormData, Request, Response } = require("undici");
+const { clearImmediate } = require("node:timers");
Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
@@ -30,4 +31,5 @@ Object.defineProperties(globalThis, {
FormData: { value: FormData },
Request: { value: Request },
Response: { value: Response },
+ clearImmediate: { value: clearImmediate },
});
diff --git a/src/components/popups/referral/Box.tsx b/src/components/popups/referral/Box.tsx
index 6b21e2418..25b83fb1e 100644
--- a/src/components/popups/referral/Box.tsx
+++ b/src/components/popups/referral/Box.tsx
@@ -65,7 +65,7 @@ export default function Box({ value = null, label = null }: BoxProps): ReactElem
}, [timeoutId]);
return (
-
+
{value}
diff --git a/src/components/popups/referral/List.tsx b/src/components/popups/referral/List.tsx
index 7fac2cc93..a4c8bb28e 100644
--- a/src/components/popups/referral/List.tsx
+++ b/src/components/popups/referral/List.tsx
@@ -34,7 +34,7 @@ export default function ReferralList({ bounty = false }: { bounty?: boolean }):
{referrals?.map((referral) => (
-
+
))}
diff --git a/src/components/popups/referral/ListItem.tsx b/src/components/popups/referral/ListItem.tsx
index 7dec08937..0b96b99da 100644
--- a/src/components/popups/referral/ListItem.tsx
+++ b/src/components/popups/referral/ListItem.tsx
@@ -26,6 +26,7 @@ type Referral = {
interface ReferralListItemProps {
referral: Referral;
bounty?: boolean;
+ testId?: string;
}
/**
@@ -39,9 +40,9 @@ interface ReferralListItemProps {
}
* @returns {ReactElement}
*/
-export default function ReferralListItem({ referral, bounty = false }: ReferralListItemProps): ReactElement {
+export default function ReferralListItem({ referral, bounty = false, testId = "referral-bounty-item" }: ReferralListItemProps): ReactElement {
return (
-