mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Update init method to try login multiple times + use WA ttl for QR gen
This commit is contained in:
@@ -7,20 +7,17 @@ import { assertChatDBIntegrity, makeConnection, testJid } from './Common'
|
||||
describe('QR Generation', () => {
|
||||
it('should generate QR', async () => {
|
||||
const conn = makeConnection ()
|
||||
conn.connectOptions.regenerateQRIntervalMs = 5000
|
||||
conn.connectOptions.maxRetries = 0
|
||||
|
||||
let calledQR = 0
|
||||
conn.removeAllListeners ('qr')
|
||||
conn.on ('qr', qr => calledQR += 1)
|
||||
conn.on ('qr', () => calledQR += 1)
|
||||
|
||||
await conn.connect()
|
||||
.then (() => assert.fail('should not have succeeded'))
|
||||
.catch (error => {
|
||||
assert.equal (error.message, 'timed out')
|
||||
})
|
||||
assert.deepEqual (conn['pendingRequests'], [])
|
||||
assert.deepEqual (
|
||||
Object.keys(conn['callbacks']).filter(key => !key.startsWith('function:')),
|
||||
.catch (error => {})
|
||||
assert.deepStrictEqual (
|
||||
Object.keys(conn.eventNames()).filter(key => key.startsWith('TAG:')),
|
||||
[]
|
||||
)
|
||||
assert.ok(calledQR >= 2, 'QR not called')
|
||||
|
||||
Reference in New Issue
Block a user