Skip to content

Commit 5d96306

Browse files
committed
Fix action_line macro selected assertion
The action_line macro was not correctly asserting that unselected lines were not selected. This updates the assertion to check selection on unselected line, fixes some error output formatting around selected lines, and fixes the few tests that were not using the correct selected action line.
1 parent 22230cb commit 5d96306

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/core/src/modules/list/tests/change_action.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ fn visual_mode_action_change_to_drop() {
4141
assert_rendered_output!(
4242
Body view_data,
4343
action_line!(Pick "aaa", "c1"),
44-
action_line!(Drop "aaa", "c2"),
45-
action_line!(Drop "aaa", "c3"),
46-
action_line!(Drop "aaa", "c4"),
44+
action_line!(Selected Drop "aaa", "c2"),
45+
action_line!(Selected Drop "aaa", "c3"),
46+
action_line!(Selected Drop "aaa", "c4"),
4747
action_line!(Pick "aaa", "c5")
4848
);
4949
},
@@ -260,7 +260,7 @@ fn normal_mode_action_change_to_squash() {
260260
_ = test_context.handle_all_events(&mut module);
261261
let view_data = test_context.build_view_data(&mut module);
262262
assert_rendered_output!(
263-
Body view_data, action_line!(Squash "aaa", "c1")
263+
Body view_data, action_line!(Selected Squash "aaa", "c1")
264264
);
265265
},
266266
);
@@ -290,9 +290,9 @@ fn visual_mode_action_change_to_squash() {
290290
assert_rendered_output!(
291291
Body view_data,
292292
action_line!(Pick "aaa", "c1"),
293-
action_line!(Squash "aaa", "c2"),
294-
action_line!(Squash "aaa", "c3"),
295-
action_line!(Squash "aaa", "c4"),
293+
action_line!(Selected Squash "aaa", "c2"),
294+
action_line!(Selected Squash "aaa", "c3"),
295+
action_line!(Selected Squash "aaa", "c4"),
296296
action_line!(Pick "aaa", "c5")
297297
);
298298
},

src/core/src/testutil/action_line.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ impl ActionPattern {
7373

7474
impl LinePattern for ActionPattern {
7575
fn matches(&self, rendered: &str) -> bool {
76-
if self.selected && !rendered.contains("{Selected}") {
76+
if rendered.contains("{Selected}") {
77+
if !self.selected {
78+
return false;
79+
}
80+
}
81+
else if self.selected {
7782
return false;
7883
}
7984

@@ -101,10 +106,10 @@ impl LinePattern for ActionPattern {
101106

102107
fn expected(&self) -> String {
103108
if self.selected {
104-
format!("> {}", replace_invisibles(self.line.to_text().as_str()))
109+
replace_invisibles(format!("> {}", self.line.to_text()).as_str())
105110
}
106111
else {
107-
format!(" {}", replace_invisibles(self.line.to_text().as_str()))
112+
replace_invisibles(format!(" {}", self.line.to_text()).as_str())
108113
}
109114
}
110115

@@ -113,7 +118,7 @@ impl LinePattern for ActionPattern {
113118
else {
114119
return String::from(rendered);
115120
};
116-
if self.selected {
121+
if rendered.contains("{Selected}") {
117122
replace_invisibles(format!("> {}", actual_line_parsed.to_text()).as_str())
118123
}
119124
else {

0 commit comments

Comments
 (0)