Counts: tests read the real catalogs; the ElyTree summary is tested at 0, 1 and 2 (R2.11)
This commit is contained in:
6 files changed
+74
-7
No files matched your search
@@ -209,13 +209,7 @@ impl Tree {
|
||||
.iter()
|
||||
.filter(|entry| entry.state != State::Ignored)
|
||||
.count();
|
||||
let (icon, title) = match changed {
|
||||
0 => (IconName::CircleCheck, text(cx, "tree.clean", &[])),
|
||||
n => (
|
||||
IconName::GitBranch,
|
||||
ely_ui::i18n::counted(cx, "tree.changed", n as u64, &[("n", &n.to_string())]),
|
||||
),
|
||||
};
|
||||
let (icon, title) = summary(changed, cx);
|
||||
EmptyState::new(("tree-summary", opened.id), icon, title).into_any_element()
|
||||
}
|
||||
}
|
||||
@@ -263,3 +257,25 @@ impl Render for Tree {
|
||||
.children(self.dialog(cx))
|
||||
}
|
||||
}
|
||||
|
||||
/// The work tree's line: clean, or how many files changed.
|
||||
pub(crate) fn summary(changed: usize, cx: &App) -> (IconName, SharedString) {
|
||||
match changed {
|
||||
0 => (IconName::CircleCheck, text(cx, "tree.clean", &[])),
|
||||
n => (IconName::GitBranch, ely_ui::i18n::counted(cx, "tree.changed", n as u64, &[("n", &n.to_string())])),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[gpui::test]
|
||||
fn the_summary_counts_files_in_both_languages(cx: &mut gpui::TestAppContext) {
|
||||
cx.update(|cx| {
|
||||
ely_ui::i18n::install_as("en-US", cx);
|
||||
let said = |n: usize, cx: &gpui::App| super::summary(n, cx).1.to_string();
|
||||
assert_eq!([said(0, cx), said(1, cx), said(2, cx)], ["Nothing to commit", "1 file changed", "2 files changed"]);
|
||||
ely_ui::i18n::install_as("zh-CN", cx);
|
||||
assert_eq!([said(1, cx), said(2, cx)], ["1 个文件有改动", "2 个文件有改动"]);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user