Skip to content
Snippets Groups Projects
Select Git revision
  • 430c05528cb6e288411f4f751439b5a093497206
  • master default
2 results

error-config.spec.js

Blame
  • error-config.spec.js 1.81 KiB
    const {
      raiseConfigWarningIssue,
    } = require('../../../lib/workers/repository/error-config');
    
    let config;
    beforeEach(() => {
      jest.resetAllMocks();
      config = require('../../config/config/_fixtures');
    });
    
    describe('workers/repository/error-config', () => {
      describe('raiseConfigWarningIssue()', () => {
        it('creates issues', async () => {
          const error = new Error('config-validation');
          error.configFile = 'package.json';
          error.validationMessage = 'some-message';
          platform.ensureIssue.mockReturnValue('created');
          const res = await raiseConfigWarningIssue(config, error);
          expect(res).toBeUndefined();
        });
        it('creates issues (dryRun)', async () => {
          const error = new Error('config-validation');
          error.configFile = 'package.json';
          error.validationMessage = 'some-message';
          platform.ensureIssue.mockReturnValue('created');
          const res = await raiseConfigWarningIssue(
            { ...config, dryRun: true },
            error
          );
          expect(res).toBeUndefined();
        });
        it('handles onboarding', async () => {
          const error = new Error('config-validation');
          error.configFile = 'package.json';
          error.validationMessage = 'some-message';
          platform.getBranchPr.mockReturnValueOnce({ number: 1, state: 'open' });
          const res = await raiseConfigWarningIssue(config, error);
          expect(res).toBeUndefined();
        });
        it('handles onboarding (dryRun)', async () => {
          const error = new Error('config-validation');
          error.configFile = 'package.json';
          error.validationMessage = 'some-message';
          platform.getBranchPr.mockReturnValueOnce({ number: 1, state: 'open' });
          const res = await raiseConfigWarningIssue(
            { ...config, dryRun: true },
            error
          );
          expect(res).toBeUndefined();
        });
      });
    });