From a638dfe78611c069402096f0c702c3f51648962c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 4 Oct 2024 13:48:57 -0700 Subject: [PATCH] Tests for column_header_order() --- src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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!( -- 2.44.1