Added TUI integration tests
This commit is contained in:
parent
9956c22cce
commit
abbaafe2df
4 changed files with 41 additions and 1 deletions
|
@ -25,6 +25,7 @@ cli = { path = "../cli" }
|
||||||
domain = { path = "../domain" }
|
domain = { path = "../domain" }
|
||||||
memory = { path = "../memory" }
|
memory = { path = "../memory" }
|
||||||
postgres = { path = "../postgres" }
|
postgres = { path = "../postgres" }
|
||||||
|
tui = { path = "../tui" }
|
||||||
|
|
||||||
# Additional test dependencies
|
# Additional test dependencies
|
||||||
hyper = { version = "1.0", features = ["full"] }
|
hyper = { version = "1.0", features = ["full"] }
|
||||||
|
|
|
@ -16,4 +16,6 @@ pub mod cli_tests;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod migration_tests;
|
pub mod migration_tests;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod performance_tests;
|
pub mod performance_tests;
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tui_tests;
|
25
backend/crates/integration-tests/src/tui_tests.rs
Normal file
25
backend/crates/integration-tests/src/tui_tests.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Sharenet.
|
||||||
|
*
|
||||||
|
* Sharenet is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the license at:
|
||||||
|
* https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 Continuist <continuist02@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use tui::App;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_app_initialization() {
|
||||||
|
let app = App::new();
|
||||||
|
assert_eq!(app.input(), "");
|
||||||
|
assert_eq!(app.messages(), &vec!["Welcome to Sharenet CLI!".to_string()]);
|
||||||
|
assert!(!app.should_quit());
|
||||||
|
}
|
||||||
|
|
||||||
|
// More integration tests will be added here
|
||||||
|
}
|
|
@ -90,6 +90,18 @@ impl App {
|
||||||
self.cursor_position -= 1;
|
self.cursor_position -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn input(&self) -> &str {
|
||||||
|
&self.input
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn messages(&self) -> &Vec<String> {
|
||||||
|
&self.messages
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn should_quit(&self) -> bool {
|
||||||
|
self.should_quit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_tui<U, P>(user_service: U, product_service: P) -> anyhow::Result<()>
|
pub async fn run_tui<U, P>(user_service: U, product_service: P) -> anyhow::Result<()>
|
||||||
|
|
Loading…
Add table
Reference in a new issue