diff --git a/rslib/src/notetype/mod.rs b/rslib/src/notetype/mod.rs index 914170bc4..5c8c7b87a 100644 --- a/rslib/src/notetype/mod.rs +++ b/rslib/src/notetype/mod.rs @@ -77,6 +77,7 @@ static SPECIAL_FIELDS: LazyLock> = LazyLock::new(|| { "Subdeck", "Tags", "Type", + "CardID", ]) }); diff --git a/rslib/src/notetype/render.rs b/rslib/src/notetype/render.rs index 490886dda..08c5677b0 100644 --- a/rslib/src/notetype/render.rs +++ b/rslib/src/notetype/render.rs @@ -214,6 +214,7 @@ fn fill_empty_fields(note: &mut Note, qfmt: &str, nt: &Notetype, tr: &I18n) { mod test { use super::*; use crate::collection::CollectionBuilder; + use crate::notetype::SPECIAL_FIELDS; #[test] fn can_render_fully() -> Result<()> { @@ -235,4 +236,20 @@ mod test { Ok(()) } + + #[test] + fn special_fields_complete() -> Result<()> { + let mut col = CollectionBuilder::default().build()?; + let mut map = HashMap::new(); + + let nt = col.get_notetype_by_name("Basic")?.unwrap(); + let note = Note::new(&nt); + let card = Card::new(0.into(), 0.try_into().unwrap(), 0.into(), 0); + let tmpl = nt.templates[0].clone(); + + col.add_special_fields(&mut map, ¬e, &card, &nt, &tmpl)?; + + assert!(map.iter().all(|val| SPECIAL_FIELDS.contains(val.0))); + Ok(()) + } }