Git Product home page Git Product logo

hackerrankangularintermediateweatherdetails's Introduction

WeatherFinder

JSON API URL : https://jsonmock.hackerrank.com/api/weather?name=<name>

Environment

  • Angular CLI Version: 10.0.9
  • Angular Core Version: 10.0.9
  • Node Version: 12.18.3
  • Default Port: 8000

Application Demo:

Functionality Requirements

The component must have the following functionalities:

  • The input should initially be empty. The user can type a city name into this input box to search for weather details for this city.

  • Clicking on the Search button should make an API GET call to the URL https://jsonmock.hackerrank.com/api/weather?name=<name> using the Angular HttpClient module. Here, <name> is the city name entered into the text box. For example, for the value Dallas, the API hit has to be https://jsonmock.hackerrank.com/api/weather?name=Dallas. You will always get data for cities Dallas and Oakland.

  • The response contains a data field, where data is an array of objects, and each object is a weather record. We only need to use the first record from the array for rendering in this challenge. The sample format of the data field is given below:

  "data": [
    {
      "name": "Dallas",
      "weather": "12 degree", // Format is always "<value> degree"
      "status": [
        "Wind: 2Kmph", // String
        "Humidity: 5%" // String
      ]
    }
  ]
  • The weather details should be rendered inside <div data-test-id="weather-details"></div>. This div should not be rendered initially since no API has been hit yet.

  • Each weather record contains a weather field. Retrieve the value and display in the following element - <span data-test-id="result-temperature"></span>.

  • If value in weather field is less than 20, render cold weather icon by rendering <i data-test-id="icon-cold"></i>. If the value is greater than or equal to 20, render sunny weather icon by rendering <i data-test-id="icon-sunny"></i>.

  • Each weather record contains a status field which is an array of strings.

  • The first string denotes the wind value and the second string denotes the humidity value.

    1. Render wind value in
    2. Render humidity value in
  • If no records are returned for any city by the API, you must render <div data-test-id="no-result">No Results Found</div> instead, and this element must be visible only when the data field is an empty array. This div should not be rendered initially since no API has been hit yet.

  • Please note that the input field accepts only text. Test cases take care of calling the API with valid input, so writing input validation is not required.

  • For testing purposes, please use the following cities and their corresponding weather conditions:

  Dallas - Cold
  Oakland - Sunny

Testing Requirements

  • The input should have the data-test-id attribute app-input.
  • The Search button should have the data-test-id attribute submit-button.
  • The weather details should have the data-test-id attribute weather-details.
  • The sunny icon should have the data-test-id attribute icon-sunny.
  • The cold icon should have the data-test-id attribute icon-cold.
  • The span showing temperature should have the data-test-id attribute result-temperature.
  • The div showing wind information should have the data-test-id attribute result-wind.
  • The div showing wind information should have the data-test-id attribute result-humidity.
  • The No Results Found div should have the data-test-id attribute no-result.

Project Specifications

Read Only Files

  • src/tsconfig.spec.json
  • src/app/app.component.css
  • src/app/app.module.ts
  • src/app/app.component.spec.ts
  • src/app/weatherFinder/weatherFinder.component.spec.ts

Commands

  • run:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm start
  • install:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm install
  • test:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm test

hackerrankangularintermediateweatherdetails's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.