1
//! Each window records the cells it shows with its own id, resolved front to back.
2

            
3
use crate::app::tests::overlap::overlapped;
4
use crate::hits::Target;
5
use ratatui::layout::Position;
6

            
7
#[test]
8
1
fn the_front_window_owns_its_frame_over_the_body_of_the_window_behind() {
9
1
    let (app, _, front) = overlapped();
10
1
    let hit = app.hits.hit_at(Position::new(20, 8));
11
1
    assert_eq!(
12
1
        hit.map(|(_, target, id)| (target, id)),
13
1
        Some((Target::Block, Some(front)))
14
    );
15
1
}
16

            
17
#[test]
18
1
fn a_window_shows_its_own_cells_where_nothing_covers_it() {
19
1
    let (app, rear, _) = overlapped();
20
1
    let hit = app.hits.hit_at(Position::new(5, 9));
21
1
    assert_eq!(hit.map(|(_, _, id)| id), Some(Some(rear)));
22
1
}
23

            
24
#[test]
25
1
fn the_desktop_between_windows_belongs_to_none() {
26
1
    let (app, ..) = overlapped();
27
1
    assert_eq!(app.hits.hit_at(Position::new(70, 20)), None);
28
1
}
29

            
30
#[test]
31
1
fn the_rows_of_a_window_carry_its_id() {
32
1
    let (app, _, front) = overlapped();
33
1
    let row = crate::test_support::area_of(&app, Target::Row(0));
34
1
    let hit = app.hits.hit_at(Position::new(row.x, row.y));
35
1
    assert_eq!(
36
1
        hit.map(|(_, target, id)| (target, id)),
37
1
        Some((Target::Row(0), Some(front)))
38
    );
39
1
}