-
Notifications
You must be signed in to change notification settings - Fork 6
Assignments week 2 Ahmad Zetouny #10
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on the second assignment! All the requirements are met and I especially like how you made sure to add the keys file to the gitignore.
I left a few suggestions and some comments on your test cases!
@@ -0,0 +1 @@ | |||
sources/keys.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on adding your api key in the gitignore!
import fetch from "node-fetch"; | ||
|
||
const request = supertest(app); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a test case for the GET / route?
@@ -0,0 +1,47 @@ | |||
import express from "express"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job on separating your app into server and app files, the app.js file should be in the main directory and not in sources to keep consistency!
`https://api.openweathermap.org/data/2.5/weather?q=${cityName}&APPID=${keys.API_KEY}&units=metric` | ||
); | ||
|
||
if (!response.ok) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work on checking the response code here! A suggestion would be to check if (!temp?.main?.temp) so that you are sure that the temperature is actually returned!
.expect(400, { weatherText: "City name should be a string" }, done); | ||
}); | ||
|
||
it("Checking if the WeatherAPI is online", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for this test. This is a test that the developers of the weather API should write! You should be only testing the code you wrote to make sure it works as expected. I would replace the fetch call with a call to your api and then see if a 200 is returned!
}); | ||
|
||
it("Checking if temperature is a number", async () => { | ||
const response = await fetch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above :) Call your endpoint!
No description provided.