Add simple test to prove the scan for in-buffer settings is still working.
This commit is contained in:
parent
8cd0e4ec63
commit
cd781a7dcf
@ -113,3 +113,33 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>(
|
|||||||
|
|
||||||
Ok(new_settings)
|
Ok(new_settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn scan_test() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let input = OrgSource::new(
|
||||||
|
r#"
|
||||||
|
foo
|
||||||
|
#+archive: bar
|
||||||
|
|
||||||
|
baz #+category: lorem
|
||||||
|
|
||||||
|
#+label: ipsum
|
||||||
|
|
||||||
|
#+todo: dolar
|
||||||
|
cat
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
let (remaining, settings) = scan_for_in_buffer_settings(input)?;
|
||||||
|
assert_eq!(Into::<&str>::into(remaining), "cat\n");
|
||||||
|
let keys: Vec<_> = settings.iter().map(|kw| kw.key).collect();
|
||||||
|
// category is skipped because it is not the first non-whitespace on the line.
|
||||||
|
//
|
||||||
|
// label is skipped because it is not an in-buffer setting.
|
||||||
|
assert_eq!(keys, vec!["archive", "todo"]);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user