File size: 1,675 Bytes
fcd8223 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | import { describe, expect, it, vi } from "vitest";
import type { scanInstalledApps } from "../infra/installed-apps.js";
import { invokeDeviceApps } from "./invoke-device-apps.js";
const scan = vi.fn<typeof scanInstalledApps>(async () => ({
status: "ok",
apps: [
{ label: "Calendar", bundleId: "com.apple.iCal", path: "/System/Calendar.app", system: true },
{
label: "Notes App",
bundleId: "com.example.notes",
path: "/Applications/Notes.app",
system: false,
},
{ label: "Other", path: "/Applications/Other.app", system: false },
],
}));
describe("invokeDeviceApps", () => {
it("returns the typed privacy error while sharing is disabled", async () => {
await expect(
invokeDeviceApps({ sharingEnabled: false, platform: "darwin", scan }),
).resolves.toEqual({
ok: false,
code: "INSTALLED_APPS_SHARING_DISABLED",
message: "INSTALLED_APPS_SHARING_DISABLED: enable Installed Apps in node-host settings",
});
expect(scan).not.toHaveBeenCalled();
});
it("matches the Android count envelope with macOS app fields", async () => {
const result = await invokeDeviceApps({
sharingEnabled: true,
platform: "darwin",
paramsJSON: JSON.stringify({ query: "app", limit: 1, includeSystem: false }),
scan,
});
expect(result).toEqual({
ok: true,
payload: {
count: 1,
totalMatched: 1,
truncated: false,
apps: [
{
label: "Notes App",
bundleId: "com.example.notes",
path: "/Applications/Notes.app",
system: false,
},
],
},
});
});
});
|