diff --git a/src/model/richtext.rs b/src/model/richtext.rs index 4f52ab7..aeb81fc 100644 --- a/src/model/richtext.rs +++ b/src/model/richtext.rs @@ -72,6 +72,13 @@ pub trait ToMarkdown { fn to_markdown_yt_host(&self, yt_host: &str) -> String; } +impl RichText { + /// Returns `true` if the rich text contains no text components. + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } +} + impl TextComponent { /// Get the text from the component pub fn get_text(&self) -> &str { diff --git a/tests/youtube.rs b/tests/youtube.rs index cc50841..0d707fe 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -730,6 +730,29 @@ fn get_video_details_agegate(rp: RustyPipe) { assert!(details.recommended.items.is_empty()); } +#[rstest] +fn get_video_details_no_desc(rp: RustyPipe) { + let details = tokio_test::block_on(rp.query().video_details("VYJNSQ_ANyA")).unwrap(); + + assert_eq!(details.id, "VYJNSQ_ANyA"); + assert_eq!(details.name, "Cricket comedy by Modi"); + assert_eq!(details.channel.id, "UC8gBy2lByHxIyoPMglerNWg"); + assert_eq!(details.channel.name, "TMP VIBES"); + assert!(!details.channel.avatar.is_empty(), "no channel avatars"); + + assert!( + details.description.is_empty(), + "got desc: `{}`", + details.description.to_plaintext() + ); + + let date = details.publish_date.unwrap(); + assert_eq!(date.date(), date!(2023 - 11 - 21)); + + assert!(!details.is_live); + assert!(!details.is_ccommons); +} + #[rstest] fn get_video_details_not_found(rp: RustyPipe) { let err = tokio_test::block_on(rp.query().video_details("abcdefgLi5X")).unwrap_err();