summaryrefslogtreecommitdiff
path: root/test/include
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-05-18 23:52:34 +0300
committerEd Tanous <edtanous@google.com>2023-05-18 23:54:58 +0300
commit5a60c56f08c8c65a611e559b4c1ef6886933501a (patch)
tree628436568ff3fb7359727f7bc10c916ef43120ce /test/include
parentd87fdd9e37c975de8efebb298249b559ecf6969b (diff)
downloadbmcweb-5a60c56f08c8c65a611e559b4c1ef6886933501a.tar.xz
Add a unit test for dumpHtml
We have no unit tests for this. This isn't very extensive, but we should have at least one. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I212ee528b354f2ed47f88076be009fd6e16fb760
Diffstat (limited to 'test/include')
-rw-r--r--test/include/json_html_serializer.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/include/json_html_serializer.cpp b/test/include/json_html_serializer.cpp
new file mode 100644
index 0000000000..b8afc9b727
--- /dev/null
+++ b/test/include/json_html_serializer.cpp
@@ -0,0 +1,41 @@
+#include "json_html_serializer.hpp"
+
+#include <nlohmann/json.hpp>
+
+#include <string>
+
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+
+namespace json_html_util
+{
+namespace
+{
+
+TEST(JsonHtmlSerializer, dumpHtmlLink)
+{
+ std::string out;
+ nlohmann::json j;
+ j["@odata.id"] = "/redfish/v1";
+ dumpHtml(out, j);
+ EXPECT_EQ(
+ out,
+ "<html>\n"
+ "<head>\n"
+ "<title>Redfish API</title>\n"
+ "<link href=\"/redfish.css\" rel=\"stylesheet\">\n"
+ "</head>\n"
+ "<body>\n"
+ "<div class=\"container\">\n"
+ "<img src=\"/DMTF_Redfish_logo_2017.svg\" alt=\"redfish\" height=\"406px\" width=\"576px\">\n"
+ "<div class=\"content\">\n"
+ "{<div class=tab>&quot@odata.id&quot: <a href=\"/redfish/v1\">\"/redfish/v1\"</a><br></div>}</div>\n"
+ "</div>\n"
+ "</body>\n"
+ "</html>\n");
+}
+} // namespace
+} // namespace json_html_util