Skip to content
Snippets Groups Projects
Select Git revision
  • 53ce3cf4d6bc2995aa2f95fdeb473873f09f5e69
  • main default protected
  • next
  • chore/update-static-data
  • renovate/main-redis-5.x
  • feat/gnupg
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • refactor/pin-new-value
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • gh-readonly-queue/next/pr-35654-137d934242c784e0c45d4b957362214f0eade1d7
  • fix/32307-global-extends-merging
  • fix/32307-global-extends-repositories
  • gh-readonly-queue/next/pr-35009-046ebf7cb84ab859f7fefceb5fa53a54ce9736f8
  • 41.55.3
  • 41.55.2
  • 41.55.1
  • 41.55.0
  • 41.54.0
  • 41.53.1
  • 41.53.0
  • 41.52.3
  • 41.52.2
  • 41.52.1
  • 41.52.0
  • 41.51.2
  • 41.51.1
  • 41.51.0
  • 41.50.0
  • 41.49.1
  • 41.49.0
  • 41.48.1
  • 41.48.0
  • 41.47.1
41 results

error-config.spec.ts

Blame
  • user avatar
    Rhys Arkins authored and GitHub committed
    53ca9130
    History
    error-config.spec.ts 2.17 KiB
    import { mock } from 'jest-mock-extended';
    import { RenovateConfig, getConfig, platform } from '../../../test/util';
    import { CONFIG_VALIDATION } from '../../constants/error-messages';
    import { PR_STATE_OPEN } from '../../constants/pull-requests';
    import { Pr } from '../../platform';
    import { raiseConfigWarningIssue } from './error-config';
    
    jest.mock('../../platform');
    
    let config: RenovateConfig;
    beforeEach(() => {
      jest.resetAllMocks();
      config = getConfig();
    });
    
    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.mockResolvedValueOnce('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.mockResolvedValueOnce('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.mockResolvedValue({
            ...mock<Pr>(),
            number: 1,
            state: PR_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.mockResolvedValue({
            ...mock<Pr>(),
            number: 1,
            state: PR_STATE_OPEN,
          });
          const res = await raiseConfigWarningIssue(
            { ...config, dryRun: true },
            error
          );
          expect(res).toBeUndefined();
        });
      });
    });