Skip to content

Commit 7da8a3b

Browse files
committed
test(ui): build the deferred removal with Promise.withResolvers
The pending-state test seeded its deferred promise by declaring the resolver with let and reassigning it inside the executor. Promise.withResolvers is the standard way to get the same handle without the reassignment, and the assertions are unchanged.
1 parent 62b072d commit 7da8a3b

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/cost_tracking_settings.test.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,8 @@ describe("CostTrackingSettings", () => {
199199

200200
it("should hold the confirmation open while the removal is still in flight", async () => {
201201
mockDiscountConfig.mockReturnValue({ openai: 0.05 });
202-
let settleRemoval: () => void = () => {};
203-
mockRemoveDiscount.mockReturnValue(
204-
new Promise<void>((resolve) => {
205-
settleRemoval = resolve;
206-
}),
207-
);
202+
const { promise, resolve: settleRemoval } = Promise.withResolvers<void>();
203+
mockRemoveDiscount.mockReturnValue(promise);
208204

209205
const user = await expandAndRemove("Provider Discounts", "Remove discount for openai");
210206
await user.click(await screen.findByRole("button", { name: "Remove" }));

0 commit comments

Comments
 (0)