Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ekathuria/style pages #18

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a7fa97f
running into node-fetch error when setting up react test suite
alvma1945 Apr 12, 2022
b7e5eeb
jest setup for frontend testing
alvma1945 Apr 12, 2022
b50e762
Merge pull request #1 from panda-whale-csny32/alvin/testing
iuddin Apr 12, 2022
554cc35
some tests added in reviews.test.js
iuddin Apr 12, 2022
e1d36d2
some tests added in reviews.test.js
iuddin Apr 12, 2022
d3a5807
adding package.json
iuddin Apr 12, 2022
2fb33c8
adding the build files
iuddin Apr 12, 2022
21842a2
worked on books tests
emiliayoffie Apr 12, 2022
4548e5c
added bundle
emiliayoffie Apr 12, 2022
329324e
frontend testing library setup compelete?
alvma1945 Apr 13, 2022
5e111c1
backend testing - reviews and books routes, Alvins changes in FE testing
iuddin Apr 14, 2022
0c68359
some frontend tests written using RTL and jest
alvma1945 Apr 14, 2022
619aa7e
added OtherfutureContainer code
alvma1945 Apr 14, 2022
d9875e1
navbar, signup, login components created
alvma1945 Apr 14, 2022
32177cd
Merge pull request #2 from panda-whale-csny32/alvin/testing
bozoputer Apr 14, 2022
f140490
finished books tests
emiliayoffie Apr 14, 2022
26dace7
Merge branch 'tests' into iftekhar/one
iuddin Apr 14, 2022
605d015
modified home, signup, and login pages
alvma1945 Apr 14, 2022
558a129
Merge pull request #3 from panda-whale-csny32/iftekhar/one
emiliayoffie Apr 14, 2022
75bc702
Merge branch 'tests' into emilia/testing
emiliayoffie Apr 14, 2022
2a2e26e
Merge pull request #4 from panda-whale-csny32/emilia/testing
iuddin Apr 14, 2022
69b9421
added new sql instance
emiliayoffie Apr 14, 2022
a2e2f9e
Merge branch 'tests' into emilia/testing
emiliayoffie Apr 14, 2022
6c15755
Merge pull request #5 from panda-whale-csny32/emilia/testing
alvma1945 Apr 14, 2022
f642c66
modified login and signup routes
alvma1945 Apr 14, 2022
5ae1569
Merge branch 'dev' into alvin/testing
alvma1945 Apr 14, 2022
938acbb
database set up successfully
alvma1945 Apr 14, 2022
1f85a95
Merge pull request #6 from panda-whale-csny32/alvin/testing
bozoputer Apr 14, 2022
f0c1fd3
styled login and signup buttons
alvma1945 Apr 14, 2022
9f6b799
Merge pull request #7 from panda-whale-csny32/alvin/testing
alvma1945 Apr 14, 2022
98145e9
updated auth controllers and routes
emiliayoffie Apr 14, 2022
6ff9bca
Merge pull request #8 from panda-whale-csny32/emilia/auth
alvma1945 Apr 14, 2022
17c5dfe
wrote some auth post requests to backend in login and signup
alvma1945 Apr 14, 2022
78f997b
fixed merge conflict
alvma1945 Apr 14, 2022
f8e4b91
attempted fetch request to backend
alvma1945 Apr 14, 2022
d77bed5
Merge pull request #9 from panda-whale-csny32/alvin/testing
alvma1945 Apr 14, 2022
c8dff2e
Style pages
Apr 14, 2022
da3b041
Fix merge conflicts
Apr 14, 2022
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
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-transform-runtime"]
}
97 changes: 97 additions & 0 deletions __tests__/route tests/books.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* Supertest is used to test the functionality of the books.js router
*/
const request = require('supertest');
const server = 'http://localhost:3000';

