Skip to content

Commit 52fd5df

Browse files
committed
test: Add a test for a group with no Title
1 parent 4e70f56 commit 52fd5df

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

examples/elide_header.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use annotate_snippets::{AnnotationKind, Group, Level, Renderer, Snippet};
2+
3+
fn main() {
4+
let source = r#"# Docstring followed by a newline
5+
6+
def foobar(door, bar={}):
7+
"""
8+
"""
9+
"#;
10+
11+
let message = &[Group::new()
12+
.element(
13+
Snippet::source(source)
14+
.fold(false)
15+
.annotation(AnnotationKind::Primary.span(56..58).label("B006")),
16+
)
17+
.element(Level::HELP.title("Replace with `None`; initialize within function"))];
18+
19+
let renderer = Renderer::styled();
20+
anstream::println!("{}", renderer.render(message));
21+
}

examples/elide_header.svg

Lines changed: 44 additions & 0 deletions
Loading

tests/examples.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ fn custom_level() {
1414
assert_example(target, expected);
1515
}
1616

17+
#[test]
18+
fn elide_header() {
19+
let target = "elide_header";
20+
let expected = snapbox::file!["../examples/elide_header.svg": TermSvg];
21+
assert_example(target, expected);
22+
}
23+
1724
#[test]
1825
fn expected_type() {
1926
let target = "expected_type";

0 commit comments

Comments
 (0)