Skip to content

Commit b5b1106

Browse files
authored
Minor tidy-up for local-databases tests (#3058)
1 parent 429f9a1 commit b5b1106

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import { testDisposeHandler } from "../../test-dispose-handler";
2121
import { QueryRunner } from "../../../../src/query-server/query-runner";
2222
import * as dialog from "../../../../src/common/vscode/dialog";
23-
import { Setting } from "../../../../src/config";
23+
import * as config from "../../../../src/config";
2424
import { QlPackGenerator } from "../../../../src/local-queries/qlpack-generator";
2525
import { mockedObject } from "../../utils/mocking.helpers";
2626
import { createMockApp } from "../../../__mocks__/appMock";
@@ -626,12 +626,15 @@ describe("local databases", () => {
626626
showNeverAskAgainDialogSpy = jest
627627
.spyOn(dialog, "showNeverAskAgainDialog")
628628
.mockResolvedValue("No, and never ask me again");
629-
const updateValueSpy = jest.spyOn(Setting.prototype, "updateValue");
629+
const setAutogenerateQlPacksSpy = jest.spyOn(
630+
config,
631+
"setAutogenerateQlPacks",
632+
);
630633

631634
await (databaseManager as any).createSkeletonPacks(mockDbItem);
632635

633636
expect(generateSpy).not.toBeCalled();
634-
expect(updateValueSpy).toHaveBeenCalledWith("never", 2);
637+
expect(setAutogenerateQlPacksSpy).toHaveBeenCalledWith("never");
635638
});
636639

637640
it("should create the skeleton QL pack for the user", async () => {
@@ -735,7 +738,7 @@ describe("local databases", () => {
735738
describe("when codeQL.codespacesTemplate is set to true", () => {
736739
describe("when we add the tutorial database to the codespace", () => {
737740
it("should not offer to create a skeleton QL pack", async () => {
738-
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
741+
jest.spyOn(config, "isCodespacesTemplate").mockReturnValue(true);
739742

740743
const isTutorialDatabase = true;
741744
const makeSelected = true;
@@ -754,7 +757,7 @@ describe("local databases", () => {
754757

755758
describe("when we add a new database that isn't the tutorial one", () => {
756759
it("should create a skeleton QL pack", async () => {
757-
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
760+
jest.spyOn(config, "isCodespacesTemplate").mockReturnValue(true);
758761

759762
await databaseManager.openDatabase(mockDbItem.databaseUri);
760763

@@ -763,18 +766,9 @@ describe("local databases", () => {
763766
});
764767
});
765768

766-
describe("when codeQL.codespacesTemplate is set to false", () => {
767-
it("should not create a skeleton QL pack", async () => {
768-
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(false);
769-
770-
await databaseManager.openDatabase(mockDbItem.databaseUri);
771-
expect(createSkeletonPacksSpy).toBeCalledTimes(0);
772-
});
773-
});
774-
775-
describe("when codeQL.codespacesTemplate is not set", () => {
769+
describe("when codeQL.codespacesTemplate is set to false or not defined", () => {
776770
it("should not create a skeleton QL pack", async () => {
777-
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(undefined);
771+
jest.spyOn(config, "isCodespacesTemplate").mockReturnValue(false);
778772

779773
await databaseManager.openDatabase(mockDbItem.databaseUri);
780774
expect(createSkeletonPacksSpy).toBeCalledTimes(0);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ import { QueryLanguage } from "../../../../src/common/query-language";
1717
describe("local-databases-ui", () => {
1818
describe("fixDbUri", () => {
1919
const fixDbUri = (DatabaseUI.prototype as any).fixDbUri;
20-
it("should choose current directory direcory normally", async () => {
20+
it("should choose current directory normally", async () => {
2121
const dir = dirSync().name;
2222
const uri = await fixDbUri(Uri.file(dir));
2323
expect(uri.toString()).toBe(Uri.file(dir).toString());
2424
});
2525

26-
it("should choose parent direcory when file is selected", async () => {
26+
it("should choose parent directory when file is selected", async () => {
2727
const file = fileSync().name;
2828
const uri = await fixDbUri(Uri.file(file));
2929
expect(uri.toString()).toBe(Uri.file(dirname(file)).toString());
3030
});
3131

32-
it("should choose parent direcory when db-* is selected", async () => {
32+
it("should choose parent directory when db-* is selected", async () => {
3333
const dir = dirSync().name;
3434
const dbDir = join(dir, "db-javascript");
3535
await mkdirs(dbDir);
@@ -38,7 +38,7 @@ describe("local-databases-ui", () => {
3838
expect(uri.toString()).toBe(Uri.file(dir).toString());
3939
});
4040

41-
it("should choose parent's parent direcory when file selected is in db-*", async () => {
41+
it("should choose parent's parent directory when file selected is in db-*", async () => {
4242
const dir = dirSync().name;
4343
const dbDir = join(dir, "db-javascript");
4444
const file = join(dbDir, "nested");

0 commit comments

Comments
 (0)