odin-javascript-exercises/07_tempConversion/solution/tempConversion-solution.spec.js

29 lines
715 B
JavaScript
Raw Normal View History

2023-02-01 15:53:54 -08:00
const {
convertToCelsius,
convertToFahrenheit,
} = require('./tempConversion-solution');
2022-02-20 11:07:44 -08:00
2023-02-01 15:53:54 -08:00
describe('convertToCelsius', () => {
test('works', () => {
2023-01-21 09:53:41 -08:00
expect(convertToCelsius(32)).toEqual(0);
});
2023-02-01 15:58:58 -08:00
test('rounds to 1 decimal', () => {
2023-01-21 09:53:41 -08:00
expect(convertToCelsius(100)).toEqual(37.8);
});
2023-02-01 15:58:58 -08:00
test('works with negatives', () => {
2023-01-21 09:53:41 -08:00
expect(convertToCelsius(-100)).toEqual(-73.3);
});
2022-02-20 11:07:44 -08:00
});
2023-02-01 15:53:54 -08:00
describe('convertToFahrenheit', () => {
2023-02-01 15:58:58 -08:00
test('works', () => {
2023-01-21 09:53:41 -08:00
expect(convertToFahrenheit(0)).toEqual(32);
});
2023-02-01 15:58:58 -08:00
test('rounds to 1 decimal', () => {
2023-01-21 09:53:41 -08:00
expect(convertToFahrenheit(73.2)).toEqual(163.8);
});
2023-02-01 15:58:58 -08:00
test('works with negatives', () => {
2023-01-21 09:53:41 -08:00
expect(convertToFahrenheit(-10)).toEqual(14);
});
2022-02-20 11:07:44 -08:00
});