You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.1 KiB
Rust

use crate::client::AnimeThemesClient;
use crate::includes::*;
const TEST_QUERIES: &[&str] = &[
"vivy",
"papiri koumei",
"re:zero",
"demon slayer",
"spirited away",
"classroom of the elite",
"tower of god",
"made in abyss",
"wonder egg priority",
"spider",
"bookworm",
"slime",
"kaguya",
];
#[tokio::test]
async fn it_searches() {
let client = AnimeThemesClient::default();
let result = client
.search(
"re:zero",
&[],
SearchIncludes {
anime: AnimeInclude::default()
.themes()
.themes_entries()
.themes_entries_videos(),
..Default::default()
},
)
.await
.unwrap();
assert!(result.artists.is_some());
assert!(result.songs.is_some());
assert!(result.anime.is_some());
assert!(result.series.is_some());
assert!(result.themes.is_some());
assert!(result.videos.is_some());
}
#[tokio::test]
async fn all_models_are_correct() {
let client = AnimeThemesClient::default();
for query in TEST_QUERIES {
println!("testing query '{query}'");
let result = client
.search(query, &[], SearchIncludes::all())
.await
.unwrap();
assert!(result.artists.is_some());
assert!(result.songs.is_some());
assert!(result.anime.is_some());
assert!(result.series.is_some());
assert!(result.themes.is_some());
assert!(result.videos.is_some());
}
}
#[tokio::test]
async fn it_returns_anime_by_slug() {
let client = AnimeThemesClient::default();
let result = client
.anime("vivy_fluorite_eyes_song", AnimeInclude::default().themes())
.await
.unwrap();
assert!(result.themes.is_some());
}
#[tokio::test]
async fn it_returns_artists_by_slug() {
let client = AnimeThemesClient::default();
let result = client
.artist("lisa", ArtistInclude::default().songs())
.await
.unwrap();
assert!(result.songs.is_some());
}
#[tokio::test]
async fn it_returns_entries_by_id() {
let client = AnimeThemesClient::default();
let result = client
.entry(11948, ThemeEntryInclude::default().theme().videos())
.await
.unwrap();
assert!(result.videos.is_some());
assert!(result.theme.is_some());
}
#[tokio::test]
async fn it_returns_images_by_id() {
let client = AnimeThemesClient::default();
let result = client
.image(7247, ImageInclude::default().anime())
.await
.unwrap();
assert!(result.anime.is_some())
}
#[tokio::test]
async fn it_returns_resources_by_id() {
let client = AnimeThemesClient::default();
let result = client
.resource(3588, ResourceInclude::default().anime())
.await
.unwrap();
assert!(result.anime.is_some())
}
#[tokio::test]
async fn it_returns_series_by_slug() {
let client = AnimeThemesClient::default();
let result = client
.series("shingeki_no_kyojin", SeriesInclude::default().anime())
.await
.unwrap();
assert!(result.anime.is_some())
}
#[tokio::test]
async fn it_returns_synonyms_by_id() {
let client = AnimeThemesClient::default();
let result = client
.synonym(2462, SynonymInclude::default().anime())
.await
.unwrap();
assert!(result.anime.is_some())
}
#[tokio::test]
async fn it_returns_songs_by_id() {
let client = AnimeThemesClient::default();
let result = client
.song(8188, SongInclude::default().themes())
.await
.unwrap();
assert!(result.themes.is_some())
}
#[tokio::test]
async fn it_returns_themes_by_id() {
let client = AnimeThemesClient::default();
let result = client
.theme(8187, ThemeInclude::default().entries())
.await
.unwrap();
assert!(result.entries.is_some())
}
#[tokio::test]
async fn it_returns_videos_by_basename() {
let client = AnimeThemesClient::default();
let result = client
.video("KimiUso-OP2.webm", VideoInclude::default().entries())
.await
.unwrap();
assert!(result.entries.is_some())
}