Skip to content
Snippets Groups Projects
Select Git revision
  • 7afc2b75d5a7396ae130359f05722210d7de146d
  • main default protected
  • renovate/main-ghcr.io-renovatebot-base-image-10.x
  • renovate/main-ghcr.io-containerbase-devcontainer-13.x
  • next
  • revert-31645-feat/rename-gradle-wrapper-validation-action
  • renovate/main-redis-5.x
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • fix/36615-branch-reuse-bug
  • 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
  • 41.26.1
  • 41.26.0
  • 41.25.1
  • 41.25.0
  • 41.24.0
  • 41.23.5
  • 41.23.4
  • 41.23.3
  • 41.23.2
  • 41.23.1
  • 41.23.0
  • 41.22.0
  • 41.21.4
  • 41.21.3
  • 41.21.2
  • 41.21.1
  • 41.21.0
  • 41.20.2
  • 41.20.1
  • 41.20.0
41 results

index.spec.ts

Blame
  • index.spec.ts 3.71 KiB
    import { getConfig } from './defaults';
    
    jest.mock('../datasource/npm');
    try {
      jest.mock('../../config.js');
    } catch (err) {
      // file does not exist
    }
    
    const defaultConfig = getConfig();
    
    describe('config/index', () => {
      describe('mergeChildConfig(parentConfig, childConfig)', () => {
        it('merges', async () => {
          const parentConfig = { ...defaultConfig };
          const childConfig = {
            foo: 'bar',
            rangeStrategy: 'replace',
            lockFileMaintenance: {
              schedule: ['on monday'],
            },
          };
          const configParser = await import('./index');
          const config = configParser.mergeChildConfig(parentConfig, childConfig);
          expect(config.foo).toBe('bar');
          expect(config.rangeStrategy).toBe('replace');
          expect(config.lockFileMaintenance.schedule).toEqual(['on monday']);
          expect(config.lockFileMaintenance).toMatchSnapshot();
        });
        it('merges packageRules', async () => {
          const parentConfig = { ...defaultConfig };
          Object.assign(parentConfig, {
            packageRules: [{ a: 1 }, { a: 2 }],
          });
          const childConfig = {
            packageRules: [{ a: 3 }, { a: 4 }],
          };
          const configParser = await import('./index');
          const config = configParser.mergeChildConfig(parentConfig, childConfig);
          expect(config.packageRules.map((rule) => rule.a)).toMatchObject([
            1, 2, 3, 4,
          ]);
        });
        it('merges constraints', async () => {
          const parentConfig = { ...defaultConfig };
          Object.assign(parentConfig, {
            constraints: {
              node: '>=12',
              npm: '^6.0.0',
            },
          });
          const childConfig = {
            constraints: {
              node: '<15',
            },
          };
          const configParser = await import('./index');
          const config = configParser.mergeChildConfig(parentConfig, childConfig);
          expect(config.constraints).toMatchSnapshot();
          expect(config.constraints.node).toBe('<15');
        });
        it('handles null parent packageRules', async () => {
          const parentConfig = { ...defaultConfig };
          Object.assign(parentConfig, {
            packageRules: null,
          });
          const childConfig = {
            packageRules: [{ a: 3 }, { a: 4 }],
          };
          const configParser = await import('./index');
          const config = configParser.mergeChildConfig(parentConfig, childConfig);
          expect(config.packageRules).toHaveLength(2);
        });
        it('handles null child packageRules', async () => {
          const parentConfig = { ...defaultConfig };
          parentConfig.packageRules = [{ a: 3 }, { a: 4 }];
          const configParser = await import('./index');
          const config = configParser.mergeChildConfig(parentConfig, {});
          expect(config.packageRules).toHaveLength(2);
        });
        it('handles undefined childConfig', async () => {
          const parentConfig = { ...defaultConfig };
          const configParser = await import('./index');
          const config = configParser.mergeChildConfig(parentConfig, undefined);
          expect(config).toMatchObject(parentConfig);
        });
    
        it('getManagerConfig()', async () => {
          const parentConfig = { ...defaultConfig };
          const configParser = await import('./index');
          const config = configParser.getManagerConfig(parentConfig, 'npm');
          expect(config).toContainEntries([
            ['fileMatch', ['(^|/)package.json$']],
            ['rollbackPrs', true],
          ]);
          expect(
            configParser.getManagerConfig(parentConfig, 'html')
          ).toContainEntries([['fileMatch', ['\\.html?$']]]);
        });
    
        it('filterConfig()', async () => {
          const parentConfig = { ...defaultConfig };
          const configParser = await import('./index');
          const config = configParser.filterConfig(parentConfig, 'pr');
          expect(config).toBeObject();
        });
      });
    });