Select Git revision
dependency-dashboard.ts
index.spec.ts 5.37 KiB
import { loadModules } from '../../util/modules';
import { getDatasourceList } from '../datasource';
import type { ManagerApi } from './types';
import * as manager from '.';
jest.mock('../../util/fs');
const datasources = getDatasourceList();
describe('modules/manager/index', () => {
describe('supportedDatasources', () => {
for (const m of manager.getManagerList()) {
if (m === 'regex') {
// regex supports any
continue;
}
const supportedDatasources = manager.get(m, 'supportedDatasources');
it(`has valid supportedDatasources for ${m}`, () => {
expect(supportedDatasources).toBeNonEmptyArray();
supportedDatasources!.every((d) => {
expect(datasources.includes(d)).toBeTrue();
});
});
}
});
describe('get()', () => {
it('gets something', () => {
expect(manager.get('dockerfile', 'extractPackageFile')).not.toBeNull();
});
});
describe('getLanguageList()', () => {
it('gets', () => {
expect(manager.getLanguageList()).not.toBeNull();
});
});
describe('getManagerList()', () => {
it('gets', () => {
expect(manager.getManagerList()).not.toBeNull();
});
});
it('validates', () => {
function validate(module: ManagerApi): boolean {
if (!module.defaultConfig) {
return false;
}
if (!module.extractPackageFile && !module.extractAllPackageFiles) {
return false;
}
if (Object.values(module).some((v) => v === undefined)) {
return false;
}
return true;
}
const mgrs = manager.getManagers();
const loadedMgr = loadModules(__dirname, validate);
expect(Array.from(mgrs.keys())).toEqual(Object.keys(loadedMgr));
for (const name of mgrs.keys()) {
const mgr = mgrs.get(name)!;
expect(validate(mgr)).toBeTrue();
}
});
describe('detectGlobalConfig()', () => {