howToCodeWell/code-quiz

Create Quiz API request handlers

Closed this issue · 0 comments

pfwd commented

This can only be done when #65 and #98 are complete.
To do

  • create a folder in src/api called requestHandler
  • Create src/api/requests/quiz.ts

This request handler must have two public methods

  • getAll
  • getQuiz

getAll

  • Makes API call to /api/v1/quizzes
  • Returns JSON

getQuiz

  • Makes API call to /api/v1/quiz/:id
  • Takes an integer as an :id
  • Returns JSON

Acceptance criteria

  • API getAll can be for-filled
  • API getQuiz can be for-filled
  • Unit tests have been added

TS ref for mocking axios request https://www.csrhymes.com/2022/03/09/mocking-axios-with-jest-and-typescript.html

Testing notes
Two types of tests are needed.

  1. Unit tests
  • Mocking out Axios get calls
  1. Integration tests (Not to be added in this ticket)
  • Testing the JSONServer setup