hooks.ts 851 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. export function checkValProps(val: unknown, props: string[]) {
  2. for(const prop of props)
  3. expect(val).toHaveProperty(prop);
  4. }
  5. export function checkSongProps(songObj: unknown) {
  6. return checkValProps(songObj, [
  7. "url",
  8. "path",
  9. "lyricsState",
  10. "id",
  11. "meta.title",
  12. "meta.fullTitle",
  13. "meta.artists",
  14. ]);
  15. }
  16. export function checkAlbumProps(albumObj: unknown) {
  17. return checkValProps(albumObj, [
  18. "name",
  19. "fullTitle",
  20. "url",
  21. "coverArt",
  22. "id",
  23. "artist",
  24. ]);
  25. }
  26. export function checkArtistProps(artistObj: unknown) {
  27. return checkValProps(artistObj, [
  28. "name",
  29. "url",
  30. "image",
  31. "headerImage",
  32. ]);
  33. }
  34. export function checkTranslationProps(translationObj: unknown) {
  35. return checkValProps(translationObj, [
  36. "language",
  37. "id",
  38. "path",
  39. "title",
  40. "url",
  41. ]);
  42. }