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("- a
- b
- c
").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("- a
long list item - b
- c
").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("- a
- b
- 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 })
);
}