Skip to content

Commit

Permalink
fix(test): update
Browse files Browse the repository at this point in the history
Signed-off-by: Bruce D'Arcus <bdarcus@gmail.com>
  • Loading branch information
bdarcus committed Jun 2, 2023
1 parent caba770 commit bc87a59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub struct ProcReference {
}

impl Processor {
fn get_references(&self) -> Vec<InputReference> {
pub fn get_references(&self) -> Vec<InputReference> {
let mut references = Vec::new();
for (key, value) in &self.bibliography {
let mut reference = value.clone();
Expand Down Expand Up @@ -196,7 +196,7 @@ impl Processor {
let refs = self.get_references();
let sorted_refs = self.sort_references(refs);
let grouped_refs = self.group_references(sorted_refs);

// REVIEW would prefer to avoid using mutable varibles here
let mut prochs = HashMap::new();
for (key, group) in grouped_refs {
let group_len = group.len();
Expand Down
16 changes: 8 additions & 8 deletions processor/tests/processor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ mod tests {
let style = load_style_from_file("examples/style.csl.yaml");
let bibliography = load_bibliography_from_file("examples/ex1.bib.yaml");
let processor = csln_processor::Processor::new(style, bibliography, "en-US".to_string());
let proc_refs = processor.get_proc_hints();
assert_eq!(proc_refs.len(), 5);
let refs = processor.get_references();
let sorted_refs = processor.sort_references(refs);
assert_eq!(sorted_refs.len(), 20);
// how can I test the contents of proc_references?
assert_eq!(proc_refs[0].data.title.as_deref(), Some("Title 0"));
assert_eq!(proc_refs[4].data.title.as_deref(), Some("Title 4"));
assert_eq!(sorted_refs[0].title.as_deref(), Some("Title 0"));
assert_eq!(sorted_refs[4].title.as_deref(), Some("Title 4"));
}

#[test]
fn test_get_proc_hints() {
let style = load_style_from_file("examples/style.csl.yaml");
let bibliography = load_bibliography_from_file("examples/ex1.bib.yaml");
let processor = csln_processor::Processor::new(style, bibliography, "en-US".to_string());
let proc_refs = processor.get_proc_hints();
assert_eq!(proc_refs.len(), 20);
assert_eq!(proc_refs[0].proc_hints.group_index, 1);
assert_eq!(proc_refs[1].proc_hints.group_index, 2);
let proc_hints = processor.get_proc_hints();
assert_eq!(proc_hints.keys().len(), 20);
assert_eq!(proc_hints["id-0"].group_index, 0);
}
}

0 comments on commit bc87a59

Please sign in to comment.