tests pass tempConversions

This commit is contained in:
abduldoesramen 2023-06-23 16:06:43 +10:00
parent 7260c48a8d
commit 1834e8d146
2 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,15 @@
const convertToCelsius = function() {
const convertToCelsius = function (fahrenTemp) {
/* Override Bodmas to match Conversion Formulas*/
const resultCelc = (fahrenTemp - 32) * 5 / 9
return Math.round(resultCelc * 10) / 10
};
const convertToFahrenheit = function() {
const convertToFahrenheit = function (celcTemp) {
const resultFahr = (celcTemp * 9 / 5 + 32)
return Math.round(resultFahr * 10) / 10
};
// Do not edit below this line

View File

@ -4,22 +4,22 @@ describe('convertToCelsius', () => {
test('works', () => {
expect(convertToCelsius(32)).toEqual(0);
});
test.skip('rounds to 1 decimal', () => {
test('rounds to 1 decimal', () => {
expect(convertToCelsius(100)).toEqual(37.8);
});
test.skip('works with negatives', () => {
test('works with negatives', () => {
expect(convertToCelsius(-100)).toEqual(-73.3);
});
});
describe('convertToFahrenheit', () => {
test.skip('works', () => {
test('works', () => {
expect(convertToFahrenheit(0)).toEqual(32);
});
test.skip('rounds to 1 decimal', () => {
test('rounds to 1 decimal', () => {
expect(convertToFahrenheit(73.2)).toEqual(163.8);
});
test.skip('works with negatives', () => {
test('works with negatives', () => {
expect(convertToFahrenheit(-10)).toEqual(14);
});
});