diff --git a/back-end/tests/test.js b/back-end/tests/test.js index 1e97e8c..fc1c1bc 100644 --- a/back-end/tests/test.js +++ b/back-end/tests/test.js @@ -1,6 +1,6 @@ -const chai = require('chai'); -const chaiHttp = require('chai-http'); -const app = require('../app.js'); +const chai = require("chai"); +const chaiHttp = require("chai-http"); +const app = require("../app.js"); const expect = chai.expect; chai.use(chaiHttp); @@ -21,76 +21,113 @@ describe('Name', () => { }) */ -describe('Login & Signup', () => { - // successful login - TODO : failing - describe('Successful login of an existing user', () => { - it('should log in existing user', (done) => { - chai.request(app) - .post('/users/login') - .send({'email' : 'user1@example.com', 'password' : '123'}) - .end((err, res) => { - expect(res).to.have.status(200); - expect(res.body).to.be.an('object'); - expect(res.body).to.have.property('id'); - expect(res.body).to.have.property('fullname', 'John Doe'); - expect(res.body).to.have.property('username', 'John'); - done(); - }) - }) - }) - - // failed login due to incorrect email address - describe('Failed login, email not found', (done) => { - it('should return 401', (done) => { - chai.request(app) - .post('/users/login') - .send({'email' : 'invalid@email.com', 'password': '123'}) - .end((err, res) => { - expect(res).to.have.status(401) - expect(res.body).to.be.an('object') - done() - }) - }) - }) - - - // failed login due to incorrect password - describe('Failed login, incorrect password', (done) => { - it('should return 401', (done) => { - chai.request(app) - .post('/users/login') - .send({'email' : 'user1@example.com', 'password': 'incorrectPassword'}) - .end((err, res) => { - expect(res).to.have.status(401) - expect(res.body).to.be.an('object') - done() - }) - }) - }) - - // successful signup - describe('Successful signup of new user', () => { - it ('should register new user', (done) => { - chai.request(app) - .post('/users/register') - .send({'fullname' : 'Tester', 'username' : 'testing', 'email' : 'testing@testmail.com', 'password' : '123'}) - .end((err, res) => { - expect(res).to.have.status(201) - expect(res.body).to.be.an('object') - done() - }) +describe("Login & Signup", () => { + // successful login - TODO : failing + describe("Successful login of an existing user", () => { + it("should log in existing user", (done) => { + chai + .request(app) + .post("/users/login") + .send({ email: "user1@example.com", password: "123" }) + .end((err, res) => { + expect(res).to.have.status(200); + expect(res.body).to.be.an("object"); + expect(res.body).to.have.property("id"); + expect(res.body).to.have.property("fullname", "John Doe"); + expect(res.body).to.have.property("username", "John"); + done(); + }); + }); + }); + + // failed login due to incorrect email address + describe("Failed login, email not found", (done) => { + it("should return 401", (done) => { + chai + .request(app) + .post("/users/login") + .send({ email: "invalid@email.com", password: "123" }) + .end((err, res) => { + expect(res).to.have.status(401); + expect(res.body).to.be.an("object"); + done(); + }); + }); + }); + + // failed login due to incorrect password + describe("Failed login, incorrect password", (done) => { + it("should return 401", (done) => { + chai + .request(app) + .post("/users/login") + .send({ email: "user1@example.com", password: "incorrectPassword" }) + .end((err, res) => { + expect(res).to.have.status(401); + expect(res.body).to.be.an("object"); + done(); + }); + }); + }); + + // successful signup + describe("Successful signup of new user", () => { + it("should register new user", (done) => { + chai + .request(app) + .post("/users/register") + .send({ + fullname: "Tester", + username: "testing", + email: "testing@testmail.com", + password: "123", }) - }) -}) + .end((err, res) => { + expect(res).to.have.status(201); + expect(res.body).to.be.an("object"); + done(); + }); + }); + }); +}); + +describe("Book Routes", () => { + it("should get all books", (done) => { + chai + .request(app) + .get("/books") + .end((err, res) => { + expect(res).to.have.status(200); + expect(res.body).to.be.an("array"); + done(); + }); + }); +}); + +describe("Friends", () => { + describe("Friend Shelf Route", () => { + it("should display friends", (done) => { + chai + .request(app) + .get("/friendShelf") + .end((err, res) => { + expect(res).to.have.status(200); + expect(res.body).to.be.an("object"); + done(); + }); + }); + }); -describe('Book Routes', () => { - it('should get all books', (done) => { - chai.request(app) - .get('/books') - .end((err, res) => { - expect(res).to.have.status(200); - expect(res.body).to.be.an('array'); - done(); - }); + describe("Friends Route", () => { + it("Friends Page Route", (done) => { + chai + .request(app) + .get("/Friends") + .end((err, res) => { + expect(res).to.have.status(200); + expect(res.body).to.be.an("object"); + done(); + }); }); -}); \ No newline at end of file + }); +}); diff --git a/front-end/src/components/FriendShelf.js b/front-end/src/components/FriendShelf.js index 48665fe..b2059d7 100644 --- a/front-end/src/components/FriendShelf.js +++ b/front-end/src/components/FriendShelf.js @@ -73,6 +73,7 @@ const FriendShelf = ({ friendsList = friendsReading }) => {