odin-default-js-exercises/07_tempConversion/solution/tempConversion-solution.spe...

29 lines
715 B
JavaScript
Raw Permalink Normal View History

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