Code Monkey home page Code Monkey logo

tdd-bookstore's Introduction

TDD Bookstore

Your goal is to get to this:

$ yarn test
> mocha ./test/setup.js --recursive test/

  HTTP Server
    GET /ping
      ✓ should respond with "pong"
    POST /api/books
      ✓ should create a book
      when missing title
        ✓ should render 400 bad request
    with fixture data
      GET /api/books
        ✓ should render 10 books
      GET /api/books?page=2
        ✓ should render the next 10 books
      GET /api/books?author=phILip
        ✓ should render books with authors named "Philip" (case insensitive)
      GET /api/books?title=wORld
        ✓ should render books with a title including "world" (case insensitive)
      GET /api/books?year=1953
        ✓ should render books published in 1953
      GET /api/books?year=1953&title=th
        ✓ should render books published in 1953 and with a title that includes the string "th"
      GET /api/authors
        ✓ should render 10 authors
      GET /api/authors?page=2
        ✓ should render the next 10 authors
      GET /api/books/12
        when the book exists
          ✓ should render book 12
        when the book doesn't exist
          ✓ should render nothing with status 404
      GET /api/genres
        ✓ should render up to 10 genres
      POST /api/book/12
        ✓ should update the book
      POST /api/book/12/delete
        ✓ should delete the book


  16 passing (4s)

Get All The Tests To Pass! :D

Your task is to make all these tests pass by designing a database schema and writing code within /server.

Setup

npm i -g yarn
yarn

Red... Green... Refactor

yarn test
# Identify one broken test
# Change the code in /server to make the test pass
# Refactor your code (clean it up)
# Rinse and repeat until all tests pass

WARNING: DO NOT EDIT ANY FILES WITHIN /test

Pro Tips

  • You must use an express server
  • Feel free to yarn add any packages you might need
  • You should use a database of some kind
  • You need to make the HTTP endpoint for resetting your database
  • The tests only interact with your code via HTTP requests to your express app
  • yarn test -- --watch to run your tests after any change

Error? Questions?

Jared wrote this :P

tdd-bookstore's People

Contributors

deadlyicon avatar jaredatron avatar tannerwelsh avatar harmanthecarman avatar yaseenagag avatar

Watchers

 avatar Shereef Bishay avatar James Cloos 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.