mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 21:34:46 +00:00
test: tighten device pair assertions
This commit is contained in:
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user