From 536344d6c4dcab063c8f3bf7b146d25a50f5aee8 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Wed, 25 Mar 2026 10:39:55 +0100 Subject: [PATCH] add test to parse_topic_1 --- test/sensors_test.gleam | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/sensors_test.gleam b/test/sensors_test.gleam index f9f9d97..6d02b0c 100644 --- a/test/sensors_test.gleam +++ b/test/sensors_test.gleam @@ -16,3 +16,15 @@ pub fn file_read_test() { reading |> should.equal("Temperature 20.5 °C") } + +pub fn parse_topic_1_test() { + let json_string = + "{\"temp\":18.84,\"humidity\":28.690811,\"pressure\":944.67}" + let readings = sensors.parse_topic_1(json_string) + readings + |> should.equal([ + sensors.SensorReading(sensor: sensors.Temperature, value: 18.84), + sensors.SensorReading(sensor: sensors.Humidity, value: 28.690811), + sensors.SensorReading(sensor: sensors.Pressure, value: 944.67), + ]) +}