Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

897 B
Raw Blame
import { BaileysSessionStore } from './baileys-session-store';

describe('findContact across identity kinds', () => {
  it('does not answer a phone lookup with a lid contact whose digits are the same', () => {
    const store = new BaileysSessionStore();
    store.upsertContacts([
      { id: '628111@lid', name: 'Other' },
      { id: '777@lid', phoneNumber: '[email protected]', name: 'Right' },
    ]);

    expect(store.findContact('[email protected]')?.name).toBe('Right');
  });

  it('does not answer a lid lookup with a phone contact whose digits are the same', () => {
    const store = new BaileysSessionStore();
    store.upsertContacts([
      { id: '[email protected]', name: 'Other' },
      { id: '[email protected]', name: 'Other twin' },
      { id: '[email protected]', lid: '777@lid', name: 'Right' },
    ]);

    expect(store.findContact('777@lid')?.name).toBe('Right');
  });
});