diff options
author | Tim Oram <dev@mitmaro.ca> | 2024-02-12 22:31:02 -0330 |
---|---|---|
committer | Tim Oram <dev@mitmaro.ca> | 2024-02-15 20:27:06 -0330 |
commit | bdb94556fba28fd2e31c1a0a8369acd204b6bcf0 (patch) | |
tree | b1639b9527e24e6d9bc5a5ea697b009b0e3bf8b5 | |
parent | 20fabc4de6baea9a8a07378f4c15f9f14a63dc54 (diff) |
Move view test utils into test_helpers
-rw-r--r-- | src/components/choice/tests.rs | 3 | ||||
-rw-r--r-- | src/components/help/tests.rs | 2 | ||||
-rw-r--r-- | src/test_helpers.rs | 2 | ||||
-rw-r--r-- | src/test_helpers/with_view_state.rs (renamed from src/view/testutil.rs) | 2 | ||||
-rw-r--r-- | src/testutil/module_test.rs | 16 | ||||
-rw-r--r-- | src/testutil/process_test.rs | 11 | ||||
-rw-r--r-- | src/util.rs | 2 | ||||
-rw-r--r-- | src/view.rs | 2 | ||||
-rw-r--r-- | src/view/render_slice.rs | 2 | ||||
-rw-r--r-- | src/view/thread/state.rs | 5 |
10 files changed, 27 insertions, 20 deletions
diff --git a/src/components/choice/tests.rs b/src/components/choice/tests.rs index 1c54b9c..b2019e5 100644 --- a/src/components/choice/tests.rs +++ b/src/components/choice/tests.rs @@ -4,8 +4,7 @@ use super::*; use crate::{ assert_rendered_output, input::StandardEvent, - test_helpers::assertions::assert_rendered_output::AssertRenderOptions, - view::testutil::with_view_state, + test_helpers::{assertions::assert_rendered_output::AssertRenderOptions, with_view_state}, }; #[derive(Clone, Debug, PartialEq)] diff --git a/src/components/help/tests.rs b/src/components/help/tests.rs index 824f2d9..fa62db1 100644 --- a/src/components/help/tests.rs +++ b/src/components/help/tests.rs @@ -4,7 +4,7 @@ use super::*; use crate::{ assert_rendered_output, input::{KeyModifiers, MouseEvent, MouseEventKind, StandardEvent}, - view::testutil::with_view_state, + test_helpers::with_view_state, }; fn handle_event(help: &mut Help, event: Event) { diff --git a/src/test_helpers.rs b/src/test_helpers.rs index f5b57d7..95dcbc7 100644 --- a/src/test_helpers.rs +++ b/src/test_helpers.rs @@ -12,6 +12,7 @@ mod with_git_config; mod with_temp_bare_repository; mod with_temp_repository; mod with_todo_file; +mod with_view_state; pub(crate) static JAN_2021_EPOCH: i64 = 1_609_459_200; @@ -26,4 +27,5 @@ pub(crate) use self::{ with_temp_bare_repository::with_temp_bare_repository, with_temp_repository::with_temp_repository, with_todo_file::{with_todo_file, TodoFileTestContext}, + with_view_state::{with_view_state, ViewStateTestContext}, }; diff --git a/src/view/testutil.rs b/src/test_helpers/with_view_state.rs index 186427c..c1daf8e 100644 --- a/src/view/testutil.rs +++ b/src/test_helpers/with_view_state.rs @@ -1,5 +1,3 @@ -//! Utilities for writing tests that interact with input events. - use std::time::Duration; use crate::view::{RenderAction, State, ViewAction}; diff --git a/src/testutil/module_test.rs b/src/testutil/module_test.rs index ccb0ca3..973de6e 100644 --- a/src/testutil/module_test.rs +++ b/src/testutil/module_test.rs @@ -4,19 +4,21 @@ use crate::{ input::Event, module::{Module, State}, process::Results, - test_helpers::{with_event_handler, with_todo_file, EventHandlerTestContext}, - todo_file::TodoFile, - view::{ - testutil::{with_view_state, ViewStateTestContext as ViewContext}, - RenderContext, - ViewData, + test_helpers::{ + with_event_handler, + with_todo_file, + with_view_state, + EventHandlerTestContext, + ViewStateTestContext, }, + todo_file::TodoFile, + view::{RenderContext, ViewData}, }; pub(crate) struct TestContext { pub(crate) event_handler_context: EventHandlerTestContext, pub(crate) render_context: RenderContext, - pub(crate) view_context: ViewContext, + pub(crate) view_context: ViewStateTestContext, todo_file: Option<TodoFile>, } diff --git a/src/testutil/process_test.rs b/src/testutil/process_test.rs index ca6651e..b5a00be 100644 --- a/src/testutil/process_test.rs +++ b/src/testutil/process_test.rs @@ -8,9 +8,14 @@ use crate::{ module::{self, ModuleHandler}, process::Process, runtime::ThreadStatuses, - test_helpers::{with_event_handler, with_todo_file, EventHandlerTestContext}, + test_helpers::{ + with_event_handler, + with_todo_file, + with_view_state, + EventHandlerTestContext, + ViewStateTestContext, + }, testutil::{with_search, SearchTestContext}, - view::testutil::{with_view_state, ViewStateTestContext as ViewContext}, }; pub(crate) struct TestContext<ModuleProvider: module::ModuleProvider + Send + 'static> { @@ -18,7 +23,7 @@ pub(crate) struct TestContext<ModuleProvider: module::ModuleProvider + Send + 's pub(crate) process: Process<ModuleProvider>, pub(crate) search_context: SearchTestContext, pub(crate) todo_file_path: PathBuf, - pub(crate) view_context: ViewContext, + pub(crate) view_context: ViewStateTestContext, } pub(crate) fn process_test<C, ModuleProvider: module::ModuleProvider + Send + 'static>( diff --git a/src/util.rs b/src/util.rs index 2c23f99..81eac5d 100644 --- a/src/util.rs +++ b/src/util.rs @@ -56,7 +56,7 @@ mod tests { use rstest::rstest; use super::*; - use crate::view::testutil::with_view_state; + use crate::test_helpers::with_view_state; #[rstest] #[case::scroll_left(StandardEvent::ScrollLeft, "ScrollLeft")] diff --git a/src/view.rs b/src/view.rs index 3fd3299..e509edf 100644 --- a/src/view.rs +++ b/src/view.rs @@ -21,8 +21,6 @@ mod view_line; #[cfg(test)] mod tests; -#[cfg(test)] -pub(crate) mod testutil; use anyhow::{Error, Result}; diff --git a/src/view/render_slice.rs b/src/view/render_slice.rs index 05c87d1..5eb7920 100644 --- a/src/view/render_slice.rs +++ b/src/view/render_slice.rs @@ -195,7 +195,7 @@ impl RenderSlice { } #[cfg(test)] - pub(super) const fn get_actions(&self) -> &VecDeque<RenderAction> { + pub(crate) const fn get_actions(&self) -> &VecDeque<RenderAction> { &self.actions } diff --git a/src/view/thread/state.rs b/src/view/thread/state.rs index 86b1098..bdbf35e 100644 --- a/src/view/thread/state.rs +++ b/src/view/thread/state.rs @@ -153,7 +153,10 @@ impl State { #[cfg(test)] mod tests { - use crate::view::{testutil::with_view_state, ViewData, ViewLine}; + use crate::{ + test_helpers::with_view_state, + view::{ViewData, ViewLine}, + }; #[test] fn start() { |