mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix/Missing cardID special field (#4078)
This commit is contained in:
parent
b1f3783a6a
commit
11cc9287ff
2 changed files with 18 additions and 0 deletions
|
@ -77,6 +77,7 @@ static SPECIAL_FIELDS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
|
|||
"Subdeck",
|
||||
"Tags",
|
||||
"Type",
|
||||
"CardID",
|
||||
])
|
||||
});
|
||||
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue