diff --git a/src/checkTemp.ts b/src/checkTemp.ts new file mode 100644 index 0000000..8a23ab3 --- /dev/null +++ b/src/checkTemp.ts @@ -0,0 +1,8 @@ +/** + * Checks if the temperature is within a safe range. + * @param temp - temperature in Celsius + * @returns true if safe (between 18°C and 30°C), false otherwise + */ +export function checkTemperature(temp: number): boolean { + return temp >= 18 && temp <= 30; +} diff --git a/src/test/checkTemp.tests.ts b/src/test/checkTemp.tests.ts new file mode 100644 index 0000000..07dabd1 --- /dev/null +++ b/src/test/checkTemp.tests.ts @@ -0,0 +1,17 @@ +import { describe, it, expect } from 'vitest'; +import { checkTemperature } from '../checkTemp'; + +describe('checkTemperature', () => { + it('returns true for temperatures within safe range', () => { + expect(checkTemperature(20)).toBe(true); + expect(checkTemperature(25)).toBe(true); + }); + + it('returns false for temperatures below safe range', () => { + expect(checkTemperature(10)).toBe(false); + }); + + it('returns false for temperatures above safe range', () => { + expect(checkTemperature(35)).toBe(false); + }); +});