Giter VIP home page Giter VIP logo

clock-in-kata's Introduction

Clock-in kata

Practice writing (tests with) Promises.

What is the task?

A time tracking tool, that optionally also accepts GPS positions. Implement the collecting of all GPS data (using promises) and sending to the server using some asynchronous method, like XHR or fetch (using promises too). Implement a clockIn() function that returns a promise and works as the diagrams below show.

Or in other words: the "boss" can determine

  1. if only times shall be tracked, without any GPS position recoding (one async action, the XHR) or
  2. GPS can be optionally added to the XHR data to be sent, getting GPS is async too,
  3. require GPS data to be sent with the XHR

Where to start?

  • start with case 1), the simplest
  • mock/stub the actual XHR and build all cases incl. error cases that might happen when sending an XHR
  • mock/stub the GPS-data retreival, implement case 2), watch out there are multiple execution paths
  • case 3) incl. retrying should be a piece of cake now
  • prevent that any test times out, ensure that all Promise-paths are tested

Next steps

If you want to get more challenging you can go the next steps like this:

  • search for a library that makes testing with Promises easier
  • use one or many library to find out which one suites best your needs
  • mock that getting retreiving GPS data takes very long, trigger a time out and report it to the user
  • write tests that verify the timing of the things happening, e.g. that the clock-in call NEVER starts before the gps-retreival had finished

Promise test libraries

What to do?

the tasks

clock-in-kata's People

Contributors

wolframkriesing avatar

Watchers

Alexandru Bolboaca 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.