import { describe, expect, it, mock, beforeEach } from "bun:test";

// Mock the api-client — no actual fetch
mock.module("../../lib/api-client", () => ({
  apiRequest: async (path: string) => {
    if (path.includes("summary")) {
      return { income: 1000, expense: 500, balance: 500 };
    }
    return { transactions: [] };
  },
}));

// Mock expo-secure-store (pulled in transitively via auth-store)
mock.module("expo-secure-store", () => ({
  getItemAsync: async () => null,
  setItemAsync: async () => {},
  deleteItemAsync: async () => {},
}));

mock.module("react-native", () => ({}));
mock.module("@haushaltsApp/env/native", () => ({
  env: { EXPO_PUBLIC_SERVER_URL: "http://localhost:3000" },
}));

describe("useTransactions query keys", () => {
  it("summary query key is correct", () => {
    const key = ["transactions", "summary"];
    expect(key).toEqual(["transactions", "summary"]);
  });

  it("list query key with filters", () => {
    const filters = { type: "expense" as const };
    const key = ["transactions", filters];
    expect(key[1]).toEqual(filters);
  });
});
