]> git.scottworley.com Git - tablify/commitdiff
Plumb Config into render_all_leftovers()
authorScott Worley <scottworley@scottworley.com>
Fri, 4 Oct 2024 04:41:11 +0000 (21:41 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 4 Oct 2024 05:09:16 +0000 (22:09 -0700)
src/lib.rs

index 6d147dd9f250506eb0061a85071d6f329c438cdf..99c454dc5ad83fd1c80acb3362b855f470065426 100644 (file)
@@ -308,7 +308,7 @@ fn render_leftover(notcol: &str, instances: &[Option<String>]) -> HTML {
     }
 }
 
-fn render_all_leftovers(row: &Row) -> HTML {
+fn render_all_leftovers(config: &Config, row: &Row) -> HTML {
     let mut order: Vec<_> = row.entries.keys().collect();
     order.sort_unstable();
     HTML(
@@ -338,7 +338,7 @@ fn render_row(config: &Config, columns: &[String], rowlike: &mut Rowlike) -> HTM
                 .iter()
                 .map(|col| render_cell(col, row))
                 .collect::<HTML>();
-            let leftovers = render_all_leftovers(row);
+            let leftovers = render_all_leftovers(config, row);
             HTML(format!(
                 "<tr><th id=\"{row_label}\">{row_label}</th>{static_cells}{dynamic_cells}<td class=\"leftover\" onmouseover=\"highlight('{row_label}')\" onmouseout=\"clear_highlight('{row_label}')\">{leftovers}</td></tr>\n"
             ))
@@ -695,30 +695,39 @@ mod tests {
     #[test]
     fn test_render_leftovers() {
         assert_eq!(
-            render_all_leftovers(&Row {
-                label: "nope".to_owned(),
-                entries: HashMap::from([("foo".to_owned(), vec![None])]),
-            }),
+            render_all_leftovers(
+                &Config::default(),
+                &Row {
+                    label: "nope".to_owned(),
+                    entries: HashMap::from([("foo".to_owned(), vec![None])]),
+                }
+            ),
             HTML::from("foo")
         );
         assert_eq!(
-            render_all_leftovers(&Row {
-                label: "nope".to_owned(),
-                entries: HashMap::from([
-                    ("foo".to_owned(), vec![None]),
-                    ("bar".to_owned(), vec![None])
-                ]),
-            }),
+            render_all_leftovers(
+                &Config::default(),
+                &Row {
+                    label: "nope".to_owned(),
+                    entries: HashMap::from([
+                        ("foo".to_owned(), vec![None]),
+                        ("bar".to_owned(), vec![None])
+                    ]),
+                }
+            ),
             HTML::from("bar, foo")
         );
         assert_eq!(
-            render_all_leftovers(&Row {
-                label: "nope".to_owned(),
-                entries: HashMap::from([
-                    ("foo".to_owned(), vec![None]),
-                    ("bar".to_owned(), vec![None, None])
-                ]),
-            }),
+            render_all_leftovers(
+                &Config::default(),
+                &Row {
+                    label: "nope".to_owned(),
+                    entries: HashMap::from([
+                        ("foo".to_owned(), vec![None]),
+                        ("bar".to_owned(), vec![None, None])
+                    ]),
+                }
+            ),
             HTML::from("bar: 2, foo")
         );
     }