From bbdfafe5d4d748e7d695ad5798c9750fb00ff30b Mon Sep 17 00:00:00 2001 From: Justin O'Reilly Date: Fri, 21 May 2021 18:46:07 -0400 Subject: [PATCH] updated with Jest --- tempConversion/tempConversion.js | 12 +++++++----- tempConversion/tempConversion.spec.js | 18 +++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tempConversion/tempConversion.js b/tempConversion/tempConversion.js index 85e28a5..cc94042 100644 --- a/tempConversion/tempConversion.js +++ b/tempConversion/tempConversion.js @@ -1,12 +1,14 @@ -const ftoc = function() { - +const ftoc = function (toCelsius) { + toCelsius = ((toCelsius - 32) * 5) / 9; + return Math.round(toCelsius * 10) / 10; }; -const ctof = function() { - +const ctof = function (toFahr) { + toFahr = (toFahr * 9) / 5 + 32; + return Math.round(toFahr * 10) / 10; }; module.exports = { ftoc, - ctof + ctof, }; diff --git a/tempConversion/tempConversion.spec.js b/tempConversion/tempConversion.spec.js index 93679cc..98ccb46 100644 --- a/tempConversion/tempConversion.spec.js +++ b/tempConversion/tempConversion.spec.js @@ -1,25 +1,25 @@ -const {ftoc, ctof} = require('./tempConversion') +const { ftoc, ctof } = require("./tempConversion"); -describe('ftoc', () => { - test('works', () => { +describe("ftoc", () => { + test("works", () => { expect(ftoc(32)).toEqual(0); }); - test.skip('rounds to 1 decimal', () => { + test("rounds to 1 decimal", () => { expect(ftoc(100)).toEqual(37.8); }); - test.skip('works with negatives', () => { + test("works with negatives", () => { expect(ftoc(-100)).toEqual(-73.3); }); }); -describe('ctof', () => { - test.skip('works', () => { +describe("ctof", () => { + test("works", () => { expect(ctof(0)).toEqual(32); }); - test.skip('rounds to 1 decimal', () => { + test("rounds to 1 decimal", () => { expect(ctof(73.2)).toEqual(163.8); }); - test.skip('works with negatives', () => { + test("works with negatives", () => { expect(ctof(-10)).toEqual(14); }); });