fix tests, remove debugging info

This commit is contained in:
C. Fuhrman 2024-10-02 14:30:53 -04:00
parent 45e6b80a2f
commit b2144345d0
4 changed files with 9 additions and 7 deletions

View file

@ -1,6 +1,6 @@
const Folders = require('../models/folders');
const ObjectId = require('mongodb').ObjectId;
const Quiz = require('../models/quiz');
const Quizzes = require('../models/quiz');
describe('Folders', () => {
let folders;
@ -24,8 +24,9 @@ describe('Folders', () => {
collection: jest.fn().mockReturnValue(collection),
};
// Initialize the Folders model with the mocked db
folders = new Folders(db);
quizzes = new Quizzes(db);
folders = new Folders(db, quizzes);
});
describe('folderExists', () => {
@ -81,7 +82,7 @@ describe('Folders', () => {
jest.spyOn(folders, 'getFolderWithContent').mockResolvedValue(sourceFolder);
jest.spyOn(folders, 'create').mockResolvedValue(newFolderId);
// Mock the response from Quiz.createQuiz
jest.spyOn(Quiz, 'create').mockImplementation(() => {});
jest.spyOn(quizzes, 'create').mockImplementation(() => {});
const result = await folders.copy(folderId, userId);

View file

@ -5,7 +5,8 @@ const { setupWebsocket } = require("../socket/socket");
process.env.NODE_ENV = "test";
const BACKEND_PORT = 4400;
// pick a random port number for testing
const BACKEND_PORT = Math.ceil(Math.random() * 1000 + 3000);
const BACKEND_URL = "http://localhost";
const BACKEND_API = `${BACKEND_URL}:${BACKEND_PORT}`;

View file

@ -3,7 +3,7 @@ const { ObjectId } = require('mongodb');
class Quiz {
constructor(db) {
console.log("Quiz constructor: db", db)
// console.log("Quiz constructor: db", db)
this.db = db;
}

View file

@ -5,7 +5,7 @@ const { USER_ALREADY_EXISTS } = require('../constants/errorCodes');
class Users {
constructor(db, foldersModel) {
console.log("Users constructor: db", db)
// console.log("Users constructor: db", db)
this.db = db;
this.folders = foldersModel;
}