0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-12 23:51:55 +00:00
renovatebot_renovate/lib/workers/repository/reconfigure/reconfigure-cache.spec.ts
2025-03-13 17:52:09 +00:00

57 lines
1.7 KiB
TypeScript

import * as _cache from '../../../util/cache/repository';
import type { RepoCacheData } from '../../../util/cache/repository/types';
import {
deleteReconfigureBranchCache,
setReconfigureBranchCache,
} from './reconfigure-cache';
vi.mock('../../../util/cache/repository');
const cache = vi.mocked(_cache);
describe('workers/repository/reconfigure/reconfigure-cache', () => {
describe('setReconfigureBranchCache()', () => {
it('sets new cache', () => {
const dummyCache = {} satisfies RepoCacheData;
cache.getCache.mockReturnValue(dummyCache);
setReconfigureBranchCache('reconfigure-sha', false);
expect(dummyCache).toEqual({
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha',
isConfigValid: false,
},
});
});
it('updates old cache', () => {
const dummyCache = {
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha',
isConfigValid: false,
},
} satisfies RepoCacheData;
cache.getCache.mockReturnValue(dummyCache);
setReconfigureBranchCache('reconfigure-sha-1', false);
expect(dummyCache).toEqual({
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha-1',
isConfigValid: false,
},
});
});
});
describe('deleteReconfigureBranchCache()', () => {
it('deletes cache', () => {
const dummyCache = {
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha',
isConfigValid: false,
},
} satisfies RepoCacheData;
cache.getCache.mockReturnValue(dummyCache);
deleteReconfigureBranchCache();
expect(dummyCache.reconfigureBranchCache).toBeUndefined();
});
});
});