Handle updating of credentials

This commit is contained in:
Adhiraj
2020-10-02 14:19:04 +05:30
parent 67d82b4169
commit 0d13a15904
6 changed files with 54 additions and 13 deletions

View File

@@ -33,10 +33,15 @@ describe('Test Connect', () => {
console.log('please be ready to scan with your phone')
const conn = new WAConnection()
let credentialsUpdateCalled = false
conn.on ('credentials-updated', () => credentialsUpdateCalled = true)
await conn.connect ()
assert.ok(conn.user?.jid)
assert.ok(conn.user?.phone)
assert.ok (conn.user?.imgUrl || conn.user.imgUrl === '')
assert.ok (credentialsUpdateCalled)
assertChatDBIntegrity (conn)
@@ -45,15 +50,19 @@ describe('Test Connect', () => {
})
it('should reconnect', async () => {
const conn = new WAConnection()
let credentialsUpdateCalled = false
conn.on ('credentials-updated', () => credentialsUpdateCalled = true)
await conn.loadAuthInfo (auth).connect ()
assert.ok(conn.user)
assert.ok(conn.user.jid)
assert.ok (credentialsUpdateCalled)
assertChatDBIntegrity (conn)
await conn.logout()
conn.loadAuthInfo(auth)
await conn.connect()
.then (() => assert.fail('should not have reconnected'))
.catch (err => {