diff --git a/backend/crates/integration-tests/Cargo.toml b/backend/crates/integration-tests/Cargo.toml index 802d5ca..727015b 100644 --- a/backend/crates/integration-tests/Cargo.toml +++ b/backend/crates/integration-tests/Cargo.toml @@ -25,6 +25,7 @@ cli = { path = "../cli" } domain = { path = "../domain" } memory = { path = "../memory" } postgres = { path = "../postgres" } +tui = { path = "../tui" } # Additional test dependencies hyper = { version = "1.0", features = ["full"] } diff --git a/backend/crates/integration-tests/src/lib.rs b/backend/crates/integration-tests/src/lib.rs index c5caf05..fc2a5a2 100644 --- a/backend/crates/integration-tests/src/lib.rs +++ b/backend/crates/integration-tests/src/lib.rs @@ -16,4 +16,6 @@ pub mod cli_tests; #[cfg(test)] pub mod migration_tests; #[cfg(test)] -pub mod performance_tests; \ No newline at end of file +pub mod performance_tests; +#[cfg(test)] +pub mod tui_tests; \ No newline at end of file diff --git a/backend/crates/integration-tests/src/tui_tests.rs b/backend/crates/integration-tests/src/tui_tests.rs new file mode 100644 index 0000000..e50fbe8 --- /dev/null +++ b/backend/crates/integration-tests/src/tui_tests.rs @@ -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 + */ + +#[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 +} \ No newline at end of file diff --git a/backend/crates/tui/src/lib.rs b/backend/crates/tui/src/lib.rs index adc9965..551f8ca 100644 --- a/backend/crates/tui/src/lib.rs +++ b/backend/crates/tui/src/lib.rs @@ -90,6 +90,18 @@ impl App { self.cursor_position -= 1; } } + + pub fn input(&self) -> &str { + &self.input + } + + pub fn messages(&self) -> &Vec { + &self.messages + } + + pub fn should_quit(&self) -> bool { + self.should_quit + } } pub async fn run_tui(user_service: U, product_service: P) -> anyhow::Result<()>