use bbml::render; use pretty_assertions::assert_eq; use ratatui::{ prelude::*, widgets::{Paragraph, Wrap}, }; #[test] fn test_ul() { assert_eq!( render("").0, Paragraph::new(vec![ vec![ Span::styled(" - ", Style::new()), Span::styled("a", Style::new()), ] .into(), vec![ Span::styled(" - ", Style::new()), Span::styled("b", Style::new()), ] .into(), vec![ Span::styled(" - ", Style::new()), Span::styled("c", Style::new()), ] .into(), vec![].into() ]) .wrap(Wrap { trim: false }) ); } #[test] fn test_ul_multiline() { assert_eq!( render("").0, Paragraph::new(vec![ vec![ Span::styled(" - ", Style::new()), Span::styled("a", Style::new()), ] .into(), vec![ Span::styled(" ", Style::new()), Span::styled("long list item", Style::new()), ] .into(), vec![ Span::styled(" - ", Style::new()), Span::styled("b", Style::new()), ] .into(), vec![ Span::styled(" - ", Style::new()), Span::styled("c", Style::new()), ] .into(), vec![].into() ]) .wrap(Wrap { trim: false }) ); } #[test] fn test_ol() { assert_eq!( render("
  1. a
  2. b
  3. c
  4. ").0, Paragraph::new(vec![ vec![ Span::styled("1. ", Style::new()), Span::styled("a", Style::new()), ] .into(), vec![ Span::styled("2. ", Style::new()), Span::styled("b", Style::new()), ] .into(), vec![ Span::styled("3. ", Style::new()), Span::styled("c", Style::new()), ] .into(), vec![].into() ]) .wrap(Wrap { trim: false }) ); } #[test] fn test_ol_multiline() { assert_eq!( render("
    1. a
      long list item
    2. b
    3. c
    4. ").0, Paragraph::new(vec![ vec![ Span::styled("1. ", Style::new()), Span::styled("a", Style::new()), ] .into(), vec![ Span::styled(" ", Style::new()), Span::styled("long list item", Style::new()), ] .into(), vec![ Span::styled("2. ", Style::new()), Span::styled("b", Style::new()), ] .into(), vec![ Span::styled("3. ", Style::new()), Span::styled("c", Style::new()), ] .into(), vec![].into() ]) .wrap(Wrap { trim: false }) ); } #[test] fn test_ul_nested() { assert_eq!( render("").0, Paragraph::new(vec![ vec![ Span::styled(" - ", Style::new()), Span::styled("a", Style::new()), ] .into(), vec![ Span::styled(" ", Style::new()), Span::styled(" - ", Style::new()), Span::styled("b", Style::new()), ] .into(), vec![ Span::styled(" - ", Style::new()), Span::styled("c", Style::new()), ] .into(), vec![].into() ]) .wrap(Wrap { trim: false }) ); } #[test] fn test_ol_nested() { assert_eq!( render("
      1. a
        1. b
      2. c
      ").0, Paragraph::new(vec![ vec![ Span::styled("1. ", Style::new()), Span::styled("a", Style::new()), ] .into(), vec![ Span::styled(" ", Style::new()), Span::styled("1. ", Style::new()), Span::styled("b", Style::new()), ] .into(), vec![ Span::styled("2. ", Style::new()), Span::styled("c", Style::new()), ] .into(), vec![].into() ]) .wrap(Wrap { trim: false }) ); }