From d8217029bac47d03972b31cda056e5a0f68bdd57 Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Sat, 30 Oct 2021 00:03:19 -0400 Subject: [PATCH] add test for maxQrRetries --- tests/client.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/client.js b/tests/client.js index dde89e8..85db9d1 100644 --- a/tests/client.js +++ b/tests/client.js @@ -29,6 +29,24 @@ describe('Client', function() { await client.destroy(); }); + it('should disconnect after reaching max qr retries', async function () { + this.timeout(50000); + + const qrCallback = sinon.spy(); + const disconnectedCallback = sinon.spy(); + + const client = helper.createClient({options: {qrMaxRetries: 2}}); + client.on('qr', qrCallback); + client.on('disconnected', disconnectedCallback); + + client.initialize(); + + await helper.sleep(45000); + + expect(qrCallback.calledThrice).to.eql(true); + expect(disconnectedCallback.calledOnceWith('Max qrcode retries reached')).to.eql(true); + }); + it('should fail auth if session is invalid', async function() { this.timeout(40000);