2017-11-05 04:45:49 +00:00
|
|
|
const { handleError } = require('../../../lib/workers/repository/error');
|
|
|
|
|
2017-12-18 08:39:52 +00:00
|
|
|
jest.mock('../../../lib/workers/repository/error-config');
|
|
|
|
|
2017-11-05 04:45:49 +00:00
|
|
|
let config;
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.resetAllMocks();
|
|
|
|
config = require('../../_fixtures/config');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('workers/repository/error', () => {
|
|
|
|
describe('handleError()', () => {
|
|
|
|
const errors = [
|
|
|
|
'uninitiated',
|
|
|
|
'disabled',
|
|
|
|
'fork',
|
|
|
|
'no-package-files',
|
|
|
|
'loops>5',
|
2017-12-18 08:39:52 +00:00
|
|
|
'config-validation',
|
2017-12-31 19:28:22 +00:00
|
|
|
'archived',
|
2017-11-05 04:45:49 +00:00
|
|
|
];
|
|
|
|
errors.forEach(err => {
|
2017-12-18 08:39:52 +00:00
|
|
|
it(`errors ${err}`, async () => {
|
|
|
|
const res = await handleError(config, new Error(err));
|
2017-11-05 04:45:49 +00:00
|
|
|
expect(res).toEqual(err);
|
|
|
|
});
|
|
|
|
});
|
2017-12-18 08:39:52 +00:00
|
|
|
it('handles unknown error', async () => {
|
|
|
|
const res = await handleError(config, new Error('abcdefg'));
|
2017-11-05 04:45:49 +00:00
|
|
|
expect(res).toEqual('unknown-error');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|