chore: cleanup, ci workflows and formatting (#127064)
* ci: setup workflows, dependabot, labeler and commit linting * docs: update README, community files and issue templates * chore: configure prettier, editorconfig and format codebase * chore: restore changes lost during rebase * docs: adjust url for new logo * fix: align badges * chore: resolve conflicts and re-add temp lint
This commit is contained in:
parent
c2d978fd0a
commit
807efd502d
94 changed files with 6790 additions and 3547 deletions
|
|
@ -11,7 +11,7 @@ describe('Chat', function () {
|
|||
let client;
|
||||
let chat;
|
||||
|
||||
before(async function() {
|
||||
before(async function () {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({ authenticated: true });
|
||||
await client.initialize();
|
||||
|
|
@ -39,7 +39,7 @@ describe('Chat', function () {
|
|||
const messages = await chat.fetchMessages();
|
||||
expect(messages.length).to.be.greaterThanOrEqual(2);
|
||||
|
||||
const fetchedMsg = messages[messages.length-1];
|
||||
const fetchedMsg = messages[messages.length - 1];
|
||||
expect(fetchedMsg).to.be.instanceOf(Message);
|
||||
expect(fetchedMsg.type).to.equal(MessageTypes.TEXT);
|
||||
expect(fetchedMsg.id._serialized).to.equal(msg.id._serialized);
|
||||
|
|
@ -47,11 +47,11 @@ describe('Chat', function () {
|
|||
});
|
||||
|
||||
it('can use a limit when fetching messages sent in a chat', async function () {
|
||||
await helper.sleep(1000);
|
||||
await helper.sleep(1000);
|
||||
const msg = await chat.sendMessage('yet another message');
|
||||
await helper.sleep(500);
|
||||
|
||||
const messages = await chat.fetchMessages({limit: 1});
|
||||
const messages = await chat.fetchMessages({ limit: 1 });
|
||||
expect(messages).to.have.lengthOf(1);
|
||||
|
||||
const fetchedMsg = messages[0];
|
||||
|
|
@ -62,12 +62,12 @@ describe('Chat', function () {
|
|||
});
|
||||
|
||||
it('can use fromMe=true when fetching messages sent in a chat to get only bot messages', async function () {
|
||||
const messages = await chat.fetchMessages({fromMe: true});
|
||||
const messages = await chat.fetchMessages({ fromMe: true });
|
||||
expect(messages).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('can use fromMe=false when fetching messages sent in a chat to get only non bot messages', async function () {
|
||||
const messages = await chat.fetchMessages({fromMe: false});
|
||||
const messages = await chat.fetchMessages({ fromMe: false });
|
||||
expect(messages).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ describe('Chat', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Archiving', function (){
|
||||
describe('Archiving', function () {
|
||||
it('can archive a chat', async function () {
|
||||
const res = await chat.archive();
|
||||
expect(res).to.equal(true);
|
||||
|
|
@ -147,7 +147,7 @@ describe('Chat', function () {
|
|||
});
|
||||
|
||||
describe('Muting', function () {
|
||||
it('can mute a chat forever', async function() {
|
||||
it('can mute a chat forever', async function () {
|
||||
await chat.mute();
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
|
@ -158,8 +158,8 @@ describe('Chat', function () {
|
|||
expect(chat.muteExpiration).to.equal(-1);
|
||||
});
|
||||
|
||||
it('can mute a chat until a specific date', async function() {
|
||||
const unmuteDate = new Date(new Date().getTime() + (1000*60*60));
|
||||
it('can mute a chat until a specific date', async function () {
|
||||
const unmuteDate = new Date(new Date().getTime() + 1000 * 60 * 60);
|
||||
await chat.mute(unmuteDate);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
|
@ -168,36 +168,36 @@ describe('Chat', function () {
|
|||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(true);
|
||||
expect(chat.muteExpiration).to.equal(
|
||||
Math.round(unmuteDate.getTime() / 1000)
|
||||
Math.round(unmuteDate.getTime() / 1000),
|
||||
);
|
||||
});
|
||||
|
||||
it('can unmute a chat', async function () {
|
||||
await chat.unmute();
|
||||
await helper.sleep(500);
|
||||
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(false);
|
||||
expect(chat.muteExpiration).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// eslint-disable-next-line mocha/no-skipped-tests
|
||||
describe.skip('Destructive operations', function () {
|
||||
it('can clear all messages from chat', async function () {
|
||||
it('can clear all messages from chat', async function () {
|
||||
const res = await chat.clearMessages();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
|
||||
await helper.sleep(3000);
|
||||
|
||||
|
||||
const msgs = await chat.fetchMessages();
|
||||
expect(msgs).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
|
||||
it('can delete a chat', async function () {
|
||||
const res = await chat.delete();
|
||||
expect(res).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,18 +3,20 @@ const helper = require('../helper');
|
|||
|
||||
const remoteId = helper.remoteId;
|
||||
|
||||
describe('Group', function() {
|
||||
describe('Group', function () {
|
||||
let client;
|
||||
let group;
|
||||
|
||||
before(async function() {
|
||||
before(async function () {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({
|
||||
authenticated: true,
|
||||
authenticated: true,
|
||||
});
|
||||
await client.initialize();
|
||||
|
||||
const createRes = await client.createGroup('My Awesome Group', [remoteId]);
|
||||
const createRes = await client.createGroup('My Awesome Group', [
|
||||
remoteId,
|
||||
]);
|
||||
expect(createRes.gid).to.exist;
|
||||
await helper.sleep(500);
|
||||
group = await client.getChatById(createRes.gid._serialized);
|
||||
|
|
@ -34,7 +36,7 @@ describe('Group', function() {
|
|||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.name).to.equal('My Amazing Group');
|
||||
});
|
||||
|
||||
|
|
@ -47,7 +49,7 @@ describe('Group', function() {
|
|||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.description).to.equal('some description');
|
||||
});
|
||||
|
||||
|
|
@ -127,7 +129,9 @@ describe('Group', function() {
|
|||
|
||||
describe('Participants', function () {
|
||||
it('can promote a user to admin', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized === remoteId);
|
||||
let participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(false);
|
||||
|
||||
|
|
@ -138,13 +142,17 @@ describe('Group', function() {
|
|||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(true);
|
||||
});
|
||||
|
||||
it('can demote a user', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
let participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(true);
|
||||
|
||||
|
|
@ -155,13 +163,17 @@ describe('Group', function() {
|
|||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(false);
|
||||
});
|
||||
|
||||
it('can remove a user from the group', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
let participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.exist;
|
||||
|
||||
const res = await group.removeParticipants([remoteId]);
|
||||
|
|
@ -171,12 +183,16 @@ describe('Group', function() {
|
|||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.not.exist;
|
||||
});
|
||||
|
||||
it('can add back a user to the group', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
let participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.not.exist;
|
||||
|
||||
const res = await group.addParticipants([remoteId]);
|
||||
|
|
@ -186,14 +202,16 @@ describe('Group', function() {
|
|||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
participant = group.participants.find(
|
||||
(p) => p.id._serialized === remoteId,
|
||||
);
|
||||
expect(participant).to.exist;
|
||||
});
|
||||
});
|
||||
|
||||
describe('Leave / re-join', function () {
|
||||
let code;
|
||||
|
||||
|
||||
before(async function () {
|
||||
code = await group.getInviteCode();
|
||||
});
|
||||
|
|
@ -224,5 +242,4 @@ describe('Group', function() {
|
|||
after(async function () {
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe('Message', function () {
|
|||
let chat;
|
||||
let message;
|
||||
|
||||
before(async function() {
|
||||
before(async function () {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({ authenticated: true });
|
||||
await client.initialize();
|
||||
|
|
@ -88,7 +88,7 @@ describe('Message', function () {
|
|||
describe('Delete', function () {
|
||||
it('can delete a message for me', async function () {
|
||||
await message.delete();
|
||||
|
||||
|
||||
await helper.sleep(5000);
|
||||
expect(await message.reload()).to.equal(null);
|
||||
});
|
||||
|
|
@ -105,12 +105,14 @@ describe('Message', function () {
|
|||
|
||||
expect(await message.reload()).to.equal(null);
|
||||
expect(callback.called).to.equal(true);
|
||||
const [ revokeMsg, originalMsg ] = callback.args[0];
|
||||
expect(revokeMsg.id._serialized).to.equal(originalMsg.id._serialized);
|
||||
const [revokeMsg, originalMsg] = callback.args[0];
|
||||
expect(revokeMsg.id._serialized).to.equal(
|
||||
originalMsg.id._serialized,
|
||||
);
|
||||
expect(originalMsg.body).to.equal('sneaky message');
|
||||
expect(originalMsg.type).to.equal('chat');
|
||||
expect(revokeMsg.body).to.equal('');
|
||||
expect(revokeMsg.type).to.equal('revoked');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue