From 66dc9bdf6362c6d33d908b7816b1216be4dcac8f Mon Sep 17 00:00:00 2001 From: Kartavya Vashishtha Date: Thu, 9 Feb 2023 17:36:32 +0530 Subject: [PATCH] add redirect tests --- components/content/src/section.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/content/src/section.rs b/components/content/src/section.rs index 26778ac44d..920f863ee6 100644 --- a/components/content/src/section.rs +++ b/components/content/src/section.rs @@ -364,4 +364,24 @@ Bonjour le monde"# assert_eq!(section.lang, "fr".to_string()); assert_eq!(section.permalink, "http://a-website.com/fr/subcontent/"); } + + #[test] + fn can_redirect_to_external_site() { + let config = Config::default(); + let content = r#" ++++ +redirect_to = "https://bar.com/something" ++++ +Example"# + .to_string(); + let res = Section::parse( + Path::new("content/subcontent/_index.md"), + &content, + &config, + &PathBuf::new(), + ); + assert!(res.is_ok()); + let section = res.unwrap(); + assert_eq!(section.meta.redirect_to, Some("https://bar.com/something".to_owned())); + } }