test: tighten device pair assertions

This commit is contained in:
Shakker
2026-05-11 09:18:01 +01:00
parent 43653f5d23
commit 27ec47d433

View File

@@ -65,7 +65,14 @@ import {
import registerDevicePair from "./index.js";
async function expectPathMissing(targetPath: string): Promise<void> {
await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
let error: unknown;
try {
await fs.access(targetPath);
} catch (caught) {
error = caught;
}
expect(error).toBeInstanceOf(Error);
expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
}
afterAll(() => {
@@ -492,8 +499,19 @@ describe("device-pair /pair qr", () => {
expect(caption).toContain("If this QR code leaks, run /pair cleanup immediately.");
const mediaUrl = requireMediaUrl(opts);
expect(mediaUrl).toMatch(/pair-qr\.png$/);
expect(opts.mediaLocalRoots).toEqual([path.dirname(mediaUrl)]);
expect(opts).toMatchObject(testCase.expectedOpts);
expect(opts).toEqual({
cfg: {
gateway: {
auth: {
mode: "token",
token: "gateway-token",
},
},
},
mediaUrl,
mediaLocalRoots: [path.dirname(mediaUrl)],
...testCase.expectedOpts,
});
expect(sentPng).toBe("fakepng");
await expectPathMissing(mediaUrl);
expect(text).toContain("QR code sent above.");