webstreamr-github/src/source/PrimeWire.test.ts
2025-07-15 21:46:54 +00:00

37 lines
1.3 KiB
TypeScript

import { createTestContext } from '../test';
import { FetcherMock, ImdbId } from '../utils';
import { PrimeWire } from './PrimeWire';
const ctx = createTestContext({ en: 'on' });
describe('PrimeWire', () => {
let handler: PrimeWire;
beforeEach(() => {
handler = new PrimeWire(new FetcherMock(`${__dirname}/__fixtures__/PrimeWire`));
});
test('handle non-existent movie gracefully', async () => {
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
expect(streams).toHaveLength(0);
});
test('handle non-existent episode gracefully', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt18546730', 99, 99));
expect(streams).toHaveLength(0);
});
test('handle imdb dead city s2e5', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt18546730', 2, 5));
expect(streams).toMatchSnapshot();
});
test('handle el camino', async () => {
const streams = await handler.handle(ctx, 'series', new ImdbId('tt9243946', undefined, undefined));
expect(streams).toMatchSnapshot();
// Should be using the redirectUrlCache
const streams2 = await handler.handle(ctx, 'series', new ImdbId('tt9243946', undefined, undefined));
expect(streams2).toMatchSnapshot();
});
});