resource response subtitles deserializing test added
+use crate::types::addon::ResourceResponse;
use crate::types::addon::ResourceResponse::{Metas, MetasDetailed};
use crate::types::resource::{
- Link, MetaItem, MetaItemBehaviorHints, MetaItemPreview, SeriesInfo, Video,
+ Link, MetaItem, MetaItemBehaviorHints, MetaItemPreview, SeriesInfo, Subtitles, Video,
};
use chrono::prelude::TimeZone;
use chrono::Utc;
@@ -79,3 +80,21 @@ fn deserialize_resource_response_metas_detailed() {
_ => panic!("failed getting metas detailed"),
};
}
+
+#[test]
+fn deserialize_resource_response_subtitles() {
+ let subtitles_vec = vec![Subtitles {
+ id: "id".to_owned(),
+ lang: "lang".to_owned(),
+ url: Url::parse("https://url").unwrap(),
+ }];
+ let subtitles_json = r#"{"subtitles":[{"id":"id","lang":"lang","url":"https://url/"}]}"#;
+ let subtitles_deserialize = serde_json::from_str(&subtitles_json).unwrap();
+ match subtitles_deserialize {
+ ResourceResponse::Subtitles { subtitles } => assert_eq!(
+ subtitles, subtitles_vec,
+ "subtitles deserialized successfully"
+ ),
+ _ => panic!("failed getting subtitles"),
+ };
+}
