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 = {
ftoc,
ctof
ctof,
};

View File

@ -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);
});
});