Heartbeat: harden targeting and support lid mapping

This commit is contained in:
Peter Steinberger
2025-11-26 18:15:57 +01:00
parent b825f141f3
commit c20a266a11
9 changed files with 251 additions and 24 deletions

View File

@@ -4,7 +4,9 @@ import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import {
assertProvider,
CONFIG_DIR,
ensureDir,
jidToE164,
normalizeE164,
normalizePath,
sleep,
@@ -67,3 +69,19 @@ describe("normalizeE164 & toWhatsappJid", () => {
);
});
});
describe("jidToE164", () => {
it("maps @lid using reverse mapping file", () => {
const mappingPath = `${CONFIG_DIR}/credentials/lid-mapping-123_reverse.json`;
const original = fs.readFileSync;
const spy = vi
.spyOn(fs, "readFileSync")
// biome-ignore lint/suspicious/noExplicitAny: forwarding to native signature
.mockImplementation((path: any, encoding?: any) => {
if (path === mappingPath) return `"5551234"`;
return original(path, encoding);
});
expect(jidToE164("123@lid")).toBe("+5551234");
spy.mockRestore();
});
});