From 7dcdd63d4559daeb6243cef2ccca849ed11d9c63 Mon Sep 17 00:00:00 2001 From: Dimitar Apostolovski <8737118+themetar@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:54:13 +0200 Subject: [PATCH] [factory-sensors] Add test for temperature of 0 degrees (#2538) This exercise should reject solutions with `!temperature`. 1) In the story `null` is a special signal that the sensor is broken. That means in-universe the sensor will needlesly be replaced if it happens to encounter temperatures of 0 degrees. 2) In our world, the assignment requires that students make distinction between nulls and numbers. 0 is a valid number. There is no reason to have it _intentionally_ be handled differently than -1 or 1 and lumped with `null`. --- exercises/concept/factory-sensors/.meta/config.json | 3 ++- exercises/concept/factory-sensors/factory-sensors.spec.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/exercises/concept/factory-sensors/.meta/config.json b/exercises/concept/factory-sensors/.meta/config.json index 71e498c5a9..043296967e 100644 --- a/exercises/concept/factory-sensors/.meta/config.json +++ b/exercises/concept/factory-sensors/.meta/config.json @@ -4,7 +4,8 @@ ], "contributors": [ "SleeplessByte", - "junedev" + "junedev", + "themetar" ], "files": { "solution": [ diff --git a/exercises/concept/factory-sensors/factory-sensors.spec.js b/exercises/concept/factory-sensors/factory-sensors.spec.js index 01c185781b..9661decf7f 100644 --- a/exercises/concept/factory-sensors/factory-sensors.spec.js +++ b/exercises/concept/factory-sensors/factory-sensors.spec.js @@ -25,6 +25,10 @@ describe('reportOverheating', () => { expect(() => reportOverheating(null)).toThrow(ArgumentError); }); + test('should not throw if the temperature is 0°C', () => { + expect(() => reportOverheating(0)).not.toThrow(); + }); + test('should throw an OverheatingError if the temperature is 501°C', () => { expect(() => reportOverheating(501)).toThrow(OverheatingError);