Exploring the combination of different data types using a simple addition function. For instance, when adding 1 + 1, we expect to get 2, and when adding 1 + "one", the result should be "1one". Below is the content of my functions.js file:
module.exports = {
addingTwoDataTypes(one, two) {
return (one + two);
}
};
Here is my test file implementation:
var expect = require("chai").expect;
var functions = require("../lib/functions")
describe("addingTwoDataTypes()", function () {
it("should return the sum of two numbers", function() {
var results = functions.addingTwoDataTypes(2 + 2);
expect(results).to.equal(4);
});
});
After executing the test, an error was encountered as shown below:
addingTwoDataTypes()
1) should return the sum of two numbers
0 passing (12ms)
1 failing
1) addingTwoDataTypes()
should return the sum of two numbers:
AssertionError: expected NaN to equal 4
+ expected - actual
-NaN
+4
at Context.<anonymous> (test/test.js:7:26)
npm ERR! Test failed. See above for more details.