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
//! Utilities for snapshot and rendering tests.
//!
//! This module provides helpers to render a [`Component`] into a string
//! representation of the terminal buffer, which is useful for snapshot
//! testing with tools like [`insta`](https://docs.rs/insta).
//!
//! # Example
//!
//! ```no_run
//! # use tuirealm::component::Component;
//! # use tuirealm::testing::render_to_string;
//! # use tuirealm::ratatui::layout::Size;
//! #
//! fn assert_component_snapshot(component: &mut dyn Component) {
//! let rendered = render_to_string(component, Size::new(40, 10));
//! insta::assert_snapshot!(rendered);
//! }
//! ```
use crateComponent;
use crateBuffer;
use crateSize;
use crate;
/// Convert a ratatui [`Buffer`] to a string, one line per row,
/// with trailing whitespace trimmed from each line.
///
/// Each row of the buffer becomes a single line in the output,
/// terminated by a newline character.
///
/// # Arguments
///
/// * `buffer` — the ratatui [`Buffer`] to convert.
/// Render a [`Component`] into a [`TestTerminalAdapter`] and return
/// the buffer content as a string.
///
/// This creates an off-screen terminal of the given dimensions, calls
/// [`Component::view`] to render into it, and then converts the
/// resulting buffer to a string via [`buffer_to_string`].
///
/// # Arguments
///
/// * `component` — the component to render.
/// * `size` — width & height of the virtual terminal.
///
/// # Panics
///
/// Panics if the [`TestTerminalAdapter`] cannot be created or if the
/// draw call fails.