Skip to content

Commit dd4df01

Browse files
committed
Remove as unknown as ExtensionContext
1 parent af167c6 commit dd4df01

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-databases.test.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe("local databases", () => {
4848
>;
4949

5050
let dir: tmp.DirResult;
51+
let extensionContextStoragePath: string;
5152

5253
beforeEach(() => {
5354
dir = tmp.dirSync();
@@ -65,16 +66,24 @@ describe("local databases", () => {
6566
.spyOn(helpers, "showBinaryChoiceDialog")
6667
.mockResolvedValue(true);
6768

68-
extensionContext = {
69-
workspaceState: {
70-
update: updateSpy,
71-
get: () => [],
69+
extensionContextStoragePath = dir.name;
70+
71+
extensionContext = mockedObject<ExtensionContext>(
72+
{
73+
workspaceState: {
74+
update: updateSpy,
75+
get: () => [],
76+
},
7277
},
73-
// pretend like databases added in the temp dir are controlled by the extension
74-
// so that they are deleted upon removal
75-
storagePath: dir.name,
76-
storageUri: Uri.parse(dir.name),
77-
} as unknown as ExtensionContext;
78+
{
79+
dynamicProperties: {
80+
// pretend like databases added in the temp dir are controlled by the extension
81+
// so that they are deleted upon removal
82+
storagePath: () => extensionContextStoragePath,
83+
storageUri: () => Uri.parse(extensionContextStoragePath),
84+
},
85+
},
86+
);
7887

7988
databaseManager = new DatabaseManager(
8089
extensionContext,
@@ -267,6 +276,7 @@ describe("local databases", () => {
267276

268277
// pretend that the database location is not controlled by the extension
269278
(databaseManager as any).ctx.storagePath = "hucairz";
279+
extensionContextStoragePath = "hucairz";
270280

271281
await databaseManager.removeDatabaseItem(
272282
{} as ProgressCallback,

extensions/ql-vscode/test/vscode-tests/no-workspace/query-history/variant-analysis-history.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { EvalLogViewer } from "../../../../src/eval-log-viewer";
2020
import { QueryRunner } from "../../../../src/queryRunner";
2121
import { VariantAnalysisManager } from "../../../../src/variant-analysis/variant-analysis-manager";
2222
import { QueryHistoryManager } from "../../../../src/query-history/query-history-manager";
23+
import { mockedObject } from "../../utils/mocking.helpers";
2324

2425
// set a higher timeout since recursive delete may take a while, expecially on Windows.
2526
jest.setTimeout(120000);
@@ -75,10 +76,11 @@ describe("Variant Analyses and QueryHistoryManager", () => {
7576
variantAnalysisManagerStub,
7677
{} as EvalLogViewer,
7778
STORAGE_DIR,
78-
{
79+
mockedObject<ExtensionContext>({
7980
globalStorageUri: Uri.file(STORAGE_DIR),
81+
storageUri: undefined,
8082
extensionPath: EXTENSION_PATH,
81-
} as ExtensionContext,
83+
}),
8284
{
8385
onDidChangeConfiguration: () => new DisposableBucket(),
8486
} as unknown as QueryHistoryConfig,

0 commit comments

Comments
 (0)