Fix getItems not returning correct leaf_data_ variant

Change-Id: I7d008606be7a6f874ecb2e7c22638ea04d4f7639
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 3d54443..e53237b 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -37,7 +37,7 @@
     case LY_TYPE_STRING:
         return std::string(value->string());
     case LY_TYPE_ENUM:
-        return std::string(value->enm()->name());
+        return enum_{std::string(value->enm()->name())};
     default: // TODO: implement all types
         return "(can't print)"s;
     }
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index eec6d6c..b01b484 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -35,7 +35,7 @@
     case SR_STRING_T:
         return std::string(value->data()->get_string());
     case SR_ENUM_T:
-        return std::string(value->data()->get_enum());
+        return enum_{std::string(value->data()->get_enum())};
     case SR_DECIMAL64_T:
         return value->data()->get_decimal64();
     case SR_CONTAINER_T:
diff --git a/tests/setting_values.cpp b/tests/setting_values.cpp
index 9c04bf9..d15e2dc 100644
--- a/tests/setting_values.cpp
+++ b/tests/setting_values.cpp
@@ -213,5 +213,17 @@
         REQUIRE(datastore.getItems("/example-schema:*") == expected);
     }
 
+    SECTION("getItems returns correct datatypes")
+    {
+        {
+            REQUIRE_CALL(mock, write("/example-schema:leafEnum", "", "lol"));
+            datastore.setLeaf("/example-schema:leafEnum", enum_{"lol"});
+            datastore.commitChanges();
+        }
+        std::map<std::string, leaf_data_> expected{{"/example-schema:leafEnum", enum_{"lol"}}};
+
+        REQUIRE(datastore.getItems("/example-schema:leafEnum") == expected);
+    }
+
     waitForCompletionAndBitMore(seq1);
 }