1
use super::*;
2

            
3
static PANES: &[PaneId] = &[PaneId::Prompt, PaneId::Scrollback];
4

            
5
5
fn pane_set() -> PaneSet {
6
5
    PaneSet::new(PANES, PaneId::Prompt)
7
5
}
8

            
9
#[test]
10
1
fn initial_focus_is_prompt() {
11
1
    let ps = pane_set();
12
1
    assert_eq!(ps.focused(), PaneId::Prompt);
13
1
    assert!(ps.is_focused(PaneId::Prompt));
14
1
    assert!(!ps.is_focused(PaneId::Scrollback));
15
1
}
16

            
17
#[test]
18
1
fn focus_moves_to_member() {
19
1
    let mut ps = pane_set();
20
1
    ps.focus(PaneId::Scrollback);
21
1
    assert!(ps.is_focused(PaneId::Scrollback));
22
1
}
23

            
24
#[test]
25
1
fn focus_on_non_member_is_noop() {
26
    static PROMPT_ONLY: &[PaneId] = &[PaneId::Prompt];
27
1
    let mut ps = PaneSet::new(PROMPT_ONLY, PaneId::Prompt);
28
1
    ps.focus(PaneId::Scrollback);
29
1
    assert!(ps.is_focused(PaneId::Prompt));
30
1
}
31

            
32
#[test]
33
1
fn cycle_forward_wraps() {
34
1
    let mut ps = pane_set();
35
1
    ps.cycle(true);
36
1
    assert!(ps.is_focused(PaneId::Scrollback));
37
1
    ps.cycle(true);
38
1
    assert!(ps.is_focused(PaneId::Prompt));
39
1
}
40

            
41
#[test]
42
1
fn cycle_backward_wraps() {
43
1
    let mut ps = pane_set();
44
1
    ps.cycle(false);
45
1
    assert!(ps.is_focused(PaneId::Scrollback));
46
1
    ps.cycle(false);
47
1
    assert!(ps.is_focused(PaneId::Prompt));
48
1
}
49

            
50
#[test]
51
1
fn cycle_forward_then_backward_returns_to_start() {
52
1
    let mut ps = pane_set();
53
1
    ps.cycle(true);
54
1
    ps.cycle(false);
55
1
    assert!(ps.is_focused(PaneId::Prompt));
56
1
}