Skip to content

Commit

Permalink
fix: Add test case for issue #50
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Sep 10, 2024
1 parent 6d0fc83 commit 01c6850
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl From<AnsiStates> for tui::style::Style {
AnsiCode::Normal => {
style = style
.remove_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM)
.remove_modifier(Modifier::DIM);
}
AnsiCode::Italic => style = style.add_modifier(Modifier::ITALIC),
AnsiCode::Underline => style = style.add_modifier(Modifier::UNDERLINED),
Expand Down
13 changes: 12 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ansi_to_tui::IntoText;
use pretty_assertions::assert_eq;
use tui::style::Stylize;
use tui::{
style::{Color, Style},
style::{Color, Modifier, Style},
text::{Line, Span, Text},
};

Expand Down Expand Up @@ -191,6 +191,17 @@ fn test_rgb() {
}
}

#[test]
fn test_reset_sequences() {
let bytes = "not, \x1b[1mbold\x1b[22m, not anymore".as_bytes().to_vec();
let output = Text::from(Line::from(vec![
Span::raw("not, "),
Span::raw("bold").bold(),
Span::raw(", not anymore").remove_modifier(Modifier::BOLD | Modifier::DIM),
]));
test_both(bytes, output);
}

#[cfg(test)]
#[track_caller]
pub fn test_both(bytes: impl AsRef<[u8]>, other: Text) {
Expand Down

0 comments on commit 01c6850

Please sign in to comment.