diff --git a/src/native/autoLaunch.test.ts b/src/native/autoLaunch.test.ts
new file mode 100644
index 0000000..2e1e529
--- /dev/null
+++ b/src/native/autoLaunch.test.ts
@@ -0,0 +1,147 @@
+///
+
+import AutoLaunch from "auto-launch";
+import { ipcMain } from "electron";
+
+import { autoLaunch } from "./autoLaunch";
+import { mainWindow } from "./window";
+
+// Mock auto-launch - define mock methods inside the factory
+jest.mock("auto-launch", () => {
+ const mockAutoLaunch = {
+ isEnabled: jest.fn(),
+ enable: jest.fn(),
+ disable: jest.fn(),
+ };
+ const AutoLaunchMock = jest.fn().mockImplementation(() => mockAutoLaunch);
+ (AutoLaunchMock as unknown as Record).mockMethods =
+ mockAutoLaunch;
+ return AutoLaunchMock;
+});
+
+// Mock electron - store handlers on global
+jest.mock("electron", () => ({
+ ipcMain: {
+ on: jest.fn((channel: string, handler: Function) => {
+ (global as Record).__autoLaunchIpcHandlers =
+ (global as Record).__autoLaunchIpcHandlers || {};
+ ((global as Record).__autoLaunchIpcHandlers as Record<
+ string,
+ Function
+ >)[channel] = handler;
+ }),
+ },
+}));
+
+// Mock window
+jest.mock("./window", () => ({
+ mainWindow: {
+ webContents: {
+ send: jest.fn(),
+ },
+ },
+}));
+
+// Access the mock methods from the mocked constructor
+const mockMethods = (AutoLaunch as unknown as Record)
+ .mockMethods as Record;
+
+const getIpcHandlers = (): Record =>
+ ((global as Record).__autoLaunchIpcHandlers as Record<
+ string,
+ Function
+ >) || {};
+
+describe("autoLaunch", () => {
+ beforeEach(() => {
+ // Clear mock method calls but preserve AutoLaunch constructor call history
+ // since it's called at module load time before tests run
+ const mockMethods = (AutoLaunch as unknown as Record)
+ .mockMethods as Record;
+ Object.values(mockMethods).forEach((mock) => mock.mockClear());
+ (mainWindow.webContents.send as jest.Mock).mockClear();
+ });
+
+ describe("autoLaunch instance", () => {
+ it("should create an AutoLaunch instance with the correct config", () => {
+ expect(AutoLaunch).toHaveBeenCalledWith({
+ name: "Revolt",
+ });
+ });
+
+ it("should export the autoLaunch instance", () => {
+ expect(autoLaunch).toBeDefined();
+ });
+ });
+
+ describe("isAutostart? IPC handler", () => {
+ it("should register the isAutostart? IPC handler", () => {
+ expect(getIpcHandlers()["isAutostart?"]).toBeDefined();
+ });
+
+ it("should check if autoLaunch is enabled when handler is called", () => {
+ mockMethods.isEnabled.mockResolvedValue(true);
+ getIpcHandlers()["isAutostart?"]();
+
+ expect(mockMethods.isEnabled).toHaveBeenCalled();
+ });
+
+ it("should send true to mainWindow when autoLaunch is enabled", async () => {
+ mockMethods.isEnabled.mockResolvedValue(true);
+ getIpcHandlers()["isAutostart?"]();
+
+ await Promise.resolve();
+
+ expect(mainWindow.webContents.send).toHaveBeenCalledWith(
+ "isAutostart",
+ true,
+ );
+ });
+
+ it("should send false to mainWindow when autoLaunch is disabled", async () => {
+ mockMethods.isEnabled.mockResolvedValue(false);
+ getIpcHandlers()["isAutostart?"]();
+
+ await Promise.resolve();
+
+ expect(mainWindow.webContents.send).toHaveBeenCalledWith(
+ "isAutostart",
+ false,
+ );
+ });
+ });
+
+ describe("setAutostart IPC handler", () => {
+ it("should register the setAutostart IPC handler", () => {
+ expect(getIpcHandlers()["setAutostart"]).toBeDefined();
+ });
+
+ it("should enable autoLaunch when state is true", () => {
+ getIpcHandlers()["setAutostart"](true);
+
+ expect(mockMethods.enable).toHaveBeenCalled();
+ expect(mockMethods.disable).not.toHaveBeenCalled();
+ });
+
+ it("should disable autoLaunch when state is false", () => {
+ getIpcHandlers()["setAutostart"](false);
+
+ expect(mockMethods.disable).toHaveBeenCalled();
+ expect(mockMethods.enable).not.toHaveBeenCalled();
+ });
+
+ it("should disable autoLaunch when state is falsy", () => {
+ getIpcHandlers()["setAutostart"](null);
+
+ expect(mockMethods.disable).toHaveBeenCalled();
+ expect(mockMethods.enable).not.toHaveBeenCalled();
+ });
+
+ it("should disable autoLaunch when state is undefined", () => {
+ getIpcHandlers()["setAutostart"](undefined);
+
+ expect(mockMethods.disable).toHaveBeenCalled();
+ expect(mockMethods.enable).not.toHaveBeenCalled();
+ });
+ });
+});