mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Correction test server
This commit is contained in:
parent
b5547cb100
commit
162117a58a
1 changed files with 13 additions and 13 deletions
|
|
@ -33,7 +33,7 @@ describe('Rooms', () => {
|
||||||
// create
|
// create
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('should create a new room and return the new room ID', async () => {
|
it('should create a new room and return the new room ID', async () => {
|
||||||
const title = 'Test Room';
|
const title = 'test room';
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
collection.findOne.mockResolvedValue(null);
|
collection.findOne.mockResolvedValue(null);
|
||||||
|
|
@ -50,7 +50,7 @@ describe('Rooms', () => {
|
||||||
|
|
||||||
// throw an error if userId is undefined
|
// throw an error if userId is undefined
|
||||||
it('should throw an error if userId is undefined', async () => {
|
it('should throw an error if userId is undefined', async () => {
|
||||||
const title = 'Test Room';
|
const title = 'test room';
|
||||||
|
|
||||||
await expect(rooms.create(title, undefined)).rejects.toThrow('Missing required parameter(s)');
|
await expect(rooms.create(title, undefined)).rejects.toThrow('Missing required parameter(s)');
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ describe('Rooms', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the room already exists', async () => {
|
it('should throw an error if the room already exists', async () => {
|
||||||
const title = 'Existing Room';
|
const title = 'existing room';
|
||||||
const userId = '66fc70bea1b9e87655cf17c9';
|
const userId = '66fc70bea1b9e87655cf17c9';
|
||||||
|
|
||||||
// Mock the database response of a found room
|
// Mock the database response of a found room
|
||||||
|
|
@ -85,8 +85,8 @@ describe('Rooms', () => {
|
||||||
it('should return all rooms for a user', async () => {
|
it('should return all rooms for a user', async () => {
|
||||||
const userId = '12345';
|
const userId = '12345';
|
||||||
const userRooms = [
|
const userRooms = [
|
||||||
{ title: 'Room 1', userId },
|
{ title: 'room 1', userId },
|
||||||
{ title: 'Room 2', userId },
|
{ title: 'room 2', userId },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
|
|
@ -124,8 +124,8 @@ describe('Rooms', () => {
|
||||||
it('should return the content of a room', async () => {
|
it('should return the content of a room', async () => {
|
||||||
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
||||||
const content = [
|
const content = [
|
||||||
{ title: 'Salle 1', content: [] },
|
{ title: 'salle 1', content: [] },
|
||||||
{ title: 'Salle 2', content: [] },
|
{ title: 'salle 2', content: [] },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
|
|
@ -188,7 +188,7 @@ describe('Rooms', () => {
|
||||||
describe('rename', () => {
|
describe('rename', () => {
|
||||||
it('should rename a room and return true', async () => {
|
it('should rename a room and return true', async () => {
|
||||||
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
||||||
const newTitle = 'New Room Name';
|
const newTitle = 'new room name';
|
||||||
const userId = '12345';
|
const userId = '12345';
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
|
|
@ -205,7 +205,7 @@ describe('Rooms', () => {
|
||||||
|
|
||||||
it('should return false if the room does not exist', async () => {
|
it('should return false if the room does not exist', async () => {
|
||||||
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
||||||
const newTitle = 'New Room Name';
|
const newTitle = 'new room name';
|
||||||
const userId = '12345';
|
const userId = '12345';
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
|
|
@ -221,7 +221,7 @@ describe('Rooms', () => {
|
||||||
|
|
||||||
it('should throw an error if the new title is already in use', async () => {
|
it('should throw an error if the new title is already in use', async () => {
|
||||||
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
||||||
const newTitle = 'Existing Room';
|
const newTitle = 'existing room';
|
||||||
const userId = '12345';
|
const userId = '12345';
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
|
|
@ -239,7 +239,7 @@ 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';
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
collection.findOne.mockResolvedValue({ title });
|
collection.findOne.mockResolvedValue({ title });
|
||||||
|
|
@ -253,7 +253,7 @@ describe('Rooms', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
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';
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
collection.findOne.mockResolvedValue(null);
|
collection.findOne.mockResolvedValue(null);
|
||||||
|
|
||||||
|
|
@ -272,7 +272,7 @@ describe('Rooms', () => {
|
||||||
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
const roomId = '60c72b2f9b1d8b3a4c8e4d3b';
|
||||||
const room = {
|
const room = {
|
||||||
_id: new ObjectId(roomId),
|
_id: new ObjectId(roomId),
|
||||||
title: 'Test Room',
|
title: 'test room',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mock the database response
|
// Mock the database response
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue