diff --git a/test/native/ha/test_components/main.cpp b/test/native/ha/test_components/main.cpp index 785a2d7..aa2917e 100644 --- a/test/native/ha/test_components/main.cpp +++ b/test/native/ha/test_components/main.cpp @@ -193,6 +193,21 @@ void testBatterySensor(void) { TEST_ASSERT_EQUAL_INT(2, doc["suggested_display_precision"]); } +void testBinarySensor(void) { + BinarySensor s("id", "a_name"); + + StaticJsonDocument<256> doc; + s.buildConfig(doc); + + TEST_ASSERT_EQUAL_STRING(MAIN_DEVICE_ID"_id", doc["unique_id"]); + TEST_ASSERT_EQUAL_STRING(MAIN_DEVICE_ID "/id/state", doc["state_topic"]); + TEST_ASSERT_EQUAL_STRING("a_name", doc["name"]); + TEST_ASSERT_EQUAL_STRING(NULL, doc["device_class"]); + TEST_ASSERT_EQUAL_STRING(NULL, doc["entity_category"]); + TEST_ASSERT_EQUAL_STRING(NULL, doc["value_template"]); + TEST_ASSERT_NOT_NULL(GenericSensor::mapSensors["id"]); +} + int main(int argc, char **argv) { UNITY_BEGIN(); RUN_TEST(testDevice); @@ -208,5 +223,6 @@ int main(int argc, char **argv) { RUN_TEST(testSwitch); RUN_TEST(testSwitchWithState); RUN_TEST(testNumber); + RUN_TEST(testBinarySensor); return UNITY_END(); }