Quality Assurance Projects - Metric-Imperial Converter

Tell us what’s happening:
Describe your issue in details
I have been working on this project and i have passed 21 tests 1 is giving me hard time and i can’t figure out where the error is.
Someone kindly ascertain what could be the problem and guide me where necessary, i will be grateful.

Your project link(s)

solution: boilerplate-project-metricimpconverter - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0

Challenge: Quality Assurance Projects - Metric-Imperial Converter

Link to the challenge:

@kevinSmith @lasjorg @camperextraordinaire @Sky020 @Roma
kindly look through my code and and ascertain where the error could be?

Your switch:

case 'Kg':
case 'KG':
  result = 'kilogram(s)';
  break;

The input array

let input = ['gal','l','mi','km','lbs','kg'];

See something wrong?

Thanks for that error notice but again the tests aren’t passing via @freeCodeCamp project tests yet the coding is now 100%
All the 22 tests passing


Below are the tests ain’t passing where could the error be?

The tricky thing about testing is that you can make tests pass that should fail and vice versa. They need to follow the requirements.


I’d suggest looking at the tests and comparing your responses to the expected values. I don’t think the test output on the submit page is as useful.

Although for this one it does show what is wrong if you compare it to the response.

You can convert ‘gal’ to ‘L’ and vice versa. (1 gal to 3.78541 L)

All incoming units should be accepted in both upper and lower case, but should be returned in both the initUnit and returnUnit in lower case, except for liter, which should be represented as an uppercase ‘L’.

Response:

{"initNum":"1","initUnit":"gal","returnNum":3.78541,"returnUnit":"l","string":"1 gallon(s) converts to 3.78541 litre(s)"}

I have tried to check figure it out and crack my head but nothing seems to workout,kindly break it down.
I will be grateful

What specifically are you talking about, the thing I posted about?

Look at the returnUnit for liters and read the requirements.


Am stuck i can’t figure out where to begin from even after going through what you said?

I’m sure you can figure it out if you do what I told you to. Look at each response and check it against the expected values. Cases should match and strings should match.

This has really given me hard time and i can’t go beyond that, kindly guide me on what could be the error?

All incoming units should be accepted in both upper and lower case, but should be returned in both the initUnit and returnUnit in lower case, except for liter, which should be represented as an uppercase ‘L’.

async getUserInput => {
  try {
    const data1 = await $.get(getUserInput('url') + '/api/convert?input=1gal');
    assert.equal(data1.initUnit, 'gal');
    assert.equal(data1.returnUnit, 'L');
    const data2 = await $.get(getUserInput('url') + '/api/convert?input=10L');
    assert.equal(data2.initUnit, 'L');
    assert.equal(data2.returnUnit, 'gal');
    const data3 = await $.get(getUserInput('url') + '/api/convert?input=1l');
    assert.equal(data3.initUnit, 'L');
    assert.equal(data3.returnUnit, 'gal');
    const data4 = await $.get(getUserInput('url') + '/api/convert?input=10KM');
    assert.equal(data4.initUnit, 'km');
    assert.equal(data4.returnUnit, 'mi');
  } catch (xhr) {
    throw new Error(xhr.responseText || xhr.message);
  }
};

Responses:

{"initNum":"10","initUnit":"l","returnNum":2.64172,"returnUnit":"gal","string":"10 litres converts to 2.64172 gallons"}
{"initNum":"1","initUnit":"l","returnNum":0.26417,"returnUnit":"gal","string":"1 litres converts to 0.26417 gallons"}


That’s how far i have reached but as of what you sent to me i have taken time to think,re-think, research and researched but am sadly stuck and i have no option
maybe guide me more
Thank you.

Honestly i have tried using the .toUpperCase() and .toLowerCase() but nothing seems to shift and am just left there lingering in suspense pondering on what next?
Kindly advice.
Thanks

All I will say is you have the tests with the expected values. You can inspect the responses in the browser and compare them to the tests. How you make the responses match the requirements is for you to figure out.


Just as an aside. To get the two last tests (tests of the tests) to pass you have to keep the original outer suite names as they are in the starting code (all tests should be inside them).

2_functional-tests.js

suite('Functional Tests', function() {

});

1_unit-tests.js

suite('Unit Tests', function(){

});


For the functional and unit tests i passed and now here comes another problem which i have tried to work on it in every way and even done what you said but nothing seems working out but failed am seriously stuck and pondering on what next?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.