Skip to content

Commit 649ca13

Browse files
committed
test(lib): ensure autofix does not mark unchanged entries as NeedsReview
1 parent e1b6c79 commit 649ca13

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

langcodec/src/plural_rules.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,55 @@ mod tests {
339339
}
340340
assert!(matches!(entry.status, EntryStatus::NeedsReview));
341341
}
342+
343+
#[test]
344+
fn test_autofix_does_not_mark_unchanged_entries() {
345+
// English: first entry missing 'one', second entry already complete
346+
let mut resource = Resource {
347+
metadata: Metadata {
348+
language: "en".into(),
349+
domain: String::new(),
350+
custom: Default::default(),
351+
},
352+
entries: vec![
353+
Entry {
354+
id: "apples".into(),
355+
value: Translation::Plural(
356+
Plural::new(
357+
"apples",
358+
vec![(PluralCategory::Other, "%d apples".to_string())].into_iter(),
359+
)
360+
.unwrap(),
361+
),
362+
comment: None,
363+
status: EntryStatus::Translated,
364+
custom: Default::default(),
365+
},
366+
Entry {
367+
id: "bananas".into(),
368+
value: Translation::Plural(
369+
Plural::new(
370+
"bananas",
371+
vec![
372+
(PluralCategory::One, "One banana".to_string()),
373+
(PluralCategory::Other, "%d bananas".to_string()),
374+
]
375+
.into_iter(),
376+
)
377+
.unwrap(),
378+
),
379+
comment: None,
380+
status: EntryStatus::Translated,
381+
custom: Default::default(),
382+
},
383+
],
384+
};
385+
386+
let added = autofix_fill_missing_from_other_resource(&mut resource);
387+
assert!(added >= 1);
388+
// First entry should be NeedsReview
389+
assert!(matches!(resource.entries[0].status, EntryStatus::NeedsReview));
390+
// Second entry should remain Translated
391+
assert!(matches!(resource.entries[1].status, EntryStatus::Translated));
392+
}
342393
}

0 commit comments

Comments
 (0)