xref: /openbmc/bmcweb/test/include/json_html_serializer.cpp (revision 5a60c56f08c8c65a611e559b4c1ef6886933501a)
1 #include "json_html_serializer.hpp"
2 
3 #include <nlohmann/json.hpp>
4 
5 #include <string>
6 
7 #include <gtest/gtest.h> // IWYU pragma: keep
8 
9 // IWYU pragma: no_include <gtest/gtest-message.h>
10 // IWYU pragma: no_include <gtest/gtest-test-part.h>
11 // IWYU pragma: no_include "gtest/gtest_pred_impl.h"
12 
13 namespace json_html_util
14 {
15 namespace
16 {
17 
18 TEST(JsonHtmlSerializer, dumpHtmlLink)
19 {
20     std::string out;
21     nlohmann::json j;
22     j["@odata.id"] = "/redfish/v1";
23     dumpHtml(out, j);
24     EXPECT_EQ(
25         out,
26         "<html>\n"
27         "<head>\n"
28         "<title>Redfish API</title>\n"
29         "<link href=\"/redfish.css\" rel=\"stylesheet\">\n"
30         "</head>\n"
31         "<body>\n"
32         "<div class=\"container\">\n"
33         "<img src=\"/DMTF_Redfish_logo_2017.svg\" alt=\"redfish\" height=\"406px\" width=\"576px\">\n"
34         "<div class=\"content\">\n"
35         "{<div class=tab>&quot@odata.id&quot: <a href=\"/redfish/v1\">\"/redfish/v1\"</a><br></div>}</div>\n"
36         "</div>\n"
37         "</body>\n"
38         "</html>\n");
39 }
40 } // namespace
41 } // namespace json_html_util
42