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

Add unit test for search history end points #78

Closed
jkwening opened this issue Feb 3, 2018 · 7 comments
Closed

Add unit test for search history end points #78

jkwening opened this issue Feb 3, 2018 · 7 comments
Labels
backend help wanted Extra attention is needed testing/QA

Comments

@jkwening
Copy link
Contributor

jkwening commented Feb 3, 2018

See #59 for context. Implement unit test for the routing end points needed. You will need to incorporate authentication into test case since this will be secured data (see #38 and #76 for related information). You can reference savedPins file in tests for an example and routes/users.js and routes/saved-pins regarding routes and their controller functions.

@jkwening jkwening added help wanted Extra attention is needed backend testing/QA labels Feb 3, 2018
@gabrielgrover
Copy link
Contributor

hey @jkwening. I am thinking of tackling this issue. However when I run npm test I get an error

Cannot find module '../src/components/SigninForm'

It is coming from components.test.js in the client folder. I don't see any folder by that name in the components directory. Maybe your team is already aware of this? I am just gonna comment out that test for now and work on this issue.

@jkwening jkwening assigned jkwening and unassigned jkwening Mar 16, 2018
@jkwening
Copy link
Contributor Author

@Euklidian-Space yeah that's fine; the front end code base has change a lot since this issue was created. The related component is now in ../src/components/AccountForm - can you add a comment noting that while you're at it. Thanks for contributing!

@motosharpley can you add him to the group? Thanks.

@gabrielgrover
Copy link
Contributor

gabrielgrover commented Mar 16, 2018

hey @jkwening, I have a question,

For postSavedPins in saved-pins-controller.js there is a part in the function definition where it is checking if a pin exists in the database. It does that by looking at appReq.body.lat and appReq.body.lng . I cannot seem to find where in the middleware pipeline those properties get set. I know for this particular route verifyToken is called before postSavedPins but verify token does not mutate the body property on the appReq object.

I only ask this because the first test for POST /search/savedpins route in saved-pins-test.js is failing when i run npm test. These were test that were written before me taking on this task.

@jkwening
Copy link
Contributor Author

Hi @Euklidian-Space appReq.body.lat/lng are from the request body data that are sent along with the api request from the frontend. For a given pin/marker, it has a lat/lng data that specifies it geolocation. The frontend passes along that information in its request to the backend server to save to the database. So in writing the test, you're going to have to mimic a request response by passing the necessary correct key, value pairs in the body of the request.

Did that help?

@gabrielgrover
Copy link
Contributor

gabrielgrover commented Mar 17, 2018

@jkwening I figured it out. I didn't notice to call to .send() in the promise chain of the test. Whoever wrote this test was sending in a pin that was already being inserted into the test DB through the beforeEach(populatePins) call. I changed the test so that it correctly sends a new pin that hasn't already been inserted into the DB. I'll include it with my changes.

@gabrielgrover
Copy link
Contributor

@jkwening PR submitted.

@gabrielgrover
Copy link
Contributor

@jkwening PR was merged. This issue can be closed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend help wanted Extra attention is needed testing/QA
Projects
None yet
Development

No branches or pull requests

3 participants