Compare commits

...

2 commits

Author SHA1 Message Date
NouhailaAater
e4739468ba fix tests 2025-02-28 03:16:54 -05:00
NouhailaAater
323efca180 fix tests 2025-02-28 03:13:28 -05:00

View file

@ -190,30 +190,33 @@ describe("Rooms", () => {
describe("roomExists", () => {
it("should return true if room exists", async () => {
const title = "test room";
const title = "TEST ROOM";
const userId = '66fc70bea1b9e87655cf17c9';
collection.findOne.mockResolvedValue({ title });
collection.findOne.mockResolvedValue({ title, userId });
const result = await rooms.roomExists(title);
const result = await rooms.roomExists(title, userId);
expect(db.connect).toHaveBeenCalled();
expect(db.collection).toHaveBeenCalledWith("rooms");
expect(collection.findOne).toHaveBeenCalledWith({ title });
expect(collection.findOne).toHaveBeenCalledWith({ title: title.toUpperCase(), userId });
expect(result).toBe(true);
});
it("should return false if room does not exist", async () => {
const title = "nonexistent room";
const title = "NONEXISTENT ROOM";
const userId = '66fc70bea1b9e87655cf17c9';
collection.findOne.mockResolvedValue(null);
const result = await rooms.roomExists(title);
const result = await rooms.roomExists(title, userId);
expect(db.connect).toHaveBeenCalled();
expect(db.collection).toHaveBeenCalledWith('rooms');
expect(collection.findOne).toHaveBeenCalledWith({ title });
expect(result).toBeFalsy();
});
expect(db.connect).toHaveBeenCalled();
expect(db.collection).toHaveBeenCalledWith('rooms');
expect(collection.findOne).toHaveBeenCalledWith({ title: title.toUpperCase(), userId });
expect(result).toBe(false);
});
});
describe("getRoomById", () => {
it("should return a room by ID", async () => {