feat: pass JID on connect; extract startAccount() helper; poll 30s for new accounts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -106,4 +106,21 @@ describe('WhatsAppSessionPool', () => {
|
||||
await capturedOnQr('test-qr');
|
||||
expect(onQr).toHaveBeenCalledWith('test-qr', 'acc_1');
|
||||
});
|
||||
|
||||
it('add() injects accountId and jid into onStatus callback', async () => {
|
||||
const onStatus = jest.fn();
|
||||
const { createWhatsAppSession } = require('./session');
|
||||
|
||||
let capturedOnStatus: any;
|
||||
(createWhatsAppSession as jest.Mock).mockImplementationOnce(
|
||||
(_id: string, _path: string, _onMsg: any, _onReaction: any, _onGroups: any, _onReconnect: any, _onQr: any, statusCb: any) => {
|
||||
capturedOnStatus = statusCb;
|
||||
return Promise.resolve({ sendMessage: jest.fn(), logout: jest.fn(), end: jest.fn() });
|
||||
},
|
||||
);
|
||||
|
||||
await pool.add('acc_1', './sessions/1', jest.fn(), jest.fn(), jest.fn(), undefined, onStatus);
|
||||
await capturedOnStatus('connected', '1234@s.whatsapp.net');
|
||||
expect(onStatus).toHaveBeenCalledWith('connected', 'acc_1', '1234@s.whatsapp.net');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user