test: instantiate mocked Fetcher with logger consistently
This commit is contained in:
parent
519e0d4156
commit
4caf62a367
24 changed files with 65 additions and 48 deletions
|
|
@ -7,8 +7,7 @@ import { DoodStream } from './DoodStream';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new DoodStream(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import { Dropload } from './Dropload';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new Dropload(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import { ExternalUrl } from './ExternalUrl';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new ExternalUrl(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ import { ExtractorRegistry } from './ExtractorRegistry';
|
|||
import { Context, CountryCode } from '../types';
|
||||
import { Fetcher } from '../utils';
|
||||
import { createExtractors } from './index';
|
||||
|
||||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, createExtractors(fetcher));
|
||||
|
||||
describe('ExtractorRegistry', () => {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import { Fsst } from './Fsst';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new Fsst(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import { KinoGer } from './KinoGer';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new KinoGer(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import { Soaper } from './Soaper';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new Soaper(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import { SuperVideo } from './SuperVideo';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new SuperVideo(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import { VidSrc } from './VidSrc';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const extractorRegistry = new ExtractorRegistry(logger, [new VidSrc(fetcher)]);
|
||||
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: {} };
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { CineHDPlus } from './CineHDPlus';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { es: 'on', mx: 'on' } };
|
||||
|
||||
describe('CineHDPlus', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { Eurostreaming } from './Eurostreaming';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { it: 'on' } };
|
||||
|
||||
describe('Eurostreaming', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { Frembed } from './Frembed';
|
||||
import { Fetcher, ImdbId, TmdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { fr: 'on' } };
|
||||
|
||||
describe('Frembed', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { FrenchCloud } from './FrenchCloud';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { fr: 'on' } };
|
||||
|
||||
describe('FrenchCloud', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { KinoGer } from './KinoGer';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { de: 'on' } };
|
||||
|
||||
describe('KinoGer', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { MeineCloud } from './MeineCloud';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { de: 'on' } };
|
||||
|
||||
describe('MeineCloud', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { MostraGuarda } from './MostraGuarda';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { it: 'on' } };
|
||||
|
||||
describe('MostraGuarda', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { Soaper } from './Soaper';
|
||||
import { Fetcher, ImdbId, TmdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { en: 'on' } };
|
||||
|
||||
describe('Soaper', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { StreamKiste } from './StreamKiste';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { de: 'on' } };
|
||||
|
||||
describe('StreamKiste', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { VerHdLink } from './VerHdLink';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { es: 'on', mx: 'on' } };
|
||||
|
||||
describe('VerHdLink', () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { VidSrc } from './VidSrc';
|
||||
import { Fetcher, ImdbId } from '../utils';
|
||||
import { Context } from '../types';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { en: 'on' } };
|
||||
|
||||
describe('VidSrc', () => {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ import { ImdbId } from './id';
|
|||
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 fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { de: 'on', it: 'on' } };
|
||||
|
||||
const meineCloud = new MeineCloud(fetcher);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ const { Fetcher } = jest.requireActual('../Fetcher');
|
|||
class MockedFetcher {
|
||||
private readonly fetcher: typeof Fetcher;
|
||||
|
||||
public constructor() {
|
||||
this.fetcher = new Fetcher(winston.createLogger({ transports: [new winston.transports.Console()] }));
|
||||
public constructor(logger: winston.Logger) {
|
||||
this.fetcher = new Fetcher(logger);
|
||||
}
|
||||
|
||||
public readonly text = async (ctx: Context, url: URL, init?: RequestInit): Promise<string> => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import winston from 'winston';
|
||||
import { buildManifest } from './manifest';
|
||||
import { StreamKiste, MeineCloud, VerHdLink } from '../source';
|
||||
import { Fetcher } from './Fetcher';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
|
||||
describe('buildManifest', () => {
|
||||
test('has unchecked source without a config', () => {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@ import { getImdbIdFromTmdbId, getTmdbIdFromImdbId } from './tmdb';
|
|||
import { Fetcher } from './Fetcher';
|
||||
import { Context } from '../types';
|
||||
import { ImdbId, TmdbId } from './id';
|
||||
import winston from 'winston';
|
||||
|
||||
jest.mock('../utils/Fetcher');
|
||||
|
||||
// @ts-expect-error No constructor args needed
|
||||
const fetcher = new Fetcher();
|
||||
const logger = winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] });
|
||||
const fetcher = new Fetcher(logger);
|
||||
const ctx: Context = { id: 'id', ip: '127.0.0.1', config: { de: 'on' } };
|
||||
|
||||
describe('getTmdbIdFromImdbId', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue