The tests 9-14 doesn’t pass. When I manually enter the tests they work, or they cannot be entered through the user interface, because I programmed it as such. For example you cannot enter two operators after each other except for “-” to signal the negative number, for the decimal points I only allow one per number and turn them back on when an operator was entered, and for the operators when a number has been entered. Should I just submit it?
Hello, I’m not sure what happens when you submit a project that doesn’t pass all test even if the app works, is this what you mean by manually testing?
By manually testing I mean for example test 9 " I should be able to add, subtract, multiply and divide a chain of numbers of any length, and when I hit “=”, the correct result should be shown in the element with the id of “display”" and gives an example of “The expression 5 - 9 + 5 should produce a result of 1”. I don’t pass this test for some reason, I manually enter the expression and get the expected result of 1. This is also true to other tests like entering “000” should produce the result of “0”. You can try them, they work fine but I’m guessing that because I made it idiot proof, meaning you cannot produce any error by just using the user interface I also made it untestable.
An input of 0 0 0 should display 0 : expected '000' to equal '0'
If you enter 5.5.5 and clear the calculator (AC) and then enter 5.5.5 again, it does not work as expected. The same happens with other decimal inputs (after clearing).
I would suggest you switch to React 17 to avoid test incompatibilities. You can add the @17 to the imports and use the old render method.
import React, { useState } from "https://esm.sh/react@17";
import { render } from "https://esm.sh/react-dom@17";
// code
render(<Display />, document.getElementById("calculator-div"));
Thank you I’ll try it tomorrow. I just have one question how is it possible to enter 5.5.5 if I turn off “.” after use, so I only allow one decimal point per number, I’ve found the “bug” that AC does not unlock the decimal point, as it should. I’ll fix at least some of it tomorrow if problems still occur we’ll meet again. Thank you again.
It should not be possible to write 5.5.5, that only refers to the input being given to the calculator. The input 5.5.5 should show (and function) as 5.55
I assume the tests are being done on the user interface, where I turn off the decimal point once it is used, and only turn it back on after an operator is pressed, therefore I only allow 1 decimal point per number, for some reason now it passed that test, but there are some test that are still failing for some reason. for example test 12 "The expression “5 * 5.5” should produce an output of “27.5"” and it does exactly that. Also as you said 000 should not be allowed and 000 should display 0, every number is converted to a float and in the case of 000 it converts it to 0 and it displays 0. Can I find the test cases somewhere so I can understand what exactly is going wrong?
I switched to React 17 and now I only fail two tests. test 10 with the zeros and test 13 which is impossible to input through the user interface since I lock operators so only one can exist between two numbers excluding the - to sign a negative number. The test "The sequence “5 * - + 5” = should produce an output of “10"” will compute as 5* (here I lock every operator except - which can be pressed once) - (now I lock - as well and only unlock every operator once a number, AC or equals is pressed) and finally 5 since the + is locked so the input will be 5*-5=-25 and not 5*-+5=10. I know how dumb users can be that’s why I lock the operators so they cannot do dumb stuff like this, but because of this I fail the test. What should I do?