fix tests

This commit is contained in:
NouhailaAater 2025-02-28 03:16:54 -05:00
parent 323efca180
commit e4739468ba

View file

@ -193,13 +193,13 @@ describe("Rooms", () => {
const title = "TEST ROOM"; const title = "TEST ROOM";
const userId = '66fc70bea1b9e87655cf17c9'; 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.connect).toHaveBeenCalled();
expect(db.collection).toHaveBeenCalledWith("rooms"); expect(db.collection).toHaveBeenCalledWith("rooms");
expect(collection.findOne).toHaveBeenCalledWith({ title }); expect(collection.findOne).toHaveBeenCalledWith({ title: title.toUpperCase(), userId });
expect(result).toBe(true); expect(result).toBe(true);
}); });
@ -209,12 +209,12 @@ describe("Rooms", () => {
collection.findOne.mockResolvedValue(null); collection.findOne.mockResolvedValue(null);
const result = await rooms.roomExists(title); const result = await rooms.roomExists(title, userId);
expect(db.connect).toHaveBeenCalled(); expect(db.connect).toHaveBeenCalled();
expect(db.collection).toHaveBeenCalledWith('rooms'); expect(db.collection).toHaveBeenCalledWith('rooms');
expect(collection.findOne).toHaveBeenCalledWith({ title }); expect(collection.findOne).toHaveBeenCalledWith({ title: title.toUpperCase(), userId });
expect(result).toBeFalsy(); expect(result).toBe(false);
}); });
}); });