updated with Jest

This commit is contained in:
Justin O'Reilly 2021-05-21 18:46:07 -04:00
parent 513646cebf
commit bbdfafe5d4
2 changed files with 16 additions and 14 deletions

View File

@ -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 = { module.exports = {
ftoc, ftoc,
ctof ctof,
}; };

View File

@ -1,25 +1,25 @@
const {ftoc, ctof} = require('./tempConversion') const { ftoc, ctof } = require("./tempConversion");
describe('ftoc', () => { describe("ftoc", () => {
test('works', () => { test("works", () => {
expect(ftoc(32)).toEqual(0); expect(ftoc(32)).toEqual(0);
}); });
test.skip('rounds to 1 decimal', () => { test("rounds to 1 decimal", () => {
expect(ftoc(100)).toEqual(37.8); expect(ftoc(100)).toEqual(37.8);
}); });
test.skip('works with negatives', () => { test("works with negatives", () => {
expect(ftoc(-100)).toEqual(-73.3); expect(ftoc(-100)).toEqual(-73.3);
}); });
}); });
describe('ctof', () => { describe("ctof", () => {
test.skip('works', () => { test("works", () => {
expect(ctof(0)).toEqual(32); expect(ctof(0)).toEqual(32);
}); });
test.skip('rounds to 1 decimal', () => { test("rounds to 1 decimal", () => {
expect(ctof(73.2)).toEqual(163.8); expect(ctof(73.2)).toEqual(163.8);
}); });
test.skip('works with negatives', () => { test("works with negatives", () => {
expect(ctof(-10)).toEqual(14); expect(ctof(-10)).toEqual(14);
}); });
}); });