82 lines
2.4 KiB
Rust
82 lines
2.4 KiB
Rust
// Focused style snapshot tests.
|
|
|
|
mod helpers;
|
|
|
|
use helpers::app_builder::TestAppBuilder;
|
|
use helpers::snapshot_utils::{buffer_to_style_snapshot, render_to_buffer};
|
|
use helpers::test_data::{TestChatBuilder, TestMessageBuilder};
|
|
use insta::assert_snapshot;
|
|
|
|
#[test]
|
|
fn snapshot_style_selected_chat() {
|
|
let chats = vec![
|
|
TestChatBuilder::new("Mom", 101).build(),
|
|
TestChatBuilder::new("Work Group", 102).build(),
|
|
TestChatBuilder::new("Boss", 103).build(),
|
|
];
|
|
let mut app = TestAppBuilder::new().with_chats(chats).build();
|
|
app.chat_list_state.select(Some(1));
|
|
|
|
let buffer = render_to_buffer(36, 12, |f| {
|
|
tele_tui::ui::chat_list::render(f, f.area(), &mut app);
|
|
});
|
|
|
|
assert_snapshot!("style_selected_chat", buffer_to_style_snapshot(&buffer));
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_style_selected_message() {
|
|
let chat = TestChatBuilder::new("Mom", 101).build();
|
|
let messages = vec![
|
|
TestMessageBuilder::new("First message", 201)
|
|
.sender("Mom")
|
|
.build(),
|
|
TestMessageBuilder::new("Selected message", 202)
|
|
.sender("Mom")
|
|
.build(),
|
|
];
|
|
let mut app = TestAppBuilder::new()
|
|
.with_chat(chat)
|
|
.selected_chat(101)
|
|
.with_messages(101, messages)
|
|
.selecting_message(1)
|
|
.build();
|
|
|
|
let buffer = render_to_buffer(70, 18, |f| {
|
|
tele_tui::ui::messages::render(f, f.area(), &mut app);
|
|
});
|
|
|
|
assert_snapshot!("style_selected_message", buffer_to_style_snapshot(&buffer));
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_style_reaction_picker_selection() {
|
|
let chat = TestChatBuilder::new("Mom", 101).build();
|
|
let message = TestMessageBuilder::new("React to this", 201)
|
|
.sender("Mom")
|
|
.build();
|
|
let mut app = TestAppBuilder::new()
|
|
.with_chat(chat)
|
|
.selected_chat(101)
|
|
.with_message(101, message)
|
|
.reaction_picker(
|
|
201,
|
|
vec![
|
|
"👍".to_string(),
|
|
"❤️".to_string(),
|
|
"😂".to_string(),
|
|
"🔥".to_string(),
|
|
],
|
|
)
|
|
.build();
|
|
if let tele_tui::app::ChatState::ReactionPicker { selected_index, .. } = &mut app.chat_state {
|
|
*selected_index = 2;
|
|
}
|
|
|
|
let buffer = render_to_buffer(70, 18, |f| {
|
|
tele_tui::ui::messages::render(f, f.area(), &mut app);
|
|
});
|
|
|
|
assert_snapshot!("style_reaction_picker_selection", buffer_to_style_snapshot(&buffer));
|
|
}
|