chore: use apiv3 for room rename tests

isekai-main
Julian Lam 3 years ago
parent 74f1905ea8
commit e745e21242

@ -191,7 +191,7 @@ module.exports = function (Messaging) {
Messaging.renameRoom = async function (uid, roomId, newName) {
if (!newName) {
throw new Error('[[error:invalid-name]]');
throw new Error('[[error:invalid-data]]');
}
newName = newName.trim();
if (newName.length > 75) {

@ -521,24 +521,17 @@ describe('Messaging Library', () => {
});
});
it('should fail to rename room with invalid data', (done) => {
socketModules.chats.renameRoom({ uid: mocks.users.foo.uid }, null, (err) => {
assert.equal(err.message, '[[error:invalid-data]]');
socketModules.chats.renameRoom({ uid: mocks.users.foo.uid }, { roomId: null }, (err) => {
assert.equal(err.message, '[[error:invalid-data]]');
socketModules.chats.renameRoom({ uid: mocks.users.foo.uid }, { roomId: roomId, newName: null }, (err) => {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
});
it('should fail to rename room with invalid data', async () => {
let { body } = await callv3API('put', `/chats/${roomId}`, { name: null }, 'foo');
assert.strictEqual(body.status.message, await translator.translate('[[error:invalid-data]]'));
({ body } = await callv3API('put', `/chats/${roomId}`, {}, 'foo'));
assert.strictEqual(body.status.message, await translator.translate('[[error:required-parameters-missing, name]]'));
});
it('should rename room', (done) => {
socketModules.chats.renameRoom({ uid: mocks.users.foo.uid }, { roomId: roomId, newName: 'new room name' }, (err) => {
assert.ifError(err);
done();
});
it('should rename room', async () => {
const { statusCode } = await callv3API('put', `/chats/${roomId}`, { name: 'new room name' }, 'foo');
assert.strictEqual(statusCode, 200);
});
it('should send a room-rename system message when a room is renamed', (done) => {

Loading…
Cancel
Save