mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 18:19:51 +00:00
df8c4051ff
* test(core): replace file snapshots with explicit assertions * test(core): replace inline snapshots with explicit assertions * test(core): assert on relevant sections instead of full bodies * test(core): drop assertions implied by full equality * test(core): address review feedback * test(core): use resolves instead of awaiting inside expect
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import type { RenovateConfig } from '~test/util.ts';
|
|
import * as fileMatch from './file-match.ts';
|
|
|
|
describe('workers/repository/extract/file-match', () => {
|
|
const fileList = ['package.json', 'frontend/package.json'];
|
|
|
|
describe('getIncludedFiles()', () => {
|
|
it('returns fileList if no includePaths', () => {
|
|
const res = fileMatch.getIncludedFiles(fileList, []);
|
|
expect(res).toEqual(fileList);
|
|
});
|
|
|
|
it('returns exact matches', () => {
|
|
const includePaths = ['frontend/package.json'];
|
|
const res = fileMatch.getIncludedFiles(fileList, includePaths);
|
|
expect(res).toEqual(['frontend/package.json']);
|
|
});
|
|
|
|
it('returns minimatch matches', () => {
|
|
const includePaths = ['frontend/**'];
|
|
const res = fileMatch.getIncludedFiles(fileList, includePaths);
|
|
expect(res).toEqual(['frontend/package.json']);
|
|
});
|
|
});
|
|
|
|
describe('filterIgnoredFiles()', () => {
|
|
it('returns fileList if no ignoredPaths', () => {
|
|
const res = fileMatch.filterIgnoredFiles(fileList, []);
|
|
expect(res).toEqual(fileList);
|
|
});
|
|
|
|
it('ignores partial matches', () => {
|
|
const ignoredPaths = ['frontend'];
|
|
const res = fileMatch.filterIgnoredFiles(fileList, ignoredPaths);
|
|
expect(res).toEqual(['package.json']);
|
|
});
|
|
|
|
it('returns minimatch matches', () => {
|
|
const ignoredPaths = ['frontend/**'];
|
|
const res = fileMatch.filterIgnoredFiles(fileList, ignoredPaths);
|
|
expect(res).toEqual(['package.json']);
|
|
});
|
|
});
|
|
|
|
describe('getMatchingFiles()', () => {
|
|
const config: RenovateConfig = {
|
|
includePaths: [],
|
|
ignorePaths: [],
|
|
manager: 'npm',
|
|
managerFilePatterns: ['/(^|/)package\\.json$/'],
|
|
};
|
|
|
|
it('returns npm files', () => {
|
|
fileList.push('Dockerfile');
|
|
const res = fileMatch.getMatchingFiles(config, fileList);
|
|
expect(res).toEqual(['frontend/package.json', 'package.json']);
|
|
});
|
|
|
|
it('deduplicates', () => {
|
|
config.managerFilePatterns?.push('package.json');
|
|
const res = fileMatch.getMatchingFiles(config, fileList);
|
|
expect(res).toEqual(['frontend/package.json', 'package.json']);
|
|
});
|
|
});
|
|
});
|