Skip to content

Commit

Permalink
minor changes and test fix
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinav Kumar <[email protected]>
  • Loading branch information
abhinavkrin authored and ggazzo committed Aug 16, 2024
1 parent 1370d48 commit 609d429
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 1 addition & 5 deletions apps/meteor/app/api/server/v1/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ API.v1.addRoute(

const room = await Rooms.findOneByName(roomName, { projection: { _id: 1 } });

if (room === undefined || room === null) {
return API.v1.success({ exists: false });
}

return API.v1.success({ exists: true });
return API.v1.success({ exists: !!room });
},
},
);
Expand Down
17 changes: 16 additions & 1 deletion apps/meteor/tests/end-to-end/api/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,22 @@ describe('[Rooms]', () => {
.end(done);
});

it('should return an error when send an invalid room', (done) => {
it('should return false if this room name does not exist', (done) => {
void request
.get(api('rooms.nameExists'))
.set(credentials)
.query({
roomName: 'foo',
})
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('exists', false);
})
.end(done);
});

it('should return an error when send an invalid param', (done) => {
void request
.get(api('rooms.nameExists'))
.set(credentials)
Expand Down

0 comments on commit 609d429

Please sign in to comment.