test(handler): avoid side-effects by using a fresh handler for each test
This commit is contained in:
parent
7d0544a590
commit
364bf166ae
11 changed files with 60 additions and 23 deletions
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new CineHDPlus(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { es: 'on', mx: 'on' } };
|
||||
|
||||
describe('CineHDPlus', () => {
|
||||
let handler: CineHDPlus;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new CineHDPlus(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent series gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new Eurostreaming(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { it: 'on' } };
|
||||
|
||||
describe('Eurostreaming', () => {
|
||||
let handler: Eurostreaming;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new Eurostreaming(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent series gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new Frembed(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { fr: 'on' } };
|
||||
|
||||
describe('Frembed', () => {
|
||||
let handler: Frembed;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new Frembed(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handle imdb black mirror s4e2', async () => {
|
||||
const streams = (await handler.handle(ctx, 'series', new ImdbId('tt2085059', 4, 2))).filter(stream => stream !== undefined);
|
||||
expect(streams).toMatchSnapshot();
|
||||
|
|
@ -19,12 +24,6 @@ describe('Frembed', () => {
|
|||
|
||||
test('handle tmdb black mirror s4e2', async () => {
|
||||
const streams = (await handler.handle(ctx, 'series', new TmdbId(42009, 4, 2))).filter(stream => stream !== undefined);
|
||||
|
||||
const streamsWithoutTtl = streams.map((stream) => {
|
||||
delete stream.ttl;
|
||||
return stream;
|
||||
}); // to avoid flakyness because this is served from cache with lower ttl :)
|
||||
|
||||
expect(streamsWithoutTtl).toMatchSnapshot();
|
||||
expect(streams).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new FrenchCloud(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { fr: 'on' } };
|
||||
|
||||
describe('FrenchCloud', () => {
|
||||
let handler: FrenchCloud;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new FrenchCloud(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new KinoKiste(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { de: 'on' } };
|
||||
|
||||
describe('KinoKiste', () => {
|
||||
let handler: KinoKiste;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new KinoKiste(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent series gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'series', new ImdbId('tt12345678', 1, 1));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new MeineCloud(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { de: 'on' } };
|
||||
|
||||
describe('MeineCloud', () => {
|
||||
let handler: MeineCloud;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new MeineCloud(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new MostraGuarda(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { it: 'on' } };
|
||||
|
||||
describe('MostraGuarda', () => {
|
||||
let handler: MostraGuarda;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new MostraGuarda(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new Soaper(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { en: 'on' } };
|
||||
|
||||
describe('Soaper', () => {
|
||||
let handler: Soaper;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new Soaper(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
@ -34,13 +39,7 @@ describe('Soaper', () => {
|
|||
|
||||
test('handle tmdb black mirror s4e2', async () => {
|
||||
const streams = (await handler.handle(ctx, 'series', new TmdbId(42009, 4, 2))).filter(stream => stream !== undefined);
|
||||
|
||||
const streamsWithoutTtl = streams.map((stream) => {
|
||||
delete stream.ttl;
|
||||
return stream;
|
||||
}); // to avoid flakyness because this is served from cache with lower ttl :)
|
||||
|
||||
expect(streamsWithoutTtl).toMatchSnapshot();
|
||||
expect(streams).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('handle imdb full metal jacket', async () => {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ jest.mock('../utils/Fetcher');
|
|||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const handler = new VerHdLink(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { es: 'on', mx: 'on' } };
|
||||
|
||||
describe('VerHdLink', () => {
|
||||
let handler: VerHdLink;
|
||||
|
||||
beforeEach(() => {
|
||||
handler = new VerHdLink(fetcher, new ExtractorRegistry(logger, fetcher));
|
||||
});
|
||||
|
||||
test('handles non-existent movies gracefully', async () => {
|
||||
const streams = await handler.handle(ctx, 'movie', new ImdbId('tt12345678', undefined, undefined));
|
||||
expect(streams).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = `
|
|||
"Referer": "http://dood.to/",
|
||||
},
|
||||
"sourceId": "doodstream_fr",
|
||||
"ttl": 900000,
|
||||
"url": "https://ee317r.cloudatacdn.com/u5kj63yvxddlsdgge7qremqqka27irwiupc4k7o5cikbh7fdq4j4mwzraf7q/1y4sn4ndoi~mocked-random-string?token=fh3rdlhjvao7chgxndsi3ra7&expiry=639837296000",
|
||||
},
|
||||
{
|
||||
|
|
@ -73,6 +74,7 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = `
|
|||
"title": "Black Mirror 4x2",
|
||||
},
|
||||
"sourceId": "external_fr",
|
||||
"ttl": 3600000,
|
||||
"url": "https://netu.fanstream.us/e/0DFgfkcXOsDP",
|
||||
},
|
||||
{
|
||||
|
|
@ -83,6 +85,7 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = `
|
|||
"title": "Black Mirror 4x2",
|
||||
},
|
||||
"sourceId": "external_fr",
|
||||
"ttl": 3600000,
|
||||
"url": "https://johnalwayssame.com/e/cqy9oue7sv0g",
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ exports[`Soaper handle tmdb black mirror s4e2 1`] = `
|
|||
"title": "Black Mirror 4x2",
|
||||
},
|
||||
"sourceId": "soaper_en",
|
||||
"ttl": 900000,
|
||||
"url": "https://soaper.live/home/index/TVM3U8?key=zoeyOo54b7s8NAPnOW0div4OdvmbYxIzpE2RnmAoSXqMAm7eZKs79V4lxEnZsvQ6qYNrOEiqKO4dAwdBiYx3KmwyVRc9oPzLWoOYcLQVArr2j0.m3u8",
|
||||
},
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue