renovate/test/workers/repository/error.spec.js
2018-07-29 15:50:19 +02:00

42 lines
1 KiB
JavaScript

const { handleError } = require('../../../lib/workers/repository/error');
jest.mock('../../../lib/workers/repository/error-config');
let config;
beforeEach(() => {
jest.resetAllMocks();
config = require('../../_fixtures/config');
});
describe('workers/repository/error', () => {
describe('handleError()', () => {
const errors = [
'uninitiated',
'disabled',
'repository-changed',
'fork',
'no-package-files',
'config-validation',
'registry-failure',
'archived',
'renamed',
'blocked',
'not-found',
'forbidden',
'rate-limit-exceeded',
'lockfile-error',
'platform-failure',
'no-vulnerability-alerts',
];
errors.forEach(err => {
it(`errors ${err}`, async () => {
const res = await handleError(config, new Error(err));
expect(res).toEqual(err);
});
});
it('handles unknown error', async () => {
const res = await handleError(config, new Error('abcdefg'));
expect(res).toEqual('unknown-error');
});
});
});