7 changed files with 2686 additions and 137 deletions
@ -0,0 +1,51 @@ |
|||||||
|
import { describe, it } from "vitest"; |
||||||
|
import "@/backend"; |
||||||
|
import { getProviders } from "@/backend/helpers/register"; |
||||||
|
import { MWMediaType } from "@/backend/metadata/types"; |
||||||
|
import { runProvider } from "@/backend/helpers/run"; |
||||||
|
import { testData } from "@/__tests__/providers/testdata"; |
||||||
|
|
||||||
|
describe("providers", () => { |
||||||
|
const providers = getProviders(); |
||||||
|
|
||||||
|
it("have at least one provider", ({ expect }) => { |
||||||
|
expect(providers.length).toBeGreaterThan(0); |
||||||
|
}); |
||||||
|
|
||||||
|
for (const provider of providers) { |
||||||
|
describe(provider.displayName, () => { |
||||||
|
it("must have at least one type", async ({ expect }) => { |
||||||
|
expect(provider.type.length).toBeGreaterThan(0); |
||||||
|
}); |
||||||
|
|
||||||
|
if (provider.type.includes(MWMediaType.MOVIE)) { |
||||||
|
it("must work with movies", async ({ expect }) => { |
||||||
|
const movie = testData.find((v) => v.meta.type === MWMediaType.MOVIE); |
||||||
|
if (!movie) throw new Error("no movie to test with"); |
||||||
|
const results = await runProvider(provider, { |
||||||
|
media: movie, |
||||||
|
progress() {}, |
||||||
|
type: movie.meta.type as any, |
||||||
|
}); |
||||||
|
expect(results).toBeTruthy(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
if (provider.type.includes(MWMediaType.SERIES)) { |
||||||
|
it("must work with series", async ({ expect }) => { |
||||||
|
const show = testData.find((v) => v.meta.type === MWMediaType.SERIES); |
||||||
|
if (show?.meta.type !== MWMediaType.SERIES) |
||||||
|
throw new Error("no show to test with"); |
||||||
|
const results = await runProvider(provider, { |
||||||
|
media: show, |
||||||
|
progress() {}, |
||||||
|
type: show.meta.type as MWMediaType.SERIES, |
||||||
|
episode: show.meta.seasonData.episodes[0].id, |
||||||
|
season: show.meta.seasons[0].id, |
||||||
|
}); |
||||||
|
expect(results).toBeTruthy(); |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
@ -0,0 +1,45 @@ |
|||||||
|
import { DetailedMeta } from "@/backend/metadata/getmeta"; |
||||||
|
import { MWMediaType } from "@/backend/metadata/types"; |
||||||
|
|
||||||
|
export const testData: DetailedMeta[] = [ |
||||||
|
{ |
||||||
|
imdbId: "tt10954562", |
||||||
|
tmdbId: "572716", |
||||||
|
meta: { |
||||||
|
id: "439596", |
||||||
|
title: "Hamilton", |
||||||
|
type: MWMediaType.MOVIE, |
||||||
|
year: "2020", |
||||||
|
seasons: undefined, |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
imdbId: "tt11126994", |
||||||
|
tmdbId: "94605", |
||||||
|
meta: { |
||||||
|
id: "222333", |
||||||
|
title: "Arcane", |
||||||
|
type: MWMediaType.SERIES, |
||||||
|
year: "2021", |
||||||
|
seasons: [ |
||||||
|
{ |
||||||
|
id: "230301", |
||||||
|
number: 1, |
||||||
|
title: "Season 1", |
||||||
|
}, |
||||||
|
], |
||||||
|
seasonData: { |
||||||
|
id: "230301", |
||||||
|
number: 1, |
||||||
|
title: "Season 1", |
||||||
|
episodes: [ |
||||||
|
{ |
||||||
|
id: "4243445", |
||||||
|
number: 1, |
||||||
|
title: "Welcome to the Playground", |
||||||
|
}, |
||||||
|
], |
||||||
|
}, |
||||||
|
}, |
||||||
|
}, |
||||||
|
]; |
@ -1,25 +1,25 @@ |
|||||||
{ |
{ |
||||||
"compilerOptions": { |
"compilerOptions": { |
||||||
"target": "ES2020", |
"target": "ES2020", |
||||||
"lib": ["dom", "dom.iterable", "esnext"], |
"lib": ["dom", "dom.iterable", "esnext"], |
||||||
"allowJs": true, |
"allowJs": true, |
||||||
"skipLibCheck": true, |
"skipLibCheck": true, |
||||||
"esModuleInterop": true, |
"esModuleInterop": true, |
||||||
"allowSyntheticDefaultImports": true, |
"allowSyntheticDefaultImports": true, |
||||||
"strict": true, |
"strict": true, |
||||||
"forceConsistentCasingInFileNames": true, |
"forceConsistentCasingInFileNames": true, |
||||||
"noFallthroughCasesInSwitch": true, |
"noFallthroughCasesInSwitch": true, |
||||||
"module": "esnext", |
"module": "esnext", |
||||||
"moduleResolution": "node", |
"moduleResolution": "node", |
||||||
"resolveJsonModule": true, |
"resolveJsonModule": true, |
||||||
"isolatedModules": true, |
"isolatedModules": true, |
||||||
"noEmit": true, |
"noEmit": true, |
||||||
"jsx": "react-jsx", |
"jsx": "react-jsx", |
||||||
"baseUrl": "./src", |
"baseUrl": "./src", |
||||||
"paths": { |
"paths": { |
||||||
"@/*": ["./*"] |
"@/*": ["./*"] |
||||||
}, |
}, |
||||||
"types": ["vite/client"] |
"types": ["vite/client", "jest"] |
||||||
}, |
}, |
||||||
"include": ["src"] |
"include": ["src"] |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue