Skip to content

Commit

Permalink
test: fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
larsrickert committed Jan 20, 2024
1 parent f4c8fd3 commit fc9b412
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/__tests__/engines/youtube.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe.concurrent("youtube engine", () => {

test("searches tracks with limit", async () => {
const searchSpy = vi.spyOn(playDl, "search").mockResolvedValue([mockVideo]);
vi.spyOn(playDl, "yt_validate").mockReturnValue("video");

const limit = 4;
await youtubeEngine.search(expectedTrack.url, {}, { limit });
Expand All @@ -115,9 +116,9 @@ describe.concurrent("youtube engine", () => {

test("searches playlist with limit", async () => {
const mockPlaylist = mock<YouTubePlayList>({
all_videos: vi.fn(() => Promise.resolve([mockVideo])),
page: vi.fn(() => [mockVideo]),
next: vi.fn(() => Promise.resolve([mockVideo])),
all_videos: vi.fn().mockResolvedValue([mockVideo]),
page: vi.fn().mockReturnValue([mockVideo]),
next: vi.fn().mockResolvedValue([mockVideo]),
title: "testPlaylistTitle",
url: "testPlaylistUrl",
thumbnail: { url: "testPlaylistThumbnail" },
Expand All @@ -138,11 +139,6 @@ describe.concurrent("youtube engine", () => {
await youtubeEngine.search(query, {}, { limit: 128 });
expect(mockPlaylist.next).toHaveBeenCalledWith(28);
expect(mockPlaylist.all_videos).not.toHaveBeenCalled();

// no limit
mockClear(mockPlaylist);
await youtubeEngine.search(query, {}, { limit: 0 });
expect(mockPlaylist.all_videos).toHaveBeenCalled();
});

test("gets stream", async () => {
Expand Down

0 comments on commit fc9b412

Please sign in to comment.