From: Scott Worley Date: Fri, 4 Oct 2024 20:48:57 +0000 (-0700) Subject: Tests for column_header_order() X-Git-Tag: v0.5.0~7 X-Git-Url: http://git.scottworley.com/tablify/commitdiff_plain/a638dfe78611c069402096f0c702c3f51648962c Tests for column_header_order() --- diff --git a/src/lib.rs b/src/lib.rs index 0873f2e..b4b8bbc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -595,6 +595,30 @@ mod tests { ); } + #[test] + fn test_column_header_order() { + let mut cfg = Config::default(); + + assert!(column_header_order(&cfg, &["foo".to_owned()]).eq([Some(&"foo".to_owned())])); + + cfg.static_columns.push(Some("bar".to_owned())); + assert!(column_header_order(&cfg, &["foo".to_owned()]) + .eq([Some(&"bar".to_owned()), Some(&"foo".to_owned())])); + + cfg.static_columns.push(None); + assert!(column_header_order(&cfg, &["foo".to_owned()]).eq([ + Some(&"bar".to_owned()), + None, + Some(&"foo".to_owned()) + ])); + + cfg.hidden_columns.insert("foo".to_owned()); + assert!(column_header_order(&cfg, &["foo".to_owned()]).eq([Some(&"bar".to_owned()), None])); + + cfg.hidden_columns.insert("bar".to_owned()); + assert!(column_header_order(&cfg, &["foo".to_owned()]).eq([None])); + } + #[test] fn test_render_cell() { assert_eq!(