test: add response snapshots for larger responses

This commit is contained in:
2024-06-05 07:17:16 -04:00
parent 204a618385
commit ad61f3d18a
6 changed files with 787 additions and 883 deletions

View File

@@ -0,0 +1,114 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP
exports[`requests the "/title" route with a valid id & token 1`] = `
{
"result": {
"averageScore": 66,
"bannerImage": "https://s4.anilist.co/file/anilistcdn/media/anime/banner/135643-cmQZCR3z9dB5.jpg",
"countryOfOrigin": "JP",
"coverImage": {
"extraLarge": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx135643-2kJt86K9Db9P.jpg",
"large": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx135643-2kJt86K9Db9P.jpg",
"medium": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx135643-2kJt86K9Db9P.jpg",
},
"description":
"Once upon a time, brothers Jacob and Wilhelm collected fairy tales from across the land and made them into a book. They also had a much younger sister, the innocent and curious Charlotte, who they loved very much. One day, while the brothers were telling Charlotte a fairy tale like usual, they saw that she had a somewhat melancholy look on her face. She asked them, "Do you suppose they really lived happily ever after?"
<br><br>
The pages of Grimms' Fairy Tales, written by Jacob and Wilhelm, are now presented from the unique perspective of Charlotte, who sees the stories quite differently from her brothers.
<br><br>
(Source: Netflix Anime)"
,
"episodes": 6,
"genres": [
"Fantasy",
"Thriller",
],
"id": 135643,
"idMal": 49210,
"mediaListEntry": {
"id": 402665918,
"progress": 1,
"status": "CURRENT",
},
"nextAiringEpisode": null,
"status": "FINISHED",
"title": {
"english": "The Grimm Variations",
"userPreferred": "The Grimm Variations",
},
},
"success": true,
}
`;
exports[`requests the "/title" route with a valid id but no token 1`] = `
{
"result": {
"averageScore": 66,
"bannerImage": "https://s4.anilist.co/file/anilistcdn/media/anime/banner/135643-cmQZCR3z9dB5.jpg",
"countryOfOrigin": "JP",
"coverImage": {
"extraLarge": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx135643-2kJt86K9Db9P.jpg",
"large": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx135643-2kJt86K9Db9P.jpg",
"medium": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx135643-2kJt86K9Db9P.jpg",
},
"description":
"Once upon a time, brothers Jacob and Wilhelm collected fairy tales from across the land and made them into a book. They also had a much younger sister, the innocent and curious Charlotte, who they loved very much. One day, while the brothers were telling Charlotte a fairy tale like usual, they saw that she had a somewhat melancholy look on her face. She asked them, "Do you suppose they really lived happily ever after?"
<br><br>
The pages of Grimms' Fairy Tales, written by Jacob and Wilhelm, are now presented from the unique perspective of Charlotte, who sees the stories quite differently from her brothers.
<br><br>
(Source: Netflix Anime)"
,
"episodes": 6,
"genres": [
"Fantasy",
"Thriller",
],
"id": 135643,
"idMal": 49210,
"mediaListEntry": null,
"nextAiringEpisode": null,
"status": "FINISHED",
"title": {
"english": "The Grimm Variations",
"userPreferred": "The Grimm Variations",
},
},
"success": true,
}
`;
exports[`requests the "/title" route with an unknown title from anilist but valid title from amvstrm 1`] = `
{
"result": {
"averageScore": 83,
"bannerImage": "https://s4.anilist.co/file/anilistcdn/media/anime/banner/151807-37yfQA3ym8PA.jpg",
"countryOfOrigin": "JP",
"coverImage": {
"large": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx151807-yxY3olrjZH4k.png",
"medium": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx151807-yxY3olrjZH4k.png",
},
"description":
"They say whatever doesnt kill you makes you stronger, but thats not the case for the worlds weakest hunter Sung Jinwoo. After being brutally slaughtered by monsters in a high-ranking dungeon, Jinwoo came back with the System, a program only he could see, thats leveling him up in every way. Now, hes inspired to discover the secrets behind his powers and the dungeon that spawned them.<br>
<br>
(Source: Crunchyroll) <br><br>"
,
"episodes": 12,
"genres": [
"Action",
"Adventure",
"Fantasy",
],
"id": 151807,
"idMal": 52299,
"mediaListEntry": null,
"nextAiringEpisode": null,
"status": "FINISHED",
"title": {
"english": "Solo Leveling",
"userPreferred": "Ore dake Level Up na Ken",
},
},
"success": true,
}
`;

View File

@@ -11,110 +11,21 @@ describe('requests the "/title" route', () => {
headers: new Headers({ "x-anilist-token": "asd" }),
});
expect(response.json()).resolves.toEqual({
success: true,
result: {
nextAiringEpisode: null,
mediaListEntry: {
status: "CURRENT",
progress: 1,
id: 402665918,
},
countryOfOrigin: "JP",
coverImage: {
medium:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx135643-2kJt86K9Db9P.jpg",
large:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx135643-2kJt86K9Db9P.jpg",
extraLarge:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx135643-2kJt86K9Db9P.jpg",
},
averageScore: 66,
bannerImage:
"https://s4.anilist.co/file/anilistcdn/media/anime/banner/135643-cmQZCR3z9dB5.jpg",
status: "FINISHED",
genres: ["Fantasy", "Thriller"],
episodes: 6,
description:
'Once upon a time, brothers Jacob and Wilhelm collected fairy tales from across the land and made them into a book. They also had a much younger sister, the innocent and curious Charlotte, who they loved very much. One day, while the brothers were telling Charlotte a fairy tale like usual, they saw that she had a somewhat melancholy look on her face. She asked them, "Do you suppose they really lived happily ever after?"\n<br><br>\nThe pages of Grimms\' Fairy Tales, written by Jacob and Wilhelm, are now presented from the unique perspective of Charlotte, who sees the stories quite differently from her brothers.\n<br><br>\n(Source: Netflix Anime)',
title: {
userPreferred: "The Grimm Variations",
english: "The Grimm Variations",
},
idMal: 49210,
id: 135643,
},
});
expect(response.json()).resolves.toMatchSnapshot();
expect(response.status).toBe(200);
});
it("with a valid id but no token", async () => {
const response = await app.request("/title?id=10");
expect(response.json()).resolves.toEqual({
success: true,
result: {
nextAiringEpisode: null,
mediaListEntry: null,
countryOfOrigin: "JP",
coverImage: {
medium:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx135643-2kJt86K9Db9P.jpg",
large:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx135643-2kJt86K9Db9P.jpg",
extraLarge:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx135643-2kJt86K9Db9P.jpg",
},
averageScore: 66,
bannerImage:
"https://s4.anilist.co/file/anilistcdn/media/anime/banner/135643-cmQZCR3z9dB5.jpg",
status: "FINISHED",
genres: ["Fantasy", "Thriller"],
episodes: 6,
description:
'Once upon a time, brothers Jacob and Wilhelm collected fairy tales from across the land and made them into a book. They also had a much younger sister, the innocent and curious Charlotte, who they loved very much. One day, while the brothers were telling Charlotte a fairy tale like usual, they saw that she had a somewhat melancholy look on her face. She asked them, "Do you suppose they really lived happily ever after?"\n<br><br>\nThe pages of Grimms\' Fairy Tales, written by Jacob and Wilhelm, are now presented from the unique perspective of Charlotte, who sees the stories quite differently from her brothers.\n<br><br>\n(Source: Netflix Anime)',
title: {
userPreferred: "The Grimm Variations",
english: "The Grimm Variations",
},
idMal: 49210,
id: 135643,
},
});
expect(response.json()).resolves.toMatchSnapshot();
expect(response.status).toBe(200);
});
it("with an unknown title from anilist but valid title from amvstrm", async () => {
const response = await app.request("/title?id=50");
expect(response.json()).resolves.toEqual({
success: true,
result: {
nextAiringEpisode: null,
mediaListEntry: null,
coverImage: {
medium:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx151807-yxY3olrjZH4k.png",
large:
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx151807-yxY3olrjZH4k.png",
},
averageScore: 83,
bannerImage:
"https://s4.anilist.co/file/anilistcdn/media/anime/banner/151807-37yfQA3ym8PA.jpg",
status: "FINISHED",
genres: ["Action", "Adventure", "Fantasy"],
episodes: 12,
description:
"They say whatever doesnt kill you makes you stronger, but thats not the case for the worlds weakest hunter Sung Jinwoo. After being brutally slaughtered by monsters in a high-ranking dungeon, Jinwoo came back with the System, a program only he could see, thats leveling him up in every way. Now, hes inspired to discover the secrets behind his powers and the dungeon that spawned them.<br>\n<br>\n(Source: Crunchyroll) <br><br>",
title: {
userPreferred: "Ore dake Level Up na Ken",
english: "Solo Leveling",
},
idMal: 52299,
id: 151807,
countryOfOrigin: "JP",
},
});
expect(response.json()).resolves.toMatchSnapshot();
expect(response.status).toBe(200);
});