X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/f93f5541f591c6b0f9a9f0091eebd20b363ebb42..a638dfe78611c069402096f0c702c3f51648962c:/src/lib.rs?ds=sidebyside 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!(