feat: show account AI usage
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import React from "react";
|
||||
import "@testing-library/jest-dom";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import AiUsageCard from "./components/AiUsageCard";
|
||||
import { api } from "./api";
|
||||
|
||||
jest.mock("./api", () => ({ api: { get: jest.fn() } }));
|
||||
|
||||
test("shows monthly AI call and token limits", async () => {
|
||||
(api.get as jest.Mock).mockResolvedValue({
|
||||
data: {
|
||||
currentMonth: { calls: 4, estimatedTokens: 12000 },
|
||||
plan: "free",
|
||||
monthlyCallLimit: 25,
|
||||
monthlyTokenLimit: 100000,
|
||||
},
|
||||
});
|
||||
|
||||
render(<AiUsageCard />);
|
||||
|
||||
expect(await screen.findByText("4 of 25 generations this month")).toBeInTheDocument();
|
||||
expect(screen.getByText("12,000 of 100,000 estimated tokens")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Monthly AI generations used")).toHaveAttribute("aria-valuenow", "16");
|
||||
});
|
||||
Reference in New Issue
Block a user