/
extract-update.spec.ts
66 lines (62 loc) · 2.13 KB
/
extract-update.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
65
66
import hash from 'object-hash';
import { mocked } from '../../../../test/util';
import * as _repositoryCache from '../../../util/cache/repository';
import * as _branchify from '../updates/branchify';
import { extract, lookup, update } from './extract-update';
jest.mock('./write');
jest.mock('./sort');
jest.mock('./fetch');
jest.mock('../updates/branchify');
jest.mock('../extract');
jest.mock('../../../util/cache/repository');
const branchify = mocked(_branchify);
const repositoryCache = mocked(_repositoryCache);
branchify.branchifyUpgrades.mockResolvedValueOnce({
branches: [{ branchName: 'some-branch', upgrades: [] }],
branchList: ['branchName'],
});
describe('workers/repository/process/extract-update', () => {
describe('extract()', () => {
it('runs with no baseBranches', async () => {
const config = {
repoIsOnboarded: true,
suppressNotifications: ['deprecationWarningIssues'],
};
repositoryCache.getCache.mockReturnValueOnce({});
const packageFiles = await extract(config);
const res = await lookup(config, packageFiles);
expect(res).toMatchSnapshot();
await expect(update(config, res.branches)).resolves.not.toThrow();
});
it('runs with baseBranches', async () => {
const config = {
baseBranches: ['master', 'dev'],
repoIsOnboarded: true,
suppressNotifications: ['deprecationWarningIssues'],
};
repositoryCache.getCache.mockReturnValueOnce({});
const packageFiles = await extract(config);
expect(packageFiles).toMatchSnapshot();
});
it('uses repository cache', async () => {
const packageFiles = [];
const config = {
repoIsOnboarded: true,
suppressNotifications: ['deprecationWarningIssues'],
baseBranch: 'master',
baseBranchSha: 'abc123',
};
repositoryCache.getCache.mockReturnValueOnce({
scan: {
master: {
sha: config.baseBranchSha,
configHash: hash(config).toString(),
packageFiles,
},
},
});
const res = await extract(config);
expect(res).toEqual(packageFiles);
});
});
});