Skip to content

Commit

Permalink
test(styled_grapheme): test StyledGrapheme methods (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka committed Aug 26, 2023
1 parent ad4d6e7 commit 292a11d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/text/grapheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,39 @@ impl<'a> Styled for StyledGrapheme<'a> {
self
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::prelude::*;

#[test]
fn new() {
let style = Style::new().yellow();
let sg = StyledGrapheme::new("a", style);
assert_eq!(sg.symbol, "a");
assert_eq!(sg.style, style);
}

#[test]
fn style() {
let style = Style::new().yellow();
let sg = StyledGrapheme::new("a", style);
assert_eq!(sg.style(), style);
}

#[test]
fn set_style() {
let style = Style::new().yellow().on_red();
let style2 = Style::new().green();
let sg = StyledGrapheme::new("a", style).set_style(style2);
assert_eq!(sg.style, style2);
}

#[test]
fn stylize() {
let style = Style::new().yellow().on_red();
let sg = StyledGrapheme::new("a", style).green();
assert_eq!(sg.style, Style::new().green().on_red());
}
}

0 comments on commit 292a11d

Please sign in to comment.