Skip to content

Commit

Permalink
Add unit test for #188 (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyu08 authored Jan 4, 2024
1 parent a8810fc commit d2c816f
Showing 1 changed file with 54 additions and 0 deletions.
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

0 comments on commit d2c816f

Please sign in to comment.