Remove as unknown as TextEditor/TextDocument

This commit is contained in:
Koen Vlaswinkel
2023-02-21 13:42:16 +01:00
parent 4c14db951b
commit fa5bad6946
2 changed files with 8 additions and 6 deletions

View File

@@ -59,6 +59,7 @@ import { DbManager } from "../../../../src/databases/db-manager";
import { App } from "../../../../src/common/app";
import { ExtensionApp } from "../../../../src/common/vscode/vscode-app";
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
import { mockedObject } from "../../utils/mocking.helpers";
// up to 3 minutes per test
jest.setTimeout(3 * 60 * 1000);
@@ -992,10 +993,10 @@ describe("Variant Analysis Manager", () => {
showTextDocumentSpy = jest
.spyOn(window, "showTextDocument")
.mockResolvedValue(undefined as unknown as TextEditor);
.mockResolvedValue(mockedObject<TextEditor>({}));
openTextDocumentSpy = jest
.spyOn(workspace, "openTextDocument")
.mockResolvedValue(undefined as unknown as TextDocument);
.mockResolvedValue(mockedObject<TextDocument>({}));
});
afterEach(() => {
@@ -1005,8 +1006,8 @@ describe("Variant Analysis Manager", () => {
it("opens the query text", async () => {
await variantAnalysisManager.openQueryText(variantAnalysis.id);
expect(showTextDocumentSpy).toHaveBeenCalledTimes(1);
expect(openTextDocumentSpy).toHaveBeenCalledTimes(1);
expect(showTextDocumentSpy).toHaveBeenCalledTimes(1);
const uri: Uri = openTextDocumentSpy.mock.calls[0][0] as Uri;
expect(uri.scheme).toEqual("codeql-variant-analysis");
@@ -1040,10 +1041,10 @@ describe("Variant Analysis Manager", () => {
showTextDocumentSpy = jest
.spyOn(window, "showTextDocument")
.mockResolvedValue(undefined as unknown as TextEditor);
.mockResolvedValue(mockedObject<TextEditor>({}));
openTextDocumentSpy = jest
.spyOn(workspace, "openTextDocument")
.mockResolvedValue(undefined as unknown as TextDocument);
.mockResolvedValue(mockedObject<TextDocument>({}));
});
afterEach(() => {

View File

@@ -28,6 +28,7 @@ import { VariantAnalysisStatus } from "../../../../src/variant-analysis/shared/v
import { QuickPickItem, TextEditor } from "vscode";
import { WebviewReveal } from "../../../../src/interface-utils";
import * as helpers from "../../../../src/helpers";
import { mockedObject } from "../../utils/mocking.helpers";
describe("QueryHistoryManager", () => {
const mockExtensionLocation = join(tmpDir.name, "mock-extension-location");
@@ -58,7 +59,7 @@ describe("QueryHistoryManager", () => {
beforeEach(() => {
showTextDocumentSpy = jest
.spyOn(vscode.window, "showTextDocument")
.mockResolvedValue(undefined as unknown as TextEditor);
.mockResolvedValue(mockedObject<TextEditor>({}));
showInformationMessageSpy = jest
.spyOn(vscode.window, "showInformationMessage")
.mockResolvedValue(undefined);