Merge branch 'feature/add-room-collection' of https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir into feature/add-room-collection

This commit is contained in:
NouhailaAater 2025-02-26 14:07:30 -05:00
commit 2c3c6eed90

View file

@ -119,41 +119,6 @@ describe('Rooms', () => {
}); });
}); });
// write a test for getContent
describe('getContent', () => {
it('should return the content of a room', async () => {
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
const content = [
{ title: 'salle 1', content: [] },
{ title: 'salle 2', content: [] },
];
// Mock the database response
collection.find().toArray.mockResolvedValue(content);
const result = await rooms.getContent(roomId);
expect(db.connect).toHaveBeenCalled();
expect(db.collection).toHaveBeenCalledWith('files');
expect(collection.find).toHaveBeenCalledWith({ roomId });
expect(result).toEqual(content);
});
it('should return an empty array if the room has no content', async () => {
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
// Mock the database response
collection.find().toArray.mockResolvedValue([]);
const result = await rooms.getContent(roomId);
expect(db.connect).toHaveBeenCalled();
expect(db.collection).toHaveBeenCalledWith('files');
expect(collection.find).toHaveBeenCalledWith({ roomId });
expect(result).toEqual([]);
});
});
describe('delete', () => { describe('delete', () => {
it('should delete a room and return true', async () => { it('should delete a room and return true', async () => {
const roomId = '60c72b2f9b1d8b3a4c8e4d3b'; const roomId = '60c72b2f9b1d8b3a4c8e4d3b';