chore: Enhance database debugging setup and expand test mocks for Drizzle queries and Discord API interactions.
This commit is contained in:
@@ -7,6 +7,8 @@ const mockLimit = mock();
|
||||
// Helper to support the chained calls in getLeaderboards
|
||||
const mockChain = {
|
||||
from: () => mockChain,
|
||||
leftJoin: () => mockChain,
|
||||
groupBy: () => mockChain,
|
||||
orderBy: () => mockChain,
|
||||
limit: mockLimit
|
||||
};
|
||||
@@ -75,7 +77,8 @@ describe("dashboardService", () => {
|
||||
// First call is topLevels, second is topWealth
|
||||
mockLimit
|
||||
.mockResolvedValueOnce(mockTopLevels)
|
||||
.mockResolvedValueOnce(mockTopWealth);
|
||||
.mockResolvedValueOnce(mockTopWealth)
|
||||
.mockResolvedValueOnce(mockTopWealth); // Mock net worth same as wealth for simplicity
|
||||
|
||||
const result = await dashboardService.getLeaderboards();
|
||||
|
||||
@@ -85,7 +88,7 @@ describe("dashboardService", () => {
|
||||
expect(result.topWealth[0]!.balance).toBe("1000");
|
||||
expect(result.topWealth[0]!.username).toBe("Alice");
|
||||
expect(result.topWealth[1]!.balance).toBe("500");
|
||||
expect(mockLimit).toHaveBeenCalledTimes(2);
|
||||
expect(mockLimit).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
test("should handle empty leaderboards", async () => {
|
||||
|
||||
Reference in New Issue
Block a user