From 6b4c26c0e70b5fe798fe04315d564565bc38654b Mon Sep 17 00:00:00 2001 From: marleyrae Date: Mon, 19 Jun 2023 16:36:59 -0700 Subject: [PATCH] Make 07 tests pass --- 07_tempConversion/tempConversion.js | 18 +++++++---- 07_tempConversion/tempConversion.spec.js | 38 ++++++++++++------------ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/07_tempConversion/tempConversion.js b/07_tempConversion/tempConversion.js index 14153e0..0128aa3 100644 --- a/07_tempConversion/tempConversion.js +++ b/07_tempConversion/tempConversion.js @@ -1,11 +1,17 @@ -const convertToCelsius = function() { -}; +const round = function (number) { + return Math.round(number * 10) / 10 +} -const convertToFahrenheit = function() { -}; +const convertToCelsius = function (F) { + return round((F - 32) * (5 / 9)) +} + +const convertToFahrenheit = function (C) { + return round((C * (9 / 5)) + 32) +} // Do not edit below this line module.exports = { convertToCelsius, - convertToFahrenheit -}; + convertToFahrenheit, +} diff --git a/07_tempConversion/tempConversion.spec.js b/07_tempConversion/tempConversion.spec.js index c4f9742..95324ed 100644 --- a/07_tempConversion/tempConversion.spec.js +++ b/07_tempConversion/tempConversion.spec.js @@ -2,24 +2,24 @@ const {convertToCelsius, convertToFahrenheit} = require('./tempConversion') describe('convertToCelsius', () => { test('works', () => { - expect(convertToCelsius(32)).toEqual(0); - }); - test.skip('rounds to 1 decimal', () => { - expect(convertToCelsius(100)).toEqual(37.8); - }); - test.skip('works with negatives', () => { - expect(convertToCelsius(-100)).toEqual(-73.3); - }); -}); + expect(convertToCelsius(32)).toEqual(0) + }) + test('rounds to 1 decimal', () => { + expect(convertToCelsius(100)).toEqual(37.8) + }) + test('works with negatives', () => { + expect(convertToCelsius(-100)).toEqual(-73.3) + }) +}) describe('convertToFahrenheit', () => { - test.skip('works', () => { - expect(convertToFahrenheit(0)).toEqual(32); - }); - test.skip('rounds to 1 decimal', () => { - expect(convertToFahrenheit(73.2)).toEqual(163.8); - }); - test.skip('works with negatives', () => { - expect(convertToFahrenheit(-10)).toEqual(14); - }); -}); + test('works', () => { + expect(convertToFahrenheit(0)).toEqual(32) + }) + test('rounds to 1 decimal', () => { + expect(convertToFahrenheit(73.2)).toEqual(163.8) + }) + test('works with negatives', () => { + expect(convertToFahrenheit(-10)).toEqual(14) + }) +})