chat: Give chatNewMessage hook access to the raw message object

This commit is contained in:
Richard Hansen 2021-10-26 21:58:34 -04:00
parent fc5a3f553d
commit 2597b940f4
4 changed files with 30 additions and 1 deletions

View file

@ -60,5 +60,24 @@ describe('chat hooks', function () {
]);
});
}
it('message is an object', async function () {
await Promise.all([
checkHook('chatNewMessage', ({message}) => {
expect(message).to.be.an('object');
}),
helper.sendChatMessage(`${this.test.title}{enter}`),
]);
});
it('message.text is not processed', async function () {
const msg = '<script>alert("foo");</script> https://etherpad.org';
await Promise.all([
checkHook('chatNewMessage', ({message: {text}}) => {
expect(text).to.equal(`${msg}\n`);
}),
helper.sendChatMessage(`${msg}{enter}`),
]);
});
});
});