Skip to content

Commit 7691955

Browse files
committed
Shorten beforeEach to decrease chances of timeout
1 parent 269eadc commit 7691955

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

extensions/ql-vscode/test/vscode-tests/cli-integration/skeleton-query-wizard.test.ts

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,55 @@ import { CancellationTokenSource } from "vscode-jsonrpc";
1212
import { testCredentialsWithStub } from "../../factories/authentication";
1313
import { DatabaseItem, DatabaseManager } from "../../../src/local-databases";
1414
import * as databaseFetcher from "../../../src/databaseFetcher";
15-
import { Credentials } from "../../../src/common/authentication";
16-
import { getErrorMessage } from "../../../src/pure/helpers-pure";
1715

1816
describe("SkeletonQueryWizard", () => {
19-
let mockCli: CodeQLCliServer;
20-
let mockDatabaseManager: DatabaseManager;
2117
let wizard: SkeletonQueryWizard;
2218
let dir: tmp.DirResult;
2319
let storagePath: string;
24-
let credentials: Credentials;
2520
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
2621
let generateSpy: jest.SpiedFunction<
2722
typeof QlPackGenerator.prototype.generate
2823
>;
2924
let createExampleQlFileSpy: jest.SpiedFunction<
3025
typeof QlPackGenerator.prototype.createExampleQlFile
3126
>;
32-
let chosenLanguage: string;
3327
let downloadGitHubDatabaseSpy: jest.SpiedFunction<
3428
typeof databaseFetcher.downloadGitHubDatabase
3529
>;
3630
let openTextDocumentSpy: jest.SpiedFunction<
3731
typeof workspace.openTextDocument
3832
>;
3933

34+
const token = new CancellationTokenSource().token;
35+
const credentials = testCredentialsWithStub();
36+
const chosenLanguage = "ruby";
37+
const mockDatabaseManager = mockedObject<DatabaseManager>({
38+
setCurrentDatabaseItem: jest.fn(),
39+
digForDatabaseItem: jest.fn(),
40+
});
41+
const mockCli = mockedObject<CodeQLCliServer>({
42+
resolveLanguages: jest
43+
.fn()
44+
.mockResolvedValue([
45+
"ruby",
46+
"javascript",
47+
"go",
48+
"java",
49+
"python",
50+
"csharp",
51+
"cpp",
52+
]),
53+
getSupportedLanguages: jest.fn(),
54+
});
55+
4056
beforeEach(async () => {
4157
dir = tmp.dirSync({
4258
prefix: "skeleton_query_wizard_",
4359
unsafeCleanup: true,
4460
});
45-
chosenLanguage = "ruby";
46-
47-
mockCli = mockedObject<CodeQLCliServer>({
48-
resolveLanguages: jest
49-
.fn()
50-
.mockResolvedValue([
51-
"ruby",
52-
"javascript",
53-
"go",
54-
"java",
55-
"python",
56-
"csharp",
57-
"cpp",
58-
]),
59-
getSupportedLanguages: jest.fn(),
60-
});
61-
62-
mockDatabaseManager = mockedObject<DatabaseManager>({
63-
setCurrentDatabaseItem: jest.fn(),
64-
digForDatabaseItem: jest.fn(),
65-
});
6661

6762
storagePath = dir.name;
68-
credentials = testCredentialsWithStub();
6963

70-
jest.spyOn(extLogger, "log").mockResolvedValue(undefined);
7164
jest.spyOn(workspace, "workspaceFolders", "get").mockReturnValue([
7265
{
7366
name: `codespaces-codeql`,
@@ -95,8 +88,6 @@ describe("SkeletonQueryWizard", () => {
9588
.spyOn(workspace, "openTextDocument")
9689
.mockResolvedValue({} as TextDocument);
9790

98-
const token = new CancellationTokenSource().token;
99-
10091
wizard = new SkeletonQueryWizard(
10192
mockCli,
10293
jest.fn(),

0 commit comments

Comments
 (0)