1
use super::*;
2

            
3
4
fn drawn() -> RowWindow {
4
4
    let window = RowWindow::default();
5
4
    let _ = window.fit(30, 8);
6
4
    window
7
4
}
8

            
9
#[test]
10
1
fn lines_and_pages_move_within_the_content() {
11
1
    let window = drawn();
12
1
    assert!(apply(&window, Intent::ScrollLineDown));
13
1
    assert_eq!(window.top(), 1);
14
1
    assert!(apply(&window, Intent::ScrollPageDown));
15
1
    assert_eq!(window.top(), 9);
16
1
    assert!(apply(&window, Intent::ScrollPageUp));
17
1
    assert!(apply(&window, Intent::ScrollLineUp));
18
1
    assert_eq!(window.top(), 0);
19
1
}
20

            
21
#[test]
22
1
fn scrolling_stops_at_the_first_row_and_the_last_page() {
23
1
    let window = drawn();
24
1
    assert!(apply(&window, Intent::ScrollLineUp));
25
1
    assert_eq!(window.top(), 0);
26
1
    for _ in 0..5 {
27
5
        assert!(apply(&window, Intent::ScrollPageDown));
28
    }
29
1
    assert_eq!(window.top(), 22);
30
1
}
31

            
32
#[test]
33
1
fn top_and_end_jump_to_the_first_and_last_page() {
34
1
    let window = drawn();
35
1
    assert!(apply(&window, Intent::ScrollEnd));
36
1
    assert_eq!(window.top(), 22);
37
1
    assert!(apply(&window, Intent::ScrollTop));
38
1
    assert_eq!(window.top(), 0);
39
1
}
40

            
41
#[test]
42
1
fn other_intents_are_not_consumed() {
43
1
    let window = drawn();
44
1
    assert!(!apply(&window, Intent::ListSelectNext));
45
1
    assert_eq!(window.top(), 0);
46
1
}