added formatter inject_html test

This commit is contained in:
2026-01-08 12:32:04 +01:00
parent 1754c9fbab
commit cf3b502509
5 changed files with 41 additions and 4 deletions

11
src/tests/formatter.html Normal file
View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
{{replace_me}}
</body>
</html>

View File

@@ -1,4 +1,5 @@
#include "../config.hpp"
#include "../formatter.hpp"
#include "../markdown.hpp"
#include "../utils.hpp"
#include <catch2/catch_all.hpp>
@@ -83,3 +84,22 @@ int main() {
REQUIRE(get_html(INPUT) == EXPECTED_OUTPUT);
}
TEST_CASE("formatter injection test") {
const std::string FILE_NAME = "./tests/formatter.html";
const std::string EXPECTED_OUTPUT = R"(<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
I'm replaced!
</body>
</html>
)";
const std::string output =
inject_html_into_template(FILE_NAME, "{{replace_me}}", "I'm replaced!");
REQUIRE(EXPECTED_OUTPUT == output);
}