- #[test]
- fn handles_nested_structure() {
- let strategy = setup();
- let source = fixtures_dir();
- let output = fixture_path("output");
- let layout = read_fixture("_layout.html");
-
- let file = File {
- path: fixture_path("nested/nested.gmi"),
- file_type: FileType::Gemini,
- };
-
- strategy.handle_html(
- &source,
- &output,
- &file,
- &layout,
- );
-
- let generated_path = output.join("nested").join("nested.html");
- assert!(generated_path.exists());
-
- // Cleanup
- let _ = fs::remove_file(generated_path);
- let _ = fs::remove_dir(output.join("nested"));
- }
+ #[test]
+ fn handles_nested_structure() {
+ let test_dir = setup_test_dir();
+ let source_dir = test_dir.join("source");
+ let output_dir = test_dir.join("output");
+ create_dir_all(&source_dir.join("nested")).expect("Could not create source test directory");
+ create_dir_all(&output_dir).expect("Could not create output test directory");
+ let layout = "\
+<html>
+<head>
+<title>{{ title }}</title>
+<meta name=\"description\" content=\"{{ description }}\">
+</head>
+<body>{{ content }}</body>
+</html>
+";
+ create_test_file(
+ &source_dir.join("nested/test.gmi"),
+ "\
+--- title: Page Is Cool!
+--- description: My Description
+# Test
+Hello world
+",
+ );
+
+ let strategy = Strategy {};
+ let file = File {
+ path: source_dir.join("nested/test.gmi"),
+ file_type: FileType::Gemini,
+ };
+
+ strategy.handle_html(&source_dir, &output_dir, &file, &layout);
+
+ let html_output = output_dir.join("nested/test.html");
+ assert!(html_output.exists());
+ assert_file_contents(
+ &html_output,
+ "\
+<html>
+<head>
+<title>Page Is Cool!</title>
+<meta name=\"description\" content=\"My Description\">
+</head>
+<body><section class=\"h1\">
+<h1> Test</h1>
+<p>Hello world</p>
+</section>
+</body>
+</html>
+",
+ );