Skip to content

Commit 1e9c943

Browse files
committed
test(fetcher/huggingface_trending): cover render_sync TextBlock shape emitting one rank-prefixed line per entry, with the heart count and the optional download count formatted and the latter omitted when absent
1 parent 804d95b commit 1e9c943

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/fetcher/huggingface_trending.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,21 @@ mod tests {
583583
assert_eq!(t.value, "(no trending entries)");
584584
}
585585

586+
#[test]
587+
fn render_sync_text_block_lists_one_rank_prefixed_line_per_entry() {
588+
let entries = vec![
589+
entry("meta-llama/Llama-3.1", 0, 3200, Some(2_100_000)),
590+
entry("author/repo", 1, 100, None),
591+
];
592+
let body = render_sync(&entries, Kind::Models, Shape::TextBlock);
593+
let Body::TextBlock(b) = body else {
594+
panic!("expected text_block");
595+
};
596+
assert_eq!(b.lines.len(), 2);
597+
assert_eq!(b.lines[0], "#1 meta-llama/Llama-3.1 ♥ 3.2k ↓ 2.1M");
598+
assert_eq!(b.lines[1], "#2 author/repo ♥ 100");
599+
}
600+
586601
#[test]
587602
fn render_sync_linked_text_block_uses_kind_aware_url() {
588603
let body = render_sync(

0 commit comments

Comments
 (0)