//can try other id's as well
const id = 3;
describe(`/books/${id}`, () => {
describe('GET', () => {
it('responds with 200 status and return JSON body in response', () => {
return (
request(server)
.get(`/books/${id}`)
// .then((res) => console.log(res.body))
.expect('Content-Type', /json/)
.expect(200)
);
});

it('the response body matches the user id', () => {
return request(server)
.get(`/books/${id}`)
.then((res) => {
expect(res.body[0].userid).toEqual(id);
});
});
});
});
//should I check that length of db is equal to length of res body or something similar? other than just checking the shape?
describe('/books/all', () => {
describe('GET', () => {
it('responds with 200 status and application/json content type', () => {
return request(server)
.get('/books/all')
.expect('Content-Type', /json/)
.expect(200);
});
it('all books in db', () => {
return request(server)
.get('/books/all')
.expect((res) => {
if (!Array.isArray(res.body)) throw new Error('Is not an array');
});
});
});
});
/*
POST REQUEST TESTS FAIL WITH EVERYTHING

describe('POST', () => {
xit('responds with 200 status and application/json content type', () => {
const newTitle = "New Title"
return request(server)
.post(`/books/${id}`)
// .expect('Content-Type', /json/) //html
// .expect(200); //500
// .then(())
.send( {
"title": "Please help us",
"author": "Oh Man",
"genreId": 11,
"statusId": 3
})
.then((res) => {
// console.log(req)
console.log('here: ', res.body[0])
expect(res.body[0]).toHaveProperty('title')

xit('new books get added to users profile in db', () => {
return request(server)
.post(`/books/${id}`)

.expect((res) => res.body.length)
.then((res) => console.log(res));
});
*/

describe(`/books/${id}`, () => {
describe('PATCH', () => {
it('responds with 200 status, has application/json content-type, and updates book status', () => {
return request(server)
.patch(`/books/${id}`)
.expect('Content-Type', /json/)
.expect(200);
});
});

describe('DELETE', () => {
it('responds with 200 status and application/json content type', () => {
return request(server)
.delete(`/books/8`)
.expect('Content-Type', /json/)
.expect(200);
});
});
});
102 changes: 102 additions & 0 deletions __tests__/route tests/reviews.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const request = require('supertest');
const server = 'http://localhost:3000';

//remove sth from the working code so the test fails
const id = 3; //can try w other id's
describe('Reviews route integration', () => {
describe('/reviews', () => {
describe('GET', () => {
it('Should return 200 response status code',() => {
return request(server)
.get('/reviews')
.expect(200)
});

it('Should return JSON body in response',() => {
return request(server)
.get('/reviews')
.expect('Content-Type', /json/)
});

it('Responds with response body being an array',() => {
return request(server)
.get('/reviews')
.then((res) => {
// console.log(res.body);
expect(res.body).toBeInstanceOf(Array);
});
});
});
});

describe(`/reviews/${id}`, () => {
describe('GET', () => {
it('Should return 200 response status code and return JSON body in response',() => {
return request(server)
.get(`/reviews/${id}`)
.expect(200)
.expect('Content-Type', /json/)
});

it('Responds with response body being an object in an array with 1 review',() => {
return request(server)
.get(`/reviews/${id}`)
.then((res) => {
for (let i = 0; i < res.body.length; i++) {
if (res.body[i]._id === id) {
// console.log("id: " + res.body[i]._id + ", review: " + res.body[i].review);
expect(res.body[i]).toHaveProperty('review');
}
}
});
});
});

describe('PATCH', () => {
it('Responds with status of 200, JSON Content-Type, and old review unequal to new review', () => {
let oldReview;
request(server)
.get(`/reviews/${id}`)
.then((res) => {
oldReview = res.body.review
console.log("this is what we need: ", oldReview)
})
return request(server)
.patch(`/reviews/${id}`)
.send({review: "New review?"})
.expect(200)
.expect('Content-Type', /json/)
.then(res => {
console.log("before res body");
expect(oldReview).not.toEqual(res.body.review)
console.log("after res body")
})
});
})

describe('DELETE', () => {
it('Responds with status 200',() => {
return request(server)
.delete(`/reviews/${id}`)
// .expect('Content-Type', '/json/')
.expect(200)
});
//NOT WORKING
xit('Responds with content type JSON',() => {
return request(server)
.delete(`/reviews/${id}`)
.expect('Content-Type', '/json/')
});


// const newReview = null;
it('Responds with a review of null',() => {
return request(server)
.delete(`/reviews/${id}`)
.then((res) => {
expect(res.body.review).toEqual(null);
});
});
});
});
});
75 changes: 74 additions & 1 deletion build/bundle.js

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions build/bundle.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
Expand All @@ -27,3 +37,40 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* React Router DOM v6.3.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router v6.3.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/** @license MUI v5.6.0
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Loading