12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { baseUrl, defaultFetchOpts } from "./constants";
- import { checkAlbumProps, checkArtistProps } from "./hooks";
- describe("GET /album/:id", () => {
- //#region /album/:id
- it("Album details yields correct props", async () => {
- const res = await fetch(`${baseUrl}/album/7105950`, defaultFetchOpts);
- const body = await res.json();
- expect(res.status).toBe(200);
- expect(body?.error).toEqual(false);
- expect(body?.matches).toEqual(1);
- checkAlbumProps(body?.album);
- checkArtistProps(body?.album?.artist);
- });
- //#region inv /album/:id
- it("Invalid album yields error", async () => {
- const res = await fetch(`${baseUrl}/album/0`, defaultFetchOpts);
- const body = await res.json();
- expect(res.status).toBe(400);
- expect(body?.error).toEqual(true);
- expect(body?.matches).toEqual(0);
- expect(body?.message).toBeDefined();
- });
- //#region inv /album
- it("Album path without ID yields error", async () => {
- const res = await fetch(`${baseUrl}/album`, defaultFetchOpts);
- const body = await res.json();
- expect(res.status).toBe(400);
- expect(body?.error).toEqual(true);
- expect(body?.matches).toEqual(null);
- expect(body?.message).toBeDefined();
- });
- });
|