
Metric Converter Microservice
- Summary: A FreeCodeCamp challenge for a microservice that converts units from metrics to imperial and vice versa.
- Source URL: https://github.com/michellemtchai/metric-imperial-converter
- Demo URL: https://metric-imperial-converter-dqn0.onrender.com
- Stacks:
Objective
Build a microservice that fulfills the user stories and passes all the tests provided by FreeCodeCamp
Original Challenge: https://www.freecodecamp.org/learn/quality-assurance/quality-assurance-projects/metric-imperial-converter
Assignment
- Complete the necessary conversion logic in
/controllers/convertHandler.js - Complete the necessary routes in
/routes/api.js - Write tests for
tests/1_unit-tests.js - Write tests for
tests/2_unit-tests.js
Writing tests/1_unit-tests.js
convertHandlershould correctly read a whole number input.convertHandlershould correctly read a decimal number input.convertHandlershould correctly read a fractional input.convertHandlershould correctly read a fractional input with a decimal.convertHandlershould correctly return an error on a double-fraction (i.e.3/2/3).convertHandlershould correctly default to a numerical input of1when no numerical input is provided.convertHandlershould correctly read each valid input unit.convertHandlershould correctly return an error for an invalid input unit.convertHandlershould return the correct return unit for each valid input unit.convertHandlershould correctly return the spelled-out string unit for each valid input unit.convertHandlershould correctly convertgaltoL.convertHandlershould correctly convertLtogal.convertHandlershould correctly convertmitokm.convertHandlershould correctly convertkmtomi.convertHandlershould correctly convertlbstokg.convertHandlershould correctly convertkgtolbs.
Writing tests/2_unit-tests.js
- Convert a valid input such as
10L:GETrequest to/api/convert. - Convert an invalid input such as
32g:GETrequest to/api/convert. - Convert an invalid number such as
3/7.2/4kg:GETrequest to/api/convert. - Convert an invalid number AND unit such as
3/7.2/4kilomegagram:GETrequest to/api/convert. - Convert with no number such as
kg:GETrequest to/api/convert.


