1
0

album.spec.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { checkAlbumProps, checkArtistProps, sendReq } from "./hooks";
  2. describe("Album routes", () => {
  3. //#region inv /album
  4. it("Album path without ID yields error", async () => {
  5. const { res, status } = await sendReq("/album");
  6. const body = await res.json();
  7. expect(status).toBe(400);
  8. expect(body?.error).toEqual(true);
  9. expect(body?.matches).toEqual(null);
  10. expect(body?.message).toBeDefined();
  11. });
  12. //#region /album/:id
  13. it("Album details yields correct props", async () => {
  14. const { status, res } = await sendReq("/album/7105950");
  15. const body = await res.json();
  16. expect(status).toBe(200);
  17. expect(body?.error).toEqual(false);
  18. expect(body?.matches).toEqual(1);
  19. checkAlbumProps(body?.album);
  20. checkArtistProps(body?.album?.artist);
  21. });
  22. //#region inv /album/:id
  23. it("Invalid song ID yields no matches", async () => {
  24. const { res, status } = await sendReq("/album/0");
  25. const body = await res.json();
  26. expect(status).toBe(200);
  27. expect(body?.error).toEqual(false);
  28. expect(body?.matches).toEqual(0);
  29. expect(body?.message).toBeUndefined();
  30. });
  31. });