summaryrefslogtreecommitdiffstats
path: root/src/modules/list/tests/help.rs
blob: 78ec6ac11f8fc2aa21b01cda029c983dd0feb8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
use super::*;
use crate::{assert_rendered_output, input::KeyCode};

#[test]
fn normal_mode_help() {
	testers::module(
		&["pick aaa c1"],
		&[Event::from(StandardEvent::Help)],
		|mut test_context| {
			let mut module = create_list(&create_config(), test_context.take_todo_file());
			module.state = ListState::Normal;
			_ = test_context.handle_all_events(&mut module);
			let view_data = test_context.build_view_data(&mut module);
			assert_rendered_output!(
				view_data,
				"{TITLE}",
				"{LEADING}",
				" Key      Action{Pad( )}",
				"{BODY}",
				" Up      |Move selection up",
				" Down    |Move selection down",
				" PageUp  |Move selection up half a page",
				" PageDown|Move selection down half a page",
				" Home    |Move selection to top of the list",
				" End     |Move selection to end of the list",
				" Left    |Scroll content to the left",
				" Right   |Scroll content to the right",
				" q       |Abort interactive rebase",
				" Q       |Immediately abort interactive rebase",
				" w       |Write interactive rebase file",
				" W       |Immediately write interactive rebase file",
				" ?       |Show help",
				" j       |Move selected lines down",
				" k       |Move selected lines up",
				" c       |Show commit information",
				" b       |Toggle break action",
				" p       |Set selected commits to be picked",
				" r       |Set selected commits to be reworded",
				" e       |Set selected commits to be edited",
				" s       |Set selected commits to be squashed",
				" f       |Set selected commits to be fixed-up",
				" d       |Set selected commits to be dropped",
				" E       |Edit an exec, label, reset or merge action's content",
				" I       |Insert a new line",
				" Delete  |Completely remove the selected lines",
				" Controlz|Undo the last change",
				" Controly|Redo the previous undone change",
				" !       |Open the todo file in the default editor",
				" v       |Enter visual selection mode",
				"{TRAILING}",
				"Press any key to close"
			);
		},
	);
}

#[test]
fn normal_mode_help_event() {
	testers::module(
		&["pick aaa c1"],
		&[Event::from(StandardEvent::Help), Event::from(KeyCode::Enter)],
		|mut test_context| {
			let mut module = create_list(&create_config(), test_context.take_todo_file());
			module.state = ListState::Normal;
			_ = test_context.handle_all_events(&mut module);
			assert!(!module.normal_mode_help.is_active());
		},
	);
}

#[test]
fn visual_mode_help() {
	testers::module(
		&["pick aaa c1"],
		&[Event::from(StandardEvent::Help)],
		|mut test_context| {
			let mut module = create_list(&create_config(), test_context.take_todo_file());
			module.state = ListState::Visual;
			_ = test_context.handle_all_events(&mut module);
			let view_data = test_context.build_view_data(&mut module);
			assert_rendered_output!(
				view_data,
				"{TITLE}",
				"{LEADING}",
				" Key      Action{Pad( )}",
				"{BODY}",
				" Up      |Move selection up",
				" Down    |Move selection down",
				" PageUp  |Move selection up half a page",
				" PageDown|Move selection down half a page",
				" Home    |Move selection to top of the list",
				" End     |Move selection to end of the list",
				" Left    |Scroll content to the left",
				" Right   |Scroll content to the right",
				" q       |Abort interactive rebase",
				" Q       |Immediately abort interactive rebase",
				" w       |Write interactive rebase file",
				" W       |Immediately write interactive rebase file",
				" ?       |Show help",
				" j       |Move selected lines down",
				" k       |Move selected lines up",
				" p       |Set selected commits to be picked",
				" r       |Set selected commits to be reworded",
				" e       |Set selected commits to be edited",
				" s       |Set selected commits to be squashed",
				" f       |Set selected commits to be fixed-up",
				" d       |Set selected commits to be dropped",
				" Delete  |Completely remove the selected lines",
				" Controlz|Undo the last change",
				" Controly|Redo the previous undone change",
				" !       |Open the todo file in the default editor",
				" v       |Exit visual selection mode",
				"{TRAILING}",
				"Press any key to close"
			);
		},
	);
}

#[test]
fn visual_mode_help_event() {
	testers::module(
		&["pick aaa c1"],
		&[Event::from(StandardEvent::Help), Event::from(KeyCode::Enter)],
		|mut test_context| {
			let mut module = create_list(&create_config(), test_context.take_todo_file());
			module.state = ListState::Visual;
			_ = test_context.handle_all_events(&mut module);
			assert!(!module.visual_mode_help.is_active());
		},
	);
}