|
| 1 | +import { join } from "node:path"; |
1 | 2 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { |
3 | 4 | enrichBlueBubblesParticipantsWithContactNames, |
@@ -111,9 +112,17 @@ describe("enrichBlueBubblesParticipantsWithContactNames", () => {
|
111 | 112 | }); |
112 | 113 | |
113 | 114 | it("lists contacts databases from the current home directory", async () => { |
| 115 | +const expectedSourcesDir = join( |
| 116 | +"/Users/tester", |
| 117 | +"Library", |
| 118 | +"Application Support", |
| 119 | +"AddressBook", |
| 120 | +"Sources", |
| 121 | +); |
| 122 | +const expectedDatabasePath = join(expectedSourcesDir, "source-a", "AddressBook-v22.abcddb"); |
114 | 123 | const readdir = vi.fn(async () => ["source-a", "source-b"]); |
115 | 124 | const access = vi.fn(async (path: string) => { |
116 | | -if (!path.endsWith("source-a/AddressBook-v22.abcddb")) { |
| 125 | +if (path !== expectedDatabasePath) { |
117 | 126 | throw new Error("missing"); |
118 | 127 | } |
119 | 128 | }); |
@@ -124,12 +133,8 @@ describe("enrichBlueBubblesParticipantsWithContactNames", () => {
|
124 | 133 | access, |
125 | 134 | }); |
126 | 135 | |
127 | | -expect(readdir).toHaveBeenCalledWith( |
128 | | -"/Users/tester/Library/Application Support/AddressBook/Sources", |
129 | | -); |
130 | | -expect(databases).toEqual([ |
131 | | -"/Users/tester/Library/Application Support/AddressBook/Sources/source-a/AddressBook-v22.abcddb", |
132 | | -]); |
| 136 | +expect(readdir).toHaveBeenCalledWith(expectedSourcesDir); |
| 137 | +expect(databases).toEqual([expectedDatabasePath]); |
133 | 138 | }); |
134 | 139 | |
135 | 140 | it("queries only the requested phone keys in sqlite", async () => { |
|