renovate/test/workers/global/index.spec.js
Rhys Arkins 6f60289782 feat: install npm as dependency (#808)
* install npm from npm

* use embedded npm and remove versions checking
2017-09-14 18:24:14 +02:00

41 lines
1.3 KiB
JavaScript

const globalWorker = require('../../../lib/workers/global');
const repositoryWorker = require('../../../lib/workers/repository');
const configParser = require('../../../lib/config');
describe('lib/workers/global', () => {
beforeEach(() => {
jest.resetAllMocks();
configParser.parseConfigs = jest.fn();
configParser.getRepositoryConfig = jest.fn();
repositoryWorker.renovateRepository = jest.fn();
});
it('handles config warnings and errors', async () => {
configParser.parseConfigs.mockReturnValueOnce({
repositories: [],
maintainYarnLock: true,
foo: 1,
});
await globalWorker.start();
});
it('handles zero repos', async () => {
configParser.parseConfigs.mockReturnValueOnce({
repositories: [],
});
await globalWorker.start();
});
it('processes repositories', async () => {
configParser.parseConfigs.mockReturnValueOnce({
enabled: true,
repositories: ['a', 'b'],
});
await globalWorker.start();
expect(configParser.parseConfigs.mock.calls.length).toBe(1);
expect(repositoryWorker.renovateRepository.mock.calls.length).toBe(2);
});
it('catches errors', async () => {
configParser.parseConfigs.mockImplementationOnce(() => {
throw new Error('a');
});
await globalWorker.start();
});
});