mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 17:57:19 +02:00
Update tests
This commit is contained in:
parent
d52d5ff101
commit
18d810c654
1 changed files with 67 additions and 0 deletions
67
src/app.rs
67
src/app.rs
|
@ -1763,6 +1763,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_taskwarrior_tui() {
|
||||
test_draw_empty_task_report();
|
||||
setup();
|
||||
test_draw_task_report();
|
||||
test_task_tags();
|
||||
|
@ -2065,6 +2066,72 @@ mod tests {
|
|||
assert_eq!(app.current_context_filter, "");
|
||||
}
|
||||
|
||||
fn test_draw_empty_task_report() {
|
||||
let test_case = |expected: &Buffer| {
|
||||
let mut app = TTApp::new().unwrap();
|
||||
|
||||
app.task_report_next();
|
||||
app.context_next();
|
||||
|
||||
let total_tasks: u64 = 0;
|
||||
|
||||
assert!(app.get_context().is_ok());
|
||||
assert!(app.update().is_ok());
|
||||
assert_eq!(app.tasks.lock().unwrap().len(), total_tasks as usize);
|
||||
assert_eq!(app.current_context_filter, "");
|
||||
|
||||
let now = Local::now();
|
||||
let now = TimeZone::from_utc_datetime(now.offset(), &now.naive_utc());
|
||||
|
||||
app.update().unwrap();
|
||||
|
||||
let backend = TestBackend::new(50, 15);
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
app.draw(f);
|
||||
app.draw(f);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(terminal.backend().size().unwrap(), expected.area);
|
||||
terminal.backend().assert_buffer(expected);
|
||||
};
|
||||
|
||||
let mut expected = Buffer::with_lines(vec![
|
||||
"╭Task|Calendar───────────────────────────────────╮",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────╯",
|
||||
"╭Task not found──────────────────────────────────╮",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"│ │",
|
||||
"╰────────────────────────────────────────────────╯",
|
||||
"╭Filter Tasks────────────────────────────────────╮",
|
||||
"│status:pending -private │",
|
||||
"╰────────────────────────────────────────────────╯",
|
||||
]);
|
||||
|
||||
for i in 1..=4 {
|
||||
// Task
|
||||
expected
|
||||
.get_mut(i, 0)
|
||||
.set_style(Style::default().add_modifier(Modifier::BOLD));
|
||||
}
|
||||
for i in 6..=13 {
|
||||
// Calendar
|
||||
expected
|
||||
.get_mut(i, 0)
|
||||
.set_style(Style::default().add_modifier(Modifier::DIM));
|
||||
}
|
||||
|
||||
test_case(&expected);
|
||||
}
|
||||
|
||||
fn test_draw_task_report() {
|
||||
let test_case = |expected: &Buffer| {
|
||||
let mut app = TTApp::new().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue