test(bluebubbles): accept native contact database paths

This commit is contained in:
Vincent Koc
2026-05-04 04:28:33 -07:00
parent 03d04c243b
commit 981767516d

View File

@@ -1,3 +1,4 @@
import { join } from "node:path";
import { beforeEach, describe, expect, it, vi } from "vitest";
import {
enrichBlueBubblesParticipantsWithContactNames,
@@ -111,9 +112,17 @@ describe("enrichBlueBubblesParticipantsWithContactNames", () => {
});
it("lists contacts databases from the current home directory", async () => {
const expectedSourcesDir = join(
"/Users/tester",
"Library",
"Application Support",
"AddressBook",
"Sources",
);
const expectedDatabasePath = join(expectedSourcesDir, "source-a", "AddressBook-v22.abcddb");
const readdir = vi.fn(async () => ["source-a", "source-b"]);
const access = vi.fn(async (path: string) => {
if (!path.endsWith("source-a/AddressBook-v22.abcddb")) {
if (path !== expectedDatabasePath) {
throw new Error("missing");
}
});
@@ -124,12 +133,8 @@ describe("enrichBlueBubblesParticipantsWithContactNames", () => {
access,
});
expect(readdir).toHaveBeenCalledWith(
"/Users/tester/Library/Application Support/AddressBook/Sources",
);
expect(databases).toEqual([
"/Users/tester/Library/Application Support/AddressBook/Sources/source-a/AddressBook-v22.abcddb",
]);
expect(readdir).toHaveBeenCalledWith(expectedSourcesDir);
expect(databases).toEqual([expectedDatabasePath]);
});
it("queries only the requested phone keys in sqlite", async () => {