Coder Social home page Coder Social logo

crashtest's Introduction

crash test

This is a space to learn, crash, recover, and experiment without fear of punitive annihilation or destruction. But then again...

To run the iTunes search, do the following (from the root directory):

npm i && npm start

To run tests (from the root directory):

npm test

ItunesMedia class

Properties

  • name: The name or title of the media item.
  • genre: The genre of the media item.
  • previewUrl: The URL for a media preview.
  • shortDescription: A short description of the media item.
  • trackURL: The URL to the full media item.

Methods

  • printInfo(): Displays information about the iTunes media item to the console, iterating through each property and printing its name and value.
  • divider(): Prints a divider in the console to improve readability.

getItunesData() function

Parameters

  • name: The search term to query the iTunes API.
  • media: The type of media to search for (e.g., movie, music, etc.).

Behavior

  • Constructs a URL using the search term and media type, then makes an HTTP GET request to the iTunes API.
  • On success, processes the response to create an instance of ItunesMedia and calls printInfo() on it.
  • On failure, logs the error to the console.

promptItunesSearchTerm() function

Behavior

  • Prompts the user to enter a search term for Apple Music.
  • Prompts the user to select a media type from a list of options.
  • After receiving user input, calls getItunesData with the provided search term and media type.

ItunesMedia Tests

  • Constructor Test: Verifies that the ItunesMedia constructor correctly assigns values to its properties.
  • printInfo Method Test: Ensures that printInfo correctly logs the media's details to the console.

getItunesData Tests

  • Data Fetching Test: Checks that getItunesData correctly fetches data from the iTunes API and processes the response appropriately.
    • Mocks axios.get to simulate API calls and tests that the function handles the mock response as expected.
  • Error Handling Test: Confirms that getItunesData properly logs errors when the API request fails.
    • Mocks axios.get to throw an error and verifies that the function catches and logs the error.

crashtest's People

Contributors

johnmcswain avatar

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.