Skip to content

Commit

Permalink
Update import paths in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne committed Feb 18, 2024
1 parent 7b2bef5 commit 4db2eef
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
36 changes: 18 additions & 18 deletions backend/src/tests/messageRoute.test.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import request from 'supertest';
import express from 'express';
import { expect } from 'chai';
import sinon from 'sinon';
import { router as messageRoutes } from '../routes/messageRoutes';
import { Message } from '../models/messages';
import request from "supertest";
import express from "express";
import { expect } from "chai";
import sinon from "sinon";
import { router as messageRoutes } from "../routes/messageRoutes.js";
import { Message } from "../models/messages.js";

const app = express();
app.use(express.json());
app.use('/messages', messageRoutes);
app.use("/messages", messageRoutes);

describe('GET /messages', () => {
it('should fetch all messages', async () => {
const mockMessages = [{ _id: '1', text: 'Test message', roomId: '1' }];
sinon.stub(Message, 'find').resolves(mockMessages);
describe("GET /messages", () => {
it("should fetch all messages", async () => {
const mockMessages = [{ _id: "1", text: "Test message", roomId: "1" }];
sinon.stub(Message, "find").resolves(mockMessages);

const res = await request(app).get('/messages');
const res = await request(app).get("/messages");
expect(res.status).to.equal(200);
expect(res.body).to.deep.equal(mockMessages);

sinon.restore();
});
});

describe('GET /messages/:roomId', () => {
it('should fetch all messages for a specific room', async () => {
const mockMessages = [{ _id: '1', text: 'Test message', roomId: '1' }];
sinon.stub(Message, 'find').resolves(mockMessages);
describe("GET /messages/:roomId", () => {
it("should fetch all messages for a specific room", async () => {
const mockMessages = [{ _id: "1", text: "Test message", roomId: "1" }];
sinon.stub(Message, "find").resolves(mockMessages);

const res = await request(app).get('/messages/1');
const res = await request(app).get("/messages/1");
expect(res.status).to.equal(200);
expect(res.body).to.deep.equal(mockMessages);

sinon.restore();
});
});
});
46 changes: 23 additions & 23 deletions backend/src/tests/roomRoutes.test.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import request from 'supertest';
import express from 'express';
import { expect } from 'chai';
import sinon from 'sinon';
import { router as roomRoutes } from '../routes/roomRoutes';
import { Room } from '../models/room';
import request from "supertest";
import express from "express";
import { expect } from "chai";
import sinon from "sinon";
import { router as roomRoutes } from "../routes/roomRoutes.js";
import { Room } from "../models/room.js";

const app = express();
app.use(express.json());
app.use('/rooms', roomRoutes);
app.use("/rooms", roomRoutes);

describe('GET /rooms', () => {
it('should fetch all rooms', async () => {
const mockRooms = [{ title: 'Global Chatroom', id: '1' }];
sinon.stub(Room, 'find').resolves(mockRooms);
describe("GET /rooms", () => {
it("should fetch all rooms", async () => {
const mockRooms = [{ title: "Global Chatroom", id: "1" }];
sinon.stub(Room, "find").resolves(mockRooms);

const res = await request(app).get('/rooms');
const res = await request(app).get("/rooms");
expect(res.status).to.equal(200);
expect(res.body).to.deep.equal(mockRooms);

sinon.restore();
});
});

describe('GET /rooms/all', () => {
it('should fetch all rooms from the database', async () => {
const mockRooms = [{ title: 'Global Chatroom', id: '1' }];
sinon.stub(Room, 'find').resolves(mockRooms);
describe("GET /rooms/all", () => {
it("should fetch all rooms from the database", async () => {
const mockRooms = [{ title: "Global Chatroom", id: "1" }];
sinon.stub(Room, "find").resolves(mockRooms);

const res = await request(app).get('/rooms/all');
const res = await request(app).get("/rooms/all");
expect(res.status).to.equal(200);
expect(res.body).to.deep.equal(mockRooms);

sinon.restore();
});
});

describe('GET /rooms/:roomId', () => {
it('should fetch a specific room by id', async () => {
const mockRoom = { title: 'Global Chatroom', id: '1' };
sinon.stub(Room, 'find').resolves([mockRoom]);
describe("GET /rooms/:roomId", () => {
it("should fetch a specific room by id", async () => {
const mockRoom = { title: "Global Chatroom", id: "1" };
sinon.stub(Room, "find").resolves([mockRoom]);

const res = await request(app).get('/rooms/1');
const res = await request(app).get("/rooms/1");
expect(res.status).to.equal(200);
expect(res.body).to.deep.equal(mockRoom);

sinon.restore();
});
});
});

0 comments on commit 4db2eef

Please sign in to comment.