diff --git a/app.js b/app.js new file mode 100644 index 00000000..89337b42 --- /dev/null +++ b/app.js @@ -0,0 +1,16 @@ +const fromEuroToDollar = function(valueInEuro) { + let valueInDollar = valueInEuro * 1.07; + return valueInDollar; +} + +const fromDollarToYen = function(valueInDollar) { + let valueInYen = valueInDollar * 149.03; + return valueInYen; +} + +const fromYenToPound = function(valueInYen) { + let valueInPound = valueInYen * 0.0072; + return valueInPound; +} + +module.exports = { fromEuroToDollar, fromDollarToYen, fromYenToPound }; \ No newline at end of file diff --git a/test.js b/test.js new file mode 100644 index 00000000..8eaca9d6 --- /dev/null +++ b/test.js @@ -0,0 +1,17 @@ +test("One euro should be 1.07 dollars", function() { + // Import the function from app.js + const { fromEuroToDollar } = require('./app.js'); + expect(fromEuroToDollar(3.5)).toBe(3.745); +}) + +test("Conversion from USD to JPY (1 USD = 149.03 JPY)", function() { + // Import the function from app.js + const { fromDollarToYen } = require('./app.js') + expect(fromDollarToYen(10)).toBe(1490.3); +}) + +test("Conversion from JPY to GBP (1 JPY = 0.0072 GBP)", function() { + // Import the function from app.js + const { fromYenToPound } = require('./app.js') + expect(fromYenToPound(1000)).toBe(7.2); +})