My code seems to be working, executing fine, and when I console.log the values concerning the 4 test I’m not passing, it is logging the correct values.
But, my code is not passing 4 test:
“invalid number”,
“invalid unit”,
“invalid number and unit”,
“initNum initUnit converts to returnNum returnUnit”
Answer:
If in app.js you use "if " statements to check if “invalid number”, “invalid unit”, or “invalid number” and “invalid unit” are returned by the variables “initNum” and “initUnit” and use res.json("invalid number"), res.json("invalid unit"), res.json("invalid number and unit") before res.json({initNum, initUnit, init_Units, returnNum, returnUnit, return_Unit, string: toString }) make sure in the functional test with respects to each one of those res.json()s you test only for that string within it… for example: for “invalid number and unit” in ‘Convert 3/7.2/4kilomegagram (invalid number and unit)’ test, test for assert.equal(req.body, "invalid number and unit") and not for req.body.initNum and req.body.initUnit because they wont be there since the res.json is only sending the string “invalid number and unit”.
for my other problem: “initNum initUnit converts to returnNum returnUnit”,
I was plugging in the wrong variables. “initUnit” should have been “init_Units” and “returnUnit” should have been “return_Unit”:
let toString = convertHandler.getString(initNum, init_Units, returnNum, return_Units);
and test for that with assert.equal(input/actual-value, expected-value) ;
Kindly provide your code work please, because I am facing some issues to pass the test, please help me out
My glitch link: https://glitch.com/edit/#!/measuremental