Skip to content

Commit a751b48

Browse files
author
Jaipreet Singh
committed
Add ability to clear cache for testing
1 parent 309c6ef commit a751b48

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/components/diff/DiffWidget.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,10 @@ export async function getRelativeFilePath(
9292
return serverRootResultCache;
9393
}
9494
}
95+
96+
/**
97+
* Visible for testing.
98+
*/
99+
export function clearCache() {
100+
serverRootResultCache = null;
101+
}

tests/test-components/DiffWidget.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'jest';
22
import { httpGitRequest } from '../../src/git';
33
import { getRelativeFilePath } from '../../src/components/diff/DiffWidget';
4+
import { clearCache } from '../../src/components/diff/DiffWidget';
45
import { createTestResponse } from './testutils';
56

67
jest.mock('../../src/git');
@@ -39,6 +40,7 @@ describe('DiffWidget', () => {
3940
);
4041

4142
// When
43+
clearCache();
4244
const result = await getRelativeFilePath(filePath, repoPath);
4345

4446
// Then

0 commit comments

Comments
 (0)