mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +00:00
Add getBlockedContacts method (#770)
* add simple method to get blocked ids * Change getBlockedList to getBlockedIds * getBlockedIds to getBlockedContacts * typo * ESLint & other changes * 🏷️ types * fix: no `this.client` * add tests Co-authored-by: Rajeh Taher <rajeh@reforward.dev> Co-authored-by: Pedro Lopez <pedroslopez@me.com> Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
95facee885
commit
4338664590
@@ -384,6 +384,32 @@ END:VCARD`;
|
||||
expect(contact).to.exist;
|
||||
expect(contact).to.be.instanceOf(Contact);
|
||||
});
|
||||
|
||||
it('can block a contact', async function () {
|
||||
const contact = await client.getContactById(remoteId);
|
||||
await contact.block();
|
||||
|
||||
const refreshedContact = await client.getContactById(remoteId);
|
||||
expect(refreshedContact.isBlocked).to.eql(true);
|
||||
});
|
||||
|
||||
it('can get a list of blocked contacts', async function () {
|
||||
const blockedContacts = await client.getBlockedContacts();
|
||||
expect(blockedContacts.length).to.be.greaterThanOrEqual(1);
|
||||
|
||||
const contact = blockedContacts.find(c => c.id._serialized === remoteId);
|
||||
expect(contact).to.exist;
|
||||
expect(contact).to.be.instanceOf(Contact);
|
||||
|
||||
});
|
||||
|
||||
it('can unblock a contact', async function () {
|
||||
const contact = await client.getContactById(remoteId);
|
||||
await contact.unblock();
|
||||
|
||||
const refreshedContact = await client.getContactById(remoteId);
|
||||
expect(refreshedContact.isBlocked).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Numbers and Users', function () {
|
||||
|
||||
Reference in New Issue
Block a user