mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Compare commits
2 commits
eb3e06f5d3
...
e4739468ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4739468ba | ||
|
|
323efca180 |
1 changed files with 21 additions and 18 deletions
|
|
@ -190,31 +190,34 @@ describe("Rooms", () => {
|
||||||
|
|
||||||
describe("roomExists", () => {
|
describe("roomExists", () => {
|
||||||
it("should return true if room exists", async () => {
|
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.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);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return false if room does not exist", async () => {
|
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);
|
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);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("getRoomById", () => {
|
describe("getRoomById", () => {
|
||||||
it("should return a room by ID", async () => {
|
it("should return a room by ID", async () => {
|
||||||
const roomId = "60c72b2f9b1d8b3a4c8e4d3b";
|
const roomId = "60c72b2f9b1d8b3a4c8e4d3b";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue