Skip to content

Commit fa5bad6

Browse files
committed
Remove as unknown as TextEditor/TextDocument
1 parent 4c14db9 commit fa5bad6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

extensions/ql-vscode/test/vscode-tests/cli-integration/variant-analysis/variant-analysis-manager.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import { DbManager } from "../../../../src/databases/db-manager";
5959
import { App } from "../../../../src/common/app";
6060
import { ExtensionApp } from "../../../../src/common/vscode/vscode-app";
6161
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
62+
import { mockedObject } from "../../utils/mocking.helpers";
6263

6364
// up to 3 minutes per test
6465
jest.setTimeout(3 * 60 * 1000);
@@ -992,10 +993,10 @@ describe("Variant Analysis Manager", () => {
992993

993994
showTextDocumentSpy = jest
994995
.spyOn(window, "showTextDocument")
995-
.mockResolvedValue(undefined as unknown as TextEditor);
996+
.mockResolvedValue(mockedObject<TextEditor>({}));
996997
openTextDocumentSpy = jest
997998
.spyOn(workspace, "openTextDocument")
998-
.mockResolvedValue(undefined as unknown as TextDocument);
999+
.mockResolvedValue(mockedObject<TextDocument>({}));
9991000
});
10001001

10011002
afterEach(() => {
@@ -1005,8 +1006,8 @@ describe("Variant Analysis Manager", () => {
10051006
it("opens the query text", async () => {
10061007
await variantAnalysisManager.openQueryText(variantAnalysis.id);
10071008

1008-
expect(showTextDocumentSpy).toHaveBeenCalledTimes(1);
10091009
expect(openTextDocumentSpy).toHaveBeenCalledTimes(1);
1010+
expect(showTextDocumentSpy).toHaveBeenCalledTimes(1);
10101011

10111012
const uri: Uri = openTextDocumentSpy.mock.calls[0][0] as Uri;
10121013
expect(uri.scheme).toEqual("codeql-variant-analysis");
@@ -1040,10 +1041,10 @@ describe("Variant Analysis Manager", () => {
10401041

10411042
showTextDocumentSpy = jest
10421043
.spyOn(window, "showTextDocument")
1043-
.mockResolvedValue(undefined as unknown as TextEditor);
1044+
.mockResolvedValue(mockedObject<TextEditor>({}));
10441045
openTextDocumentSpy = jest
10451046
.spyOn(workspace, "openTextDocument")
1046-
.mockResolvedValue(undefined as unknown as TextDocument);
1047+
.mockResolvedValue(mockedObject<TextDocument>({}));
10471048
});
10481049

10491050
afterEach(() => {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { VariantAnalysisStatus } from "../../../../src/variant-analysis/shared/v
2828
import { QuickPickItem, TextEditor } from "vscode";
2929
import { WebviewReveal } from "../../../../src/interface-utils";
3030
import * as helpers from "../../../../src/helpers";
31+
import { mockedObject } from "../../utils/mocking.helpers";
3132

3233
describe("QueryHistoryManager", () => {
3334
const mockExtensionLocation = join(tmpDir.name, "mock-extension-location");
@@ -58,7 +59,7 @@ describe("QueryHistoryManager", () => {
5859
beforeEach(() => {
5960
showTextDocumentSpy = jest
6061
.spyOn(vscode.window, "showTextDocument")
61-
.mockResolvedValue(undefined as unknown as TextEditor);
62+
.mockResolvedValue(mockedObject<TextEditor>({}));
6263
showInformationMessageSpy = jest
6364
.spyOn(vscode.window, "showInformationMessage")
6465
.mockResolvedValue(undefined);

0 commit comments

Comments
 (0)