album.spec.ts 890 B

123456789101112131415161718192021222324252627282930313233
  1. import { baseUrl, defaultFetchOpts } from "./constants";
  2. import { checkAlbumProps, checkArtistProps } from "./hooks";
  3. describe(`GET /album/:id`, () => {
  4. //#region /album/:id
  5. it("Album details yields correct props", async () => {
  6. const res = await fetch(`${baseUrl}/album/7105950`, defaultFetchOpts);
  7. const body = await res.json();
  8. expect(res.status).toBe(200);
  9. expect(body?.error).toEqual(false);
  10. expect(body?.matches).toEqual(1);
  11. checkAlbumProps(body?.album);
  12. checkArtistProps(body?.album?.artist);
  13. });
  14. //#region inv /album/:id
  15. it("Invalid album yields error", async () => {
  16. const res = await fetch(`${baseUrl}/album/0`, defaultFetchOpts);
  17. const body = await res.json();
  18. expect(res.status).toBe(400);
  19. expect(body?.error).toEqual(true);
  20. expect(body?.matches).toEqual(0);
  21. expect(body?.message).toBeDefined();
  22. });
  23. });