use journey::vault::Vault;
use journey::config::VaultConfig;
use std::collections::HashMap;
use tempfile::TempDir;
use chrono::{Local, NaiveDate, TimeZone};
use std::fs;
#[test]
fn test_template_variables() {
let temp_dir = TempDir::new().unwrap();
let template_path = temp_dir.path().join("template.md");
let template_content = r#"---
created: {created}
updated: {created}
---
[[{yesterday}]] [[{tomorrow}]]
## 📅️ {today} {weekday}
## 🎯
## 🕗
## 🔨
## 👀️
{note}"#;
fs::write(&template_path, template_content).unwrap();
let mut config = VaultConfig::test_config("test", temp_dir.path().to_str().unwrap());
config.template_file = Some(template_path.to_string_lossy().to_string());
let vault = Vault::new(config);
let test_date = NaiveDate::from_ymd_opt(2025, 1, 15).unwrap(); let timestamp = Local.from_local_date(&test_date).unwrap().and_hms_opt(14, 30, 0).unwrap();
let result = vault.add_note("Test note content", Some(timestamp));
assert!(result.is_ok());
let note_path = vault.get_note_path(test_date);
let content = fs::read_to_string(¬e_path).unwrap();
assert!(content.contains("2025-01-15 14:30:00")); assert!(content.contains("2025-01-14")); assert!(content.contains("2025-01-16")); assert!(content.contains("2025-01-15")); assert!(content.contains("Wednesday")); assert!(content.contains("Test note content"));
assert!(!content.contains("{created}"));
assert!(!content.contains("{yesterday}"));
assert!(!content.contains("{tomorrow}"));
assert!(!content.contains("{today}"));
assert!(!content.contains("{weekday}"));
assert!(!content.contains("{note}"));
}
#[test]
fn test_weekday_variations() {
let temp_dir = TempDir::new().unwrap();
let template_path = temp_dir.path().join("template.md");
let template_content = r#"Today is {weekday} ({Weekday})"#;
fs::write(&template_path, template_content).unwrap();
let mut config = VaultConfig::test_config("test", temp_dir.path().to_str().unwrap());
config.template_file = Some(template_path.to_string_lossy().to_string());
let vault = Vault::new(config);
let test_date = NaiveDate::from_ymd_opt(2025, 1, 15).unwrap();
let timestamp = Local.from_local_date(&test_date).unwrap().and_hms_opt(12, 0, 0).unwrap();
let result = vault.add_note("", Some(timestamp));
assert!(result.is_ok());
let note_path = vault.get_note_path(test_date);
let content = fs::read_to_string(¬e_path).unwrap();
assert!(content.contains("Wednesday")); assert!(content.contains("Wed")); }