I want to time how long I have been working on a task
So that in the future I know how much time to estimate.
- I can press a start button, in order to start a timer
- I can press a stop button, in order to stop the timer at how much time has passed since start
- I can press a reset button, in order to stop the timer and reset the displayed time to 00:00:00
- I can see the timer's current time in hours, seconds, minutes and milliseconds
We tried to stick to TDD as much as possible, so we first wrote tests for every component of the stopwatch, before actually write the code for it.
- getTime - create working getTime function
- stopwatch object - create stopwatch time storage object
- timeDifference - add a function to check the difference in time between given start and end
- startTiming - function to add a start time to the stopwatch object
- stopTiming - function to add a stop time to the stopwatch object
- toReadableTime - create a function that converts milliseconds to readable time.
- getHours - function to get the hours from the milliseconds value (displayed on a separate object).
- readableTimeToTextNode - return a textnode with a readable time string
- pushToDisplay - add to display
We didn't apply tests to native javascript methods and functions (addEventListener, etc.) - just the connected functions and inputs. This simplified our testing process a bunch because we didn't have to worry about async testing