From 8351c80a98f15052b4f3cefded8dce5d737757d8 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:42:32 +0000 Subject: [PATCH 01/10] Initial empty commit to create PR From 3ffd2066b51837fab4ca76c2993a3c42304ce770 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:45:27 +0000 Subject: [PATCH 02/10] Update app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 app/actions/resend/index.test.ts diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts new file mode 100644 index 00000000..48a12428 --- /dev/null +++ b/app/actions/resend/index.test.ts @@ -0,0 +1,68 @@ +import { Resend } from "resend"; +import { resend } from "./index"; +import { RESEND_API_KEY } from "@/config/resend"; + +// Mock the Resend constructor +jest.mock("resend"); + +// Mock the config +jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: "test-api-key", +})); + +describe("resend module", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should create a Resend instance with the API key", () => { + // Verify that Resend constructor was called with the correct API key + expect(Resend).toHaveBeenCalledWith("test-api-key"); + }); + + it("should export a resend instance", () => { + // Verify that resend is defined and is an instance of Resend + expect(resend).toBeDefined(); + expect(resend).toBeInstanceOf(Resend); + }); + + it("should use RESEND_API_KEY from config", () => { + // Verify that the API key from config is used + expect(RESEND_API_KEY).toBe("test-api-key"); + }); +}); + +describe("resend module with empty API key", () => { + beforeEach(() => { + jest.clearAllMocks(); + jest.resetModules(); + }); + + it("should handle empty API key", () => { + // Mock empty API key + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: "", + })); + + // Re-import to get the new mocked value + const { RESEND_API_KEY: emptyKey } = require("@/config/resend"); + + // Verify that empty string is handled + expect(emptyKey).toBe(""); + }); +}); + +describe("resend module initialization", () => { + it("should initialize resend instance on module load", () => { + // The resend instance should be created when the module is imported + // This test verifies that the module exports are accessible + expect(resend).toBeDefined(); + }); + + it("should have the expected Resend instance structure", () => { + // Verify that the resend instance has the expected structure + // The Resend class is mocked, so we just verify it's an instance + expect(resend).toBeInstanceOf(Resend); + expect(Resend).toHaveBeenCalled(); + }); +}); From b57f92e0137aecf33b0a60ce5fa5a546a1fc93f5 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:47:15 +0000 Subject: [PATCH 03/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 50 ++++++++------------------------ 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index 48a12428..97abae01 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -1,6 +1,4 @@ import { Resend } from "resend"; -import { resend } from "./index"; -import { RESEND_API_KEY } from "@/config/resend"; // Mock the Resend constructor jest.mock("resend"); @@ -15,54 +13,30 @@ describe("resend module", () => { jest.clearAllMocks(); }); - it("should create a Resend instance with the API key", () => { - // Verify that Resend constructor was called with the correct API key - expect(Resend).toHaveBeenCalledWith("test-api-key"); - }); + it("should create a Resend instance with the API key from config", () => { + // Import after mocks are set up + const { resend } = require("./index"); + const { RESEND_API_KEY } = require("@/config/resend"); - it("should export a resend instance", () => { - // Verify that resend is defined and is an instance of Resend + // Verify Resend constructor was called with the correct API key + expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); expect(resend).toBeDefined(); - expect(resend).toBeInstanceOf(Resend); - }); - - it("should use RESEND_API_KEY from config", () => { - // Verify that the API key from config is used - expect(RESEND_API_KEY).toBe("test-api-key"); }); -}); -describe("resend module with empty API key", () => { - beforeEach(() => { - jest.clearAllMocks(); - jest.resetModules(); + it("should export a resend instance", () => { + const { resend } = require("./index"); + expect(resend).toBeInstanceOf(Resend); }); it("should handle empty API key", () => { - // Mock empty API key + // Re-mock with empty API key + jest.resetModules(); jest.mock("@/config/resend", () => ({ RESEND_API_KEY: "", })); - // Re-import to get the new mocked value - const { RESEND_API_KEY: emptyKey } = require("@/config/resend"); - - // Verify that empty string is handled - expect(emptyKey).toBe(""); - }); -}); - -describe("resend module initialization", () => { - it("should initialize resend instance on module load", () => { - // The resend instance should be created when the module is imported - // This test verifies that the module exports are accessible + const { resend } = require("./index"); expect(resend).toBeDefined(); - }); - - it("should have the expected Resend instance structure", () => { - // Verify that the resend instance has the expected structure - // The Resend class is mocked, so we just verify it's an instance - expect(resend).toBeInstanceOf(Resend); expect(Resend).toHaveBeenCalled(); }); }); From ee6b973af6eced8064b59f1576923185dd2f046b Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:48:53 +0000 Subject: [PATCH 04/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 104 +++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 11 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index 97abae01..d562c4d0 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -1,11 +1,22 @@ import { Resend } from "resend"; -// Mock the Resend constructor -jest.mock("resend"); +// Mock the Resend class +jest.mock("resend", () => { + return { + Resend: jest.fn().mockImplementation((apiKey: string) => { + return { + apiKey, + emails: { + send: jest.fn(), + }, + }; + }), + }; +}); -// Mock the config +// Mock the config module jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "test-api-key", + RESEND_API_KEY: "test-api-key-123", })); describe("resend module", () => { @@ -14,29 +25,100 @@ describe("resend module", () => { }); it("should create a Resend instance with the API key from config", () => { - // Import after mocks are set up + // Clear the module cache to ensure fresh import + jest.resetModules(); + + // Re-apply mocks + jest.mock("resend", () => { + return { + Resend: jest.fn().mockImplementation((apiKey: string) => { + return { + apiKey, + emails: { + send: jest.fn(), + }, + }; + }), + }; + }); + + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: "test-api-key-123", + })); + + // Import the module const { resend } = require("./index"); const { RESEND_API_KEY } = require("@/config/resend"); + const { Resend: MockedResend } = require("resend"); // Verify Resend constructor was called with the correct API key - expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); + expect(MockedResend).toHaveBeenCalledWith(RESEND_API_KEY); expect(resend).toBeDefined(); + expect(resend.apiKey).toBe("test-api-key-123"); }); - it("should export a resend instance", () => { + it("should export a resend instance with emails property", () => { const { resend } = require("./index"); - expect(resend).toBeInstanceOf(Resend); + + expect(resend).toBeDefined(); + expect(resend.emails).toBeDefined(); + expect(resend.emails.send).toBeDefined(); }); - it("should handle empty API key", () => { - // Re-mock with empty API key + it("should handle empty API key from config", () => { + // Reset modules to test with different config jest.resetModules(); + + // Mock with empty API key + jest.mock("resend", () => { + return { + Resend: jest.fn().mockImplementation((apiKey: string) => { + return { + apiKey, + emails: { + send: jest.fn(), + }, + }; + }), + }; + }); + jest.mock("@/config/resend", () => ({ RESEND_API_KEY: "", })); const { resend } = require("./index"); + const { Resend: MockedResend } = require("resend"); + + expect(MockedResend).toHaveBeenCalledWith(""); expect(resend).toBeDefined(); - expect(Resend).toHaveBeenCalled(); + }); + + it("should create only one instance of Resend", () => { + jest.resetModules(); + + jest.mock("resend", () => { + return { + Resend: jest.fn().mockImplementation((apiKey: string) => { + return { + apiKey, + emails: { + send: jest.fn(), + }, + }; + }), + }; + }); + + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: "test-api-key-123", + })); + + // Import multiple times + const module1 = require("./index"); + const module2 = require("./index"); + + // Should be the same instance (module caching) + expect(module1.resend).toBe(module2.resend); }); }); From 7c9aaadb9619acebf57489d8d4af372440126d71 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:50:10 +0000 Subject: [PATCH 05/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 233 ++++++++++++++++++------------- 1 file changed, 137 insertions(+), 96 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index d562c4d0..1a1bba66 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -1,124 +1,165 @@ -import { Resend } from "resend"; - -// Mock the Resend class -jest.mock("resend", () => { - return { - Resend: jest.fn().mockImplementation((apiKey: string) => { - return { - apiKey, - emails: { - send: jest.fn(), - }, - }; - }), - }; -}); +// Mock the Resend class before importing +const mockResendInstance = { + emails: { + send: jest.fn(), + }, + apiKeys: { + create: jest.fn(), + }, + domains: { + list: jest.fn(), + }, +}; + +const MockResend = jest.fn().mockImplementation(() => mockResendInstance); + +jest.mock("resend", () => ({ + Resend: MockResend, +})); -// Mock the config module +// Mock the config +const mockApiKey = "test-resend-api-key-123"; jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "test-api-key-123", + RESEND_API_KEY: mockApiKey, })); -describe("resend module", () => { +describe("app/actions/resend/index", () => { beforeEach(() => { jest.clearAllMocks(); }); - it("should create a Resend instance with the API key from config", () => { - // Clear the module cache to ensure fresh import - jest.resetModules(); - - // Re-apply mocks - jest.mock("resend", () => { - return { - Resend: jest.fn().mockImplementation((apiKey: string) => { - return { - apiKey, - emails: { - send: jest.fn(), - }, - }; - }), - }; + describe("resend instance", () => { + it("should create a Resend instance with the API key from config", () => { + // Import after mocks are set up + const { resend } = require("./index"); + + // Verify Resend constructor was called with the correct API key + expect(MockResend).toHaveBeenCalledWith(mockApiKey); + expect(resend).toBeDefined(); + }); + + it("should export a resend instance", () => { + const { resend } = require("./index"); + + expect(resend).toBe(mockResendInstance); + expect(resend).toBeDefined(); }); - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "test-api-key-123", - })); + it("should have emails property", () => { + const { resend } = require("./index"); - // Import the module - const { resend } = require("./index"); - const { RESEND_API_KEY } = require("@/config/resend"); - const { Resend: MockedResend } = require("resend"); + expect(resend.emails).toBeDefined(); + expect(typeof resend.emails.send).toBe("function"); + }); - // Verify Resend constructor was called with the correct API key - expect(MockedResend).toHaveBeenCalledWith(RESEND_API_KEY); - expect(resend).toBeDefined(); - expect(resend.apiKey).toBe("test-api-key-123"); - }); + it("should have apiKeys property", () => { + const { resend } = require("./index"); - it("should export a resend instance with emails property", () => { - const { resend } = require("./index"); + expect(resend.apiKeys).toBeDefined(); + expect(typeof resend.apiKeys.create).toBe("function"); + }); + + it("should have domains property", () => { + const { resend } = require("./index"); - expect(resend).toBeDefined(); - expect(resend.emails).toBeDefined(); - expect(resend.emails.send).toBeDefined(); + expect(resend.domains).toBeDefined(); + expect(typeof resend.domains.list).toBe("function"); + }); }); - it("should handle empty API key from config", () => { - // Reset modules to test with different config - jest.resetModules(); - - // Mock with empty API key - jest.mock("resend", () => { - return { - Resend: jest.fn().mockImplementation((apiKey: string) => { - return { - apiKey, - emails: { - send: jest.fn(), - }, - }; - }), - }; + describe("module initialization", () => { + it("should initialize Resend with the correct API key", () => { + // Clear module cache and re-import + jest.resetModules(); + + // Re-apply mocks + jest.mock("resend", () => ({ + Resend: MockResend, + })); + + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: mockApiKey, + })); + + // Import the module + require("./index"); + + // Verify constructor was called + expect(MockResend).toHaveBeenCalled(); + expect(MockResend).toHaveBeenCalledWith(mockApiKey); }); - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "", - })); + it("should handle empty API key", () => { + jest.resetModules(); + + // Mock with empty API key + jest.mock("resend", () => ({ + Resend: MockResend, + })); - const { resend } = require("./index"); - const { Resend: MockedResend } = require("resend"); + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: "", + })); - expect(MockedResend).toHaveBeenCalledWith(""); - expect(resend).toBeDefined(); + const { resend } = require("./index"); + + expect(MockResend).toHaveBeenCalledWith(""); + expect(resend).toBeDefined(); + }); + + it("should create a singleton instance", () => { + jest.resetModules(); + + jest.mock("resend", () => ({ + Resend: MockResend, + })); + + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: mockApiKey, + })); + + // Import multiple times + const module1 = require("./index"); + const module2 = require("./index"); + + // Should be the same instance due to module caching + expect(module1.resend).toBe(module2.resend); + }); }); - it("should create only one instance of Resend", () => { - jest.resetModules(); - - jest.mock("resend", () => { - return { - Resend: jest.fn().mockImplementation((apiKey: string) => { - return { - apiKey, - emails: { - send: jest.fn(), - }, - }; - }), - }; + describe("edge cases", () => { + it("should handle undefined API key", () => { + jest.resetModules(); + + jest.mock("resend", () => ({ + Resend: MockResend, + })); + + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: undefined, + })); + + const { resend } = require("./index"); + + expect(MockResend).toHaveBeenCalledWith(undefined); + expect(resend).toBeDefined(); }); - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "test-api-key-123", - })); + it("should handle null API key", () => { + jest.resetModules(); - // Import multiple times - const module1 = require("./index"); - const module2 = require("./index"); + jest.mock("resend", () => ({ + Resend: MockResend, + })); - // Should be the same instance (module caching) - expect(module1.resend).toBe(module2.resend); + jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: null, + })); + + const { resend } = require("./index"); + + expect(MockResend).toHaveBeenCalledWith(null); + expect(resend).toBeDefined(); + }); }); }); From 3d1c1bbd6614c4d3cfb7097217db04e03598f892 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:51:20 +0000 Subject: [PATCH 06/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 159 ++++++++++--------------------- 1 file changed, 50 insertions(+), 109 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index 1a1bba66..807d16a0 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -1,4 +1,4 @@ -// Mock the Resend class before importing +// Mock Resend before any imports const mockResendInstance = { emails: { send: jest.fn(), @@ -11,155 +11,96 @@ const mockResendInstance = { }, }; -const MockResend = jest.fn().mockImplementation(() => mockResendInstance); +const MockResendConstructor = jest.fn(() => mockResendInstance); jest.mock("resend", () => ({ - Resend: MockResend, + Resend: MockResendConstructor, })); // Mock the config -const mockApiKey = "test-resend-api-key-123"; jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: mockApiKey, + RESEND_API_KEY: "test-resend-api-key", })); describe("app/actions/resend/index", () => { + let resend: typeof mockResendInstance; + let RESEND_API_KEY: string; + + beforeAll(() => { + // Import after mocks are set up + const resendModule = require("./index"); + const configModule = require("@/config/resend"); + + resend = resendModule.resend; + RESEND_API_KEY = configModule.RESEND_API_KEY; + }); + beforeEach(() => { jest.clearAllMocks(); }); - describe("resend instance", () => { - it("should create a Resend instance with the API key from config", () => { - // Import after mocks are set up - const { resend } = require("./index"); - - // Verify Resend constructor was called with the correct API key - expect(MockResend).toHaveBeenCalledWith(mockApiKey); - expect(resend).toBeDefined(); - }); - + describe("module exports", () => { it("should export a resend instance", () => { - const { resend } = require("./index"); - - expect(resend).toBe(mockResendInstance); expect(resend).toBeDefined(); + expect(resend).toBe(mockResendInstance); }); - it("should have emails property", () => { - const { resend } = require("./index"); + it("should create Resend instance with API key from config", () => { + expect(MockResendConstructor).toHaveBeenCalledWith(RESEND_API_KEY); + }); + }); + describe("resend instance properties", () => { + it("should have emails property with send method", () => { expect(resend.emails).toBeDefined(); + expect(resend.emails.send).toBeDefined(); expect(typeof resend.emails.send).toBe("function"); }); - it("should have apiKeys property", () => { - const { resend } = require("./index"); - + it("should have apiKeys property with create method", () => { expect(resend.apiKeys).toBeDefined(); + expect(resend.apiKeys.create).toBeDefined(); expect(typeof resend.apiKeys.create).toBe("function"); }); - it("should have domains property", () => { - const { resend } = require("./index"); - + it("should have domains property with list method", () => { expect(resend.domains).toBeDefined(); + expect(resend.domains.list).toBeDefined(); expect(typeof resend.domains.list).toBe("function"); }); }); - describe("module initialization", () => { - it("should initialize Resend with the correct API key", () => { - // Clear module cache and re-import - jest.resetModules(); + describe("instance usage", () => { + it("should be able to call emails.send", () => { + mockResendInstance.emails.send.mockResolvedValue({ data: { id: "test-id" } }); - // Re-apply mocks - jest.mock("resend", () => ({ - Resend: MockResend, - })); + const result = resend.emails.send({ + from: "test@example.com", + to: ["recipient@example.com"], + subject: "Test", + text: "Test email", + }); - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: mockApiKey, - })); - - // Import the module - require("./index"); - - // Verify constructor was called - expect(MockResend).toHaveBeenCalled(); - expect(MockResend).toHaveBeenCalledWith(mockApiKey); + expect(resend.emails.send).toHaveBeenCalled(); + expect(result).resolves.toBeDefined(); }); - it("should handle empty API key", () => { - jest.resetModules(); - - // Mock with empty API key - jest.mock("resend", () => ({ - Resend: MockResend, - })); - - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "", - })); + it("should be able to call apiKeys.create", () => { + mockResendInstance.apiKeys.create.mockResolvedValue({ data: { id: "key-id" } }); - const { resend } = require("./index"); + const result = resend.apiKeys.create({ name: "test-key" }); - expect(MockResend).toHaveBeenCalledWith(""); - expect(resend).toBeDefined(); - }); - - it("should create a singleton instance", () => { - jest.resetModules(); - - jest.mock("resend", () => ({ - Resend: MockResend, - })); - - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: mockApiKey, - })); - - // Import multiple times - const module1 = require("./index"); - const module2 = require("./index"); - - // Should be the same instance due to module caching - expect(module1.resend).toBe(module2.resend); - }); - }); - - describe("edge cases", () => { - it("should handle undefined API key", () => { - jest.resetModules(); - - jest.mock("resend", () => ({ - Resend: MockResend, - })); - - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: undefined, - })); - - const { resend } = require("./index"); - - expect(MockResend).toHaveBeenCalledWith(undefined); - expect(resend).toBeDefined(); + expect(resend.apiKeys.create).toHaveBeenCalled(); + expect(result).resolves.toBeDefined(); }); - it("should handle null API key", () => { - jest.resetModules(); - - jest.mock("resend", () => ({ - Resend: MockResend, - })); + it("should be able to call domains.list", () => { + mockResendInstance.domains.list.mockResolvedValue({ data: [] }); - jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: null, - })); + const result = resend.domains.list(); - const { resend } = require("./index"); - - expect(MockResend).toHaveBeenCalledWith(null); - expect(resend).toBeDefined(); + expect(resend.domains.list).toHaveBeenCalled(); + expect(result).resolves.toBeDefined(); }); }); }); From 4cf6707cc0d1364323f1230fdccd975668e53eac Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:52:26 +0000 Subject: [PATCH 07/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 114 +++++++------------------------ 1 file changed, 23 insertions(+), 91 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index 807d16a0..d829a455 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -1,106 +1,38 @@ -// Mock Resend before any imports -const mockResendInstance = { - emails: { - send: jest.fn(), - }, - apiKeys: { - create: jest.fn(), - }, - domains: { - list: jest.fn(), - }, -}; - -const MockResendConstructor = jest.fn(() => mockResendInstance); - -jest.mock("resend", () => ({ - Resend: MockResendConstructor, -})); +// Mock Resend class before importing the module +jest.mock("resend", () => { + const mockResendInstance = { + emails: { + send: jest.fn(), + }, + }; + + return { + Resend: jest.fn(() => mockResendInstance), + }; +}); // Mock the config jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "test-resend-api-key", + RESEND_API_KEY: "test-api-key", })); describe("app/actions/resend/index", () => { - let resend: typeof mockResendInstance; - let RESEND_API_KEY: string; - - beforeAll(() => { - // Import after mocks are set up - const resendModule = require("./index"); - const configModule = require("@/config/resend"); - - resend = resendModule.resend; - RESEND_API_KEY = configModule.RESEND_API_KEY; - }); - - beforeEach(() => { - jest.clearAllMocks(); - }); + it("should export a resend instance", () => { + const { resend } = require("./index"); - describe("module exports", () => { - it("should export a resend instance", () => { - expect(resend).toBeDefined(); - expect(resend).toBe(mockResendInstance); - }); - - it("should create Resend instance with API key from config", () => { - expect(MockResendConstructor).toHaveBeenCalledWith(RESEND_API_KEY); - }); + expect(resend).toBeDefined(); }); - describe("resend instance properties", () => { - it("should have emails property with send method", () => { - expect(resend.emails).toBeDefined(); - expect(resend.emails.send).toBeDefined(); - expect(typeof resend.emails.send).toBe("function"); - }); - - it("should have apiKeys property with create method", () => { - expect(resend.apiKeys).toBeDefined(); - expect(resend.apiKeys.create).toBeDefined(); - expect(typeof resend.apiKeys.create).toBe("function"); - }); + it("should create Resend instance with API key from config", () => { + const { Resend } = require("resend"); + const { RESEND_API_KEY } = require("@/config/resend"); - it("should have domains property with list method", () => { - expect(resend.domains).toBeDefined(); - expect(resend.domains.list).toBeDefined(); - expect(typeof resend.domains.list).toBe("function"); - }); + expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); }); - describe("instance usage", () => { - it("should be able to call emails.send", () => { - mockResendInstance.emails.send.mockResolvedValue({ data: { id: "test-id" } }); - - const result = resend.emails.send({ - from: "test@example.com", - to: ["recipient@example.com"], - subject: "Test", - text: "Test email", - }); - - expect(resend.emails.send).toHaveBeenCalled(); - expect(result).resolves.toBeDefined(); - }); - - it("should be able to call apiKeys.create", () => { - mockResendInstance.apiKeys.create.mockResolvedValue({ data: { id: "key-id" } }); - - const result = resend.apiKeys.create({ name: "test-key" }); - - expect(resend.apiKeys.create).toHaveBeenCalled(); - expect(result).resolves.toBeDefined(); - }); - - it("should be able to call domains.list", () => { - mockResendInstance.domains.list.mockResolvedValue({ data: [] }); - - const result = resend.domains.list(); + it("should have emails property", () => { + const { resend } = require("./index"); - expect(resend.domains.list).toHaveBeenCalled(); - expect(result).resolves.toBeDefined(); - }); + expect(resend.emails).toBeDefined(); }); }); From e06111435c7746dfc122fdc8839d4bedc0264080 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:54:05 +0000 Subject: [PATCH 08/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 48 +++++++++++++++----------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index d829a455..69d8ad73 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -1,38 +1,36 @@ -// Mock Resend class before importing the module -jest.mock("resend", () => { - const mockResendInstance = { - emails: { - send: jest.fn(), - }, - }; - - return { - Resend: jest.fn(() => mockResendInstance), - }; -}); +import { Resend } from "resend"; +import { RESEND_API_KEY } from "@/config/resend"; + +// Mock Resend class +jest.mock("resend"); // Mock the config -jest.mock("@/config/resend", () => ({ - RESEND_API_KEY: "test-api-key", -})); +jest.mock("@/config/resend"); describe("app/actions/resend/index", () => { - it("should export a resend instance", () => { - const { resend } = require("./index"); + beforeEach(() => { + jest.clearAllMocks(); + }); - expect(resend).toBeDefined(); + it("should import and export resend instance", async () => { + // Dynamically import the module to ensure it's loaded + const module = await import("./index"); + + expect(module.resend).toBeDefined(); }); - it("should create Resend instance with API key from config", () => { - const { Resend } = require("resend"); - const { RESEND_API_KEY } = require("@/config/resend"); + it("should create Resend instance with API key from config", async () => { + const module = await import("./index"); - expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); + expect(Resend).toHaveBeenCalled(); + expect(module.resend).toBeDefined(); }); - it("should have emails property", () => { - const { resend } = require("./index"); + it("should use RESEND_API_KEY from config", async () => { + const module = await import("./index"); - expect(resend.emails).toBeDefined(); + expect(module.resend).toBeDefined(); + // The module should have been initialized with the API key + expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); }); }); From eb938b03f667f806f33f5642335d894bf161cf82 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:55:12 +0000 Subject: [PATCH 09/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 46 ++++++++++++++------------------ 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index 69d8ad73..36f8061b 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -1,36 +1,30 @@ +// Mock Resend before importing +jest.mock("resend", () => ({ + Resend: jest.fn().mockImplementation(() => ({ + emails: { send: jest.fn() }, + })), +})); + +// Mock config +jest.mock("@/config/resend", () => ({ + RESEND_API_KEY: "test-api-key", +})); + +// Import the module to execute the code +import { resend } from "./index"; import { Resend } from "resend"; import { RESEND_API_KEY } from "@/config/resend"; -// Mock Resend class -jest.mock("resend"); - -// Mock the config -jest.mock("@/config/resend"); - describe("app/actions/resend/index", () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - it("should import and export resend instance", async () => { - // Dynamically import the module to ensure it's loaded - const module = await import("./index"); - - expect(module.resend).toBeDefined(); + it("should export resend instance", () => { + expect(resend).toBeDefined(); }); - it("should create Resend instance with API key from config", async () => { - const module = await import("./index"); - - expect(Resend).toHaveBeenCalled(); - expect(module.resend).toBeDefined(); + it("should create Resend instance with API key", () => { + expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); }); - it("should use RESEND_API_KEY from config", async () => { - const module = await import("./index"); - - expect(module.resend).toBeDefined(); - // The module should have been initialized with the API key - expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); + it("should have emails property", () => { + expect(resend.emails).toBeDefined(); }); }); From cd2cff4e16985c2c79b6f8dfc142e8c4e1e4caac Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:56:10 +0000 Subject: [PATCH 10/10] Replace content of app/actions/resend/index.test.ts [skip ci] --- app/actions/resend/index.test.ts | 36 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/app/actions/resend/index.test.ts b/app/actions/resend/index.test.ts index 36f8061b..c183df27 100644 --- a/app/actions/resend/index.test.ts +++ b/app/actions/resend/index.test.ts @@ -2,6 +2,8 @@ jest.mock("resend", () => ({ Resend: jest.fn().mockImplementation(() => ({ emails: { send: jest.fn() }, + apiKeys: { create: jest.fn() }, + domains: { list: jest.fn() }, })), })); @@ -16,15 +18,37 @@ import { Resend } from "resend"; import { RESEND_API_KEY } from "@/config/resend"; describe("app/actions/resend/index", () => { - it("should export resend instance", () => { - expect(resend).toBeDefined(); + describe("module initialization", () => { + it("should export resend instance", () => { + expect(resend).toBeDefined(); + }); + + it("should create Resend instance with API key from config", () => { + expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); + expect(Resend).toHaveBeenCalledWith("test-api-key"); + }); }); - it("should create Resend instance with API key", () => { - expect(Resend).toHaveBeenCalledWith(RESEND_API_KEY); + describe("resend instance properties", () => { + it("should have emails property", () => { + expect(resend.emails).toBeDefined(); + expect(typeof resend.emails.send).toBe("function"); + }); + + it("should have apiKeys property", () => { + expect(resend.apiKeys).toBeDefined(); + expect(typeof resend.apiKeys.create).toBe("function"); + }); + + it("should have domains property", () => { + expect(resend.domains).toBeDefined(); + expect(typeof resend.domains.list).toBe("function"); + }); }); - it("should have emails property", () => { - expect(resend.emails).toBeDefined(); + describe("resend instance type", () => { + it("should be an instance of Resend", () => { + expect(resend).toBeInstanceOf(Resend); + }); }); });