Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for #188 #191

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/usecase/fzf_make/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,60 @@ mod test {
..init_model()
},
},
Case {
title: "Next when there is no targets to select, panic should not occur",
model: {
let mut m = Model {
targets_list_state: ListState::with_selected(ListState::default(), None),
..init_model()
};
update(
// There should not be targets because init_model has ["target0", "target1", "target2"] as target.
&mut m,
Some(Message::SearchTextAreaKeyInput(KeyEvent::from(
KeyCode::Char('w'),
))),
);
m
},
message: Some(Message::Next),
expect_model: Model {
targets_list_state: ListState::with_selected(ListState::default(), None),
search_text_area: {
let mut text_area = TextArea::default();
text_area.input(KeyEvent::from(KeyCode::Char('w')));
TextArea_(text_area)
},
..init_model()
},
},
Case {
title: "Previous when there is no targets to select, panic should not occur",
model: {
let mut m = Model {
targets_list_state: ListState::with_selected(ListState::default(), None),
..init_model()
};
update(
// There should not be targets because init_model has ["target0", "target1", "target2"] as target.
&mut m,
Some(Message::SearchTextAreaKeyInput(KeyEvent::from(
KeyCode::Char('w'),
))),
);
m
},
message: Some(Message::Previous),
expect_model: Model {
targets_list_state: ListState::with_selected(ListState::default(), None),
search_text_area: {
let mut text_area = TextArea::default();
text_area.input(KeyEvent::from(KeyCode::Char('w')));
TextArea_(text_area)
},
..init_model()
},
},
];

for mut case in cases {
Expand Down