diff --git a/src/__test__/utils/valid.test.ts b/src/__test__/utils/valid.test.ts new file mode 100644 index 0000000..1fcbbf9 --- /dev/null +++ b/src/__test__/utils/valid.test.ts @@ -0,0 +1,72 @@ +import { makeStandardFetcher } from "@/fetchers/standardFetch"; +import { makeProviders } from "@/main/builder"; +import { targets } from "@/main/targets"; +import { isValidStream } from "@/utils/valid"; +import fetch from "node-fetch"; +import { describe, it, expect } from "vitest"; + +describe('isValidStream()', () => { + it('should pass valid streams', () => { + expect(isValidStream({ + type: "file", + flags: [], + qualities: { + "1080": { + type: "mp4", + url: "hello-world" + } + } + })).toBe(true); + expect(isValidStream({ + type: "hls", + flags: [], + playlist: "hello-world" + })).toBe(true); + }); + + it('should detect empty qualities', () => { + expect(isValidStream({ + type: "file", + flags: [], + qualities: {} + })).toBe(false); + }); + + it('should detect empty stream urls', () => { + expect(isValidStream({ + type: "file", + flags: [], + qualities: { + "1080": { + type: "mp4", + url: "", + } + } + })).toBe(false); + }); + + it('should detect emtpy HLS playlists', () => { + expect(isValidStream({ + type: "hls", + flags: [], + playlist: "", + })).toBe(false); + }); +}); + +describe("test", () => { + it("should work", async () => { + const providers = makeProviders({ + fetcher: makeStandardFetcher(fetch), + target: targets.BROWSER + }) + console.log(await providers.runAll({ + media: { + title: "Spider-Man: Across the Spider-Verse", + tmdbId: "569094", + releaseYear: 2023, + type: "movie", + } + })) + }) +})