0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-12 14:19:01 +00:00
renovatebot_renovate/lib/util/git/pristine.spec.ts
2022-11-20 07:10:25 +00:00

37 lines
1.1 KiB
TypeScript

import { mocked, partial } from '../../../test/util';
import * as _repositoryCache from '../cache/repository';
import type { BranchCache, RepoCacheData } from '../cache/repository/types';
import { getCachedPristineResult } from './pristine';
jest.mock('../cache/repository');
const repositoryCache = mocked(_repositoryCache);
describe('util/git/pristine', () => {
let repoCache: RepoCacheData = {};
beforeEach(() => {
repoCache = {};
repositoryCache.getCache.mockReturnValue(repoCache);
});
describe('getCachedPristineResult', () => {
it('returns false if cache is not populated', () => {
expect(getCachedPristineResult('foo')).toBeFalse();
});
it('returns false if branch not found', () => {
repoCache.branches = [partial<BranchCache>({ branchName: 'not_foo' })];
expect(getCachedPristineResult('foo')).toBeFalse();
});
it('returns true', () => {
repoCache.branches = [
partial<BranchCache>({
branchName: 'foo',
pristine: true,
}),
];
expect(getCachedPristineResult('foo')).toBeTrue();
});
});
});