import { describe, expect, it } from "vitest"; import { buildAdminEmailConnectionsVM } from "./email-connections.vm.js"; describe("admin email connections view model", () => { it("sorts accounts and derives provider capability state", () => { const vm = buildAdminEmailConnectionsVM({ accounts: [ { id: "mailbox-2", connectionId: "connection-2", provider: "microsoft_mail", emailAddress: "z@example.com", displayName: null, status: "active", lastSyncAt: new Date("2026-07-24T10:00:00.000Z"), healthMessageKey: null, }, { id: "mailbox-1", connectionId: "connection-1", provider: "google_mail", emailAddress: "a@example.com", displayName: "A", status: "revoked", lastSyncAt: null, healthMessageKey: "admin.sales.email.connections.health.revoked", }, ], providerConfiguration: { google_mail: true, microsoft_mail: false, }, }); expect(vm.accounts.map((account) => account.id)).toEqual([ "mailbox-1", "mailbox-2", ]); expect(vm.providers).toEqual([ { provider: "google_mail", configured: true, connected: false, }, { provider: "microsoft_mail", configured: false, connected: true, }, ]); }); });