mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
tests update
This commit is contained in:
@@ -33,7 +33,7 @@ describe('Test Connect', () => {
|
||||
|
||||
const conn = new WAConnection()
|
||||
await conn.connect ()
|
||||
assert.ok(conn.user?.id)
|
||||
assert.ok(conn.user?.jid)
|
||||
assert.ok(conn.user?.phone)
|
||||
assert.ok (conn.user?.imgUrl || conn.user.imgUrl === '')
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('Test Connect', () => {
|
||||
.connect ({timeoutMs: 20*1000})
|
||||
.then (conn => {
|
||||
assert.ok(conn.user)
|
||||
assert.ok(conn.user.id)
|
||||
assert.ok(conn.user.jid)
|
||||
|
||||
const chatArray = conn.chats.all()
|
||||
if (chatArray.length > 0) {
|
||||
@@ -57,10 +57,6 @@ describe('Test Connect', () => {
|
||||
assert.ok(chatArray[0].messages[0])
|
||||
}
|
||||
}
|
||||
const contactValues = Object.values(conn.contacts)
|
||||
if (contactValues[0]) {
|
||||
assert.ok(contactValues[0].jid)
|
||||
}
|
||||
})
|
||||
.then (() => conn.logout())
|
||||
.then (() => conn.loadAuthInfo(auth))
|
||||
@@ -162,7 +158,7 @@ describe ('Pending Requests', () => {
|
||||
|
||||
conn.close ()
|
||||
|
||||
const task: Promise<any> = conn.query({json: ['query', 'Status', conn.user.id]})
|
||||
const task: Promise<any> = conn.query({json: ['query', 'Status', conn.user.jid]})
|
||||
|
||||
await delay (2000)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ WAConnectionTest('Groups', (conn) => {
|
||||
const waitForEvent = new Promise (resolve => {
|
||||
conn.on ('group-description-update', ({jid, actor}) => {
|
||||
if (jid === gid) {
|
||||
assert.ok (actor, conn.user.id)
|
||||
assert.ok (actor, conn.user.jid)
|
||||
resolve ()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -35,7 +35,7 @@ WAConnectionTest('Messages', (conn) => {
|
||||
assert.strictEqual(message.message.extendedTextMessage.contextInfo.stanzaId, messages[0].key.id)
|
||||
assert.strictEqual(
|
||||
message.message.extendedTextMessage.contextInfo.participant,
|
||||
messages[0].key.fromMe ? conn.user.id : messages[0].key.id
|
||||
messages[0].key.fromMe ? conn.user.jid : messages[0].key.id
|
||||
)
|
||||
})
|
||||
it('should send a gif', async () => {
|
||||
@@ -74,7 +74,7 @@ WAConnectionTest('Message Events', (conn) => {
|
||||
it('should deliver a message', async () => {
|
||||
const waitForUpdate =
|
||||
promiseTimeout(15000, resolve => {
|
||||
conn.on('message-update', update => {
|
||||
conn.on('message-status-update', update => {
|
||||
if (update.ids.includes(response.key.id)) {
|
||||
resolve(update)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ WAConnectionTest('Misc', (conn) => {
|
||||
|
||||
const waitForEvent = new Promise (resolve => {
|
||||
conn.on ('user-status-update', ({jid, status}) => {
|
||||
if (jid === conn.user.id) {
|
||||
if (jid === conn.user.jid) {
|
||||
assert.equal (status, newStatus)
|
||||
conn.removeAllListeners ('user-status-update')
|
||||
resolve ()
|
||||
@@ -50,16 +50,16 @@ WAConnectionTest('Misc', (conn) => {
|
||||
it('should change the profile picture', async () => {
|
||||
await delay (5000)
|
||||
|
||||
const ppUrl = await conn.getProfilePicture(conn.user.id)
|
||||
const ppUrl = await conn.getProfilePicture(conn.user.jid)
|
||||
const fetched = await fetch(ppUrl, { headers: { Origin: 'https://web.whatsapp.com' } })
|
||||
const buff = await fetched.buffer ()
|
||||
|
||||
const newPP = await fs.readFile ('./Media/cat.jpeg')
|
||||
const response = await conn.updateProfilePicture (conn.user.id, newPP)
|
||||
const response = await conn.updateProfilePicture (conn.user.jid, newPP)
|
||||
|
||||
await delay (10000)
|
||||
|
||||
await conn.updateProfilePicture (conn.user.id, buff) // revert back
|
||||
await conn.updateProfilePicture (conn.user.jid, buff) // revert back
|
||||
})
|
||||
it('should return the profile picture', async () => {
|
||||
const response = await conn.getProfilePicture(testJid)
|
||||
|
||||
Reference in New Issue
Block a user