-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
file-match.spec.ts
64 lines (62 loc) · 2.21 KB
/
file-match.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { RenovateConfig } from '../../../../test/util';
import * as fileMatch from './file-match';
jest.mock('../../../util/git');
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).toMatchSnapshot();
expect(res).toHaveLength(1);
});
it('returns minimatch matches', () => {
const includePaths = ['frontend/**'];
const res = fileMatch.getIncludedFiles(fileList, includePaths);
expect(res).toMatchSnapshot();
expect(res).toHaveLength(1);
});
});
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).toMatchSnapshot();
expect(res).toHaveLength(1);
});
it('returns minimatch matches', () => {
const ignoredPaths = ['frontend/**'];
const res = fileMatch.filterIgnoredFiles(fileList, ignoredPaths);
expect(res).toMatchSnapshot();
expect(res).toHaveLength(1);
});
});
describe('getMatchingFiles()', () => {
const config: RenovateConfig = {
includePaths: [],
ignoredPaths: [],
manager: 'npm',
fileMatch: ['(^|/)package.json$'],
};
it('returns npm files', () => {
fileList.push('Dockerfile');
const res = fileMatch.getMatchingFiles(config, fileList);
expect(res).toMatchSnapshot();
expect(res).toHaveLength(2);
});
it('deduplicates', () => {
config.fileMatch.push('package.json');
const res = fileMatch.getMatchingFiles(config, fileList);
expect(res).toMatchSnapshot();
expect(res).toHaveLength(2);
});
});
});