mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
delete test passes
This commit is contained in:
parent
b20f33500e
commit
e6a3af5838
1 changed files with 26 additions and 36 deletions
|
|
@ -152,42 +152,32 @@ describe('Folders', () => {
|
|||
});
|
||||
});
|
||||
|
||||
// delete
|
||||
describe('delete', () => {
|
||||
it('should delete a folder and return true', async () => {
|
||||
const folderId = await folder.create('Test Folder', '12345');
|
||||
|
||||
// Insert the content using the quiz API
|
||||
const _quiz1ObjectId = await quiz.create('Quiz 1', [], folderId.toString(), '12345');
|
||||
const _quiz2ObjectId = await quiz.create('Quiz 2', [], folderId.toString(), '12345');
|
||||
|
||||
// // write a test for getContent
|
||||
// describe('getContent', () => {
|
||||
// it('should return the content of a folder', async () => {
|
||||
// const folderId = '60c72b2f9b1d8b3a4c8e4d3b';
|
||||
// const content = [
|
||||
// { title: 'Quiz 1', content: [] },
|
||||
// { title: 'Quiz 2', content: [] },
|
||||
// ];
|
||||
const result = await folder.delete(folderId.toString());
|
||||
|
||||
// // Mock the database response
|
||||
// collection.find().toArray.mockResolvedValue(content);
|
||||
expect(result).toBe(true);
|
||||
|
||||
// const result = await folders.getContent(folderId);
|
||||
// make sure quizzes were deleted
|
||||
const quiz1 = await database.collection('files').findOne({ _id: _quiz1ObjectId });
|
||||
const quiz2 = await database.collection('files').findOne({ _id: _quiz2ObjectId });
|
||||
|
||||
// expect(db.connect).toHaveBeenCalled();
|
||||
// expect(db.collection).toHaveBeenCalledWith('files');
|
||||
// expect(collection.find).toHaveBeenCalledWith({ folderId });
|
||||
// expect(result).toEqual(content);
|
||||
// });
|
||||
expect(quiz1).toBeNull();
|
||||
expect(quiz2).toBeNull();
|
||||
|
||||
// it('should return an empty array if the folder has no content', async () => {
|
||||
// const folderId = '60c72b2f9b1d8b3a4c8e4d3b';
|
||||
// Clean up
|
||||
await database.collection('files').deleteMany({ folderId: folderId.toString() });
|
||||
await database.collection('folders').deleteMany({ _id: folderId });
|
||||
});
|
||||
|
||||
// // Mock the database response
|
||||
// collection.find().toArray.mockResolvedValue([]);
|
||||
|
||||
// const result = await folders.getContent(folderId);
|
||||
|
||||
// expect(db.connect).toHaveBeenCalled();
|
||||
// expect(db.collection).toHaveBeenCalledWith('files');
|
||||
// expect(collection.find).toHaveBeenCalledWith({ folderId });
|
||||
// expect(result).toEqual([]);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
// // delete
|
||||
// describe('delete', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue