36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { GoogleService } from "../src/google/google.service";
|
|
import { createPrismaMock } from "./utils/mock-prisma";
|
|
|
|
describe("GoogleService", () => {
|
|
it("reports the durable user-owned Google Drive mirror status", async () => {
|
|
const prisma = createPrismaMock();
|
|
prisma.googleConnection.findUnique.mockResolvedValue({
|
|
userId: "user_1",
|
|
googleEmail: "owner@example.com",
|
|
connectedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
spreadsheetId: "sheet_123",
|
|
driveMirrorEnabled: true,
|
|
driveMirrorStatus: "synced",
|
|
driveMirrorSpreadsheetUrl: "https://docs.google.com/spreadsheets/d/sheet_123",
|
|
driveMirrorLastSyncedAt: new Date("2026-01-02T00:00:00.000Z"),
|
|
lastSyncedAt: new Date("2026-01-02T00:00:00.000Z"),
|
|
isConnected: true,
|
|
});
|
|
const service = new GoogleService(prisma as any);
|
|
|
|
await expect(service.getStatus("user_1")).resolves.toEqual({
|
|
connected: true,
|
|
googleEmail: "owner@example.com",
|
|
connectedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
driveMirror: {
|
|
enabled: true,
|
|
status: "synced",
|
|
spreadsheetId: "sheet_123",
|
|
url: "https://docs.google.com/spreadsheets/d/sheet_123",
|
|
lastSyncedAt: new Date("2026-01-02T00:00:00.000Z"),
|
|
ownership: "user_google_drive",
|
|
},
|
|
});
|
|
});
|
|
});
|