Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Zetouny
Copy link

@Zetouny Zetouny commented May 5, 2025

No description provided.

Copy link

@Pandelissym Pandelissym left a 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

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);

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";

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) {

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 () => {

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(

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants