1use super::config::TableStyleConfig;
4
5pub const OXUR_DEFAULT: &str = r##"[table]
7padding_left = 0
8padding_right = 0
9padding_top = 0
10padding_bottom = 0
11
12[title]
13enabled = true
14bg_color = "#F97316"
15fg_color = "#451A03"
16justification_char = " "
17vertical_fg_color = "#F97316"
18
19[header]
20bg_color = "#D45500"
21fg_color = "#451A03"
22# Ligher shades of the dark brown, useful for web, etc.:
23# #6c2905
24# #8a3507
25# #a94109
26justification_char = " "
27vertical_char = "│"
28vertical_bg_color = "#D45500"
29vertical_fg_color = "#D45500"
30
31[rows]
32colors = [
33 { bg = "#451A03", fg = "#FED7AA" },
34 { bg = "#451A03", fg = "#FDBA74" }
35]
36justification_char = " "
37
38[style]
39vertical_bg_color = "#451A03"
40vertical_fg_color = "#803300"
41
42[footer]
43enabled = true
44bg_color = "#803300"
45fg_color = "#D45500"
46vertical_bg_color = "#803300"
47vertical_fg_color = "#803300"
48"##;
49
50impl Default for TableStyleConfig {
51 fn default() -> Self {
52 toml::from_str(OXUR_DEFAULT).expect("Default Oxur theme should be valid TOML")
53 }
54}
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_default_theme_is_valid_toml() {
62 let config = TableStyleConfig::default();
64
65 assert_eq!(config.table.padding_left, 0);
67 assert_eq!(config.table.padding_right, 0);
68 assert_eq!(config.table.padding_top, 0);
69 assert_eq!(config.table.padding_bottom, 0);
70 }
71
72 #[test]
73 fn test_default_theme_has_title_config() {
74 let config = TableStyleConfig::default();
75
76 assert!(config.title.is_some());
77 let title = config.title.unwrap();
78 assert!(title.enabled);
79 assert_eq!(title.bg_color.as_deref(), Some("#F97316"));
80 assert_eq!(title.fg_color.as_deref(), Some("#451A03"));
81 }
82
83 #[test]
84 fn test_default_theme_has_header_config() {
85 let config = TableStyleConfig::default();
86
87 assert_eq!(config.header.bg_color, "#D45500");
88 assert_eq!(config.header.fg_color, "#451A03");
89 assert_eq!(config.header.justification_char, " ");
90 }
91
92 #[test]
93 fn test_default_theme_has_row_colors() {
94 let config = TableStyleConfig::default();
95
96 assert_eq!(config.rows.colors.len(), 2);
97 assert_eq!(config.rows.colors[0].bg, "#451A03");
98 assert_eq!(config.rows.colors[0].fg, "#FED7AA");
99 assert_eq!(config.rows.colors[1].bg, "#451A03");
100 assert_eq!(config.rows.colors[1].fg, "#FDBA74");
101 }
102
103 #[test]
104 fn test_default_theme_has_footer_config() {
105 let config = TableStyleConfig::default();
106
107 assert!(config.footer.is_some());
108 let footer = config.footer.unwrap();
109 assert!(footer.enabled);
110 assert_eq!(footer.bg_color.as_deref(), Some("#803300"));
111 assert_eq!(footer.fg_color.as_deref(), Some("#D45500"));
112 }
113
114 #[test]
115 fn test_oxur_default_const_parses() {
116 let result: Result<TableStyleConfig, _> = toml::from_str(OXUR_DEFAULT);
118 assert!(result.is_ok());
119 }
120}