Skip to content

Commit bdb9455

Browse files
committed
Move view test utils into test_helpers
1 parent 20fabc4 commit bdb9455

File tree

10 files changed

+27
-20
lines changed

10 files changed

+27
-20
lines changed

src/components/choice/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use super::*;
44
use crate::{
55
assert_rendered_output,
66
input::StandardEvent,
7-
test_helpers::assertions::assert_rendered_output::AssertRenderOptions,
8-
view::testutil::with_view_state,
7+
test_helpers::{assertions::assert_rendered_output::AssertRenderOptions, with_view_state},
98
};
109

1110
#[derive(Clone, Debug, PartialEq)]

src/components/help/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::*;
44
use crate::{
55
assert_rendered_output,
66
input::{KeyModifiers, MouseEvent, MouseEventKind, StandardEvent},
7-
view::testutil::with_view_state,
7+
test_helpers::with_view_state,
88
};
99

1010
fn handle_event(help: &mut Help, event: Event) {

src/test_helpers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod with_git_config;
1212
mod with_temp_bare_repository;
1313
mod with_temp_repository;
1414
mod with_todo_file;
15+
mod with_view_state;
1516

1617
pub(crate) static JAN_2021_EPOCH: i64 = 1_609_459_200;
1718

@@ -26,4 +27,5 @@ pub(crate) use self::{
2627
with_temp_bare_repository::with_temp_bare_repository,
2728
with_temp_repository::with_temp_repository,
2829
with_todo_file::{with_todo_file, TodoFileTestContext},
30+
with_view_state::{with_view_state, ViewStateTestContext},
2931
};

src/view/testutil.rs renamed to src/test_helpers/with_view_state.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//! Utilities for writing tests that interact with input events.
2-
31
use std::time::Duration;
42

53
use crate::view::{RenderAction, State, ViewAction};

src/testutil/module_test.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ use crate::{
44
input::Event,
55
module::{Module, State},
66
process::Results,
7-
test_helpers::{with_event_handler, with_todo_file, EventHandlerTestContext},
8-
todo_file::TodoFile,
9-
view::{
10-
testutil::{with_view_state, ViewStateTestContext as ViewContext},
11-
RenderContext,
12-
ViewData,
7+
test_helpers::{
8+
with_event_handler,
9+
with_todo_file,
10+
with_view_state,
11+
EventHandlerTestContext,
12+
ViewStateTestContext,
1313
},
14+
todo_file::TodoFile,
15+
view::{RenderContext, ViewData},
1416
};
1517

1618
pub(crate) struct TestContext {
1719
pub(crate) event_handler_context: EventHandlerTestContext,
1820
pub(crate) render_context: RenderContext,
19-
pub(crate) view_context: ViewContext,
21+
pub(crate) view_context: ViewStateTestContext,
2022
todo_file: Option<TodoFile>,
2123
}
2224

src/testutil/process_test.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ use crate::{
88
module::{self, ModuleHandler},
99
process::Process,
1010
runtime::ThreadStatuses,
11-
test_helpers::{with_event_handler, with_todo_file, EventHandlerTestContext},
11+
test_helpers::{
12+
with_event_handler,
13+
with_todo_file,
14+
with_view_state,
15+
EventHandlerTestContext,
16+
ViewStateTestContext,
17+
},
1218
testutil::{with_search, SearchTestContext},
13-
view::testutil::{with_view_state, ViewStateTestContext as ViewContext},
1419
};
1520

1621
pub(crate) struct TestContext<ModuleProvider: module::ModuleProvider + Send + 'static> {
1722
pub(crate) event_handler_context: EventHandlerTestContext,
1823
pub(crate) process: Process<ModuleProvider>,
1924
pub(crate) search_context: SearchTestContext,
2025
pub(crate) todo_file_path: PathBuf,
21-
pub(crate) view_context: ViewContext,
26+
pub(crate) view_context: ViewStateTestContext,
2227
}
2328

2429
pub(crate) fn process_test<C, ModuleProvider: module::ModuleProvider + Send + 'static>(

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod tests {
5656
use rstest::rstest;
5757

5858
use super::*;
59-
use crate::view::testutil::with_view_state;
59+
use crate::test_helpers::with_view_state;
6060

6161
#[rstest]
6262
#[case::scroll_left(StandardEvent::ScrollLeft, "ScrollLeft")]

src/view.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ mod view_line;
2121

2222
#[cfg(test)]
2323
mod tests;
24-
#[cfg(test)]
25-
pub(crate) mod testutil;
2624

2725
use anyhow::{Error, Result};
2826

src/view/render_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl RenderSlice {
195195
}
196196

197197
#[cfg(test)]
198-
pub(super) const fn get_actions(&self) -> &VecDeque<RenderAction> {
198+
pub(crate) const fn get_actions(&self) -> &VecDeque<RenderAction> {
199199
&self.actions
200200
}
201201

src/view/thread/state.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ impl State {
153153

154154
#[cfg(test)]
155155
mod tests {
156-
use crate::view::{testutil::with_view_state, ViewData, ViewLine};
156+
use crate::{
157+
test_helpers::with_view_state,
158+
view::{ViewData, ViewLine},
159+
};
157160

158161
#[test]
159162
fn start() {

0 commit comments

Comments
 (0)