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) { Messaging.renameRoom = async function (uid, roomId, newName) {
if (!newName) { if (!newName) {
throw new Error('[[error:invalid-name]]'); throw new Error('[[error:invalid-data]]');
} }
newName = newName.trim(); newName = newName.trim();
if (newName.length > 75) { if (newName.length > 75) {

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

Loading…
Cancel
Save