Merge pull request #3246 from github/nora/remove-deprecated-jest-syntax

Remove deprecated jest syntac
This commit is contained in:
Nora
2024-01-16 16:44:09 +01:00
committed by GitHub
21 changed files with 169 additions and 167 deletions

View File

@@ -54,12 +54,12 @@ describe("OutputChannelLogger tests", function () {
it("should log to the output channel", async () => { it("should log to the output channel", async () => {
await logger.log("xxx"); await logger.log("xxx");
expect(mockOutputChannel.appendLine).toBeCalledWith("xxx"); expect(mockOutputChannel.appendLine).toHaveBeenCalledWith("xxx");
expect(mockOutputChannel.append).not.toBeCalledWith("xxx"); expect(mockOutputChannel.append).not.toHaveBeenCalledWith("xxx");
await logger.log("yyy", { trailingNewline: false }); await logger.log("yyy", { trailingNewline: false });
expect(mockOutputChannel.appendLine).not.toBeCalledWith("yyy"); expect(mockOutputChannel.appendLine).not.toHaveBeenCalledWith("yyy");
expect(mockOutputChannel.append).toBeCalledWith("yyy"); expect(mockOutputChannel.append).toHaveBeenCalledWith("yyy");
const hucairz = createSideLogger(logger, "hucairz"); const hucairz = createSideLogger(logger, "hucairz");
await hucairz.log("zzz"); await hucairz.log("zzz");

View File

@@ -34,9 +34,9 @@ describe("DisposableObject and DisposeHandler", () => {
disposableObject.dispose(); disposableObject.dispose();
expect(disposable1.dispose).toBeCalled(); expect(disposable1.dispose).toHaveBeenCalled();
expect(disposable2.dispose).toBeCalled(); expect(disposable2.dispose).toHaveBeenCalled();
expect(disposable3.dispose).toBeCalled(); expect(disposable3.dispose).toHaveBeenCalled();
// pushed items must be called in reverse order // pushed items must be called in reverse order
expect(disposable2.dispose.mock.invocationCallOrder[0]).toBeLessThan( expect(disposable2.dispose.mock.invocationCallOrder[0]).toBeLessThan(
@@ -51,30 +51,30 @@ describe("DisposableObject and DisposeHandler", () => {
disposableObject.dispose(); disposableObject.dispose();
expect(disposable1.dispose).not.toBeCalled(); expect(disposable1.dispose).not.toHaveBeenCalled();
expect(disposable2.dispose).not.toBeCalled(); expect(disposable2.dispose).not.toHaveBeenCalled();
expect(disposable3.dispose).not.toBeCalled(); expect(disposable3.dispose).not.toHaveBeenCalled();
}); });
it("should dispose and stop tracking objects", () => { it("should dispose and stop tracking objects", () => {
disposableObject.track(disposable1); disposableObject.track(disposable1);
disposableObject.disposeAndStopTracking(disposable1); disposableObject.disposeAndStopTracking(disposable1);
expect(disposable1.dispose).toBeCalled(); expect(disposable1.dispose).toHaveBeenCalled();
disposable1.dispose.mockClear(); disposable1.dispose.mockClear();
disposableObject.dispose(); disposableObject.dispose();
expect(disposable1.dispose).not.toBeCalled(); expect(disposable1.dispose).not.toHaveBeenCalled();
}); });
it("should avoid disposing an object that is not tracked", () => { it("should avoid disposing an object that is not tracked", () => {
disposableObject.push(disposable1); disposableObject.push(disposable1);
disposableObject.disposeAndStopTracking(disposable1); disposableObject.disposeAndStopTracking(disposable1);
expect(disposable1.dispose).not.toBeCalled(); expect(disposable1.dispose).not.toHaveBeenCalled();
disposableObject.dispose(); disposableObject.dispose();
expect(disposable1.dispose).toBeCalled(); expect(disposable1.dispose).toHaveBeenCalled();
}); });
it("ahould use a dispose handler", () => { it("ahould use a dispose handler", () => {
@@ -91,10 +91,10 @@ describe("DisposableObject and DisposeHandler", () => {
disposableObject.dispose(handler); disposableObject.dispose(handler);
expect(disposable1.dispose).toBeCalled(); expect(disposable1.dispose).toHaveBeenCalled();
expect(disposable2.dispose).not.toBeCalled(); expect(disposable2.dispose).not.toHaveBeenCalled();
expect(disposable3.dispose).toBeCalled(); expect(disposable3.dispose).toHaveBeenCalled();
expect(disposable4.dispose).not.toBeCalled(); expect(disposable4.dispose).not.toHaveBeenCalled();
// now that disposableObject has been disposed, subsequent disposals are // now that disposableObject has been disposed, subsequent disposals are
// no-ops // no-ops
@@ -105,10 +105,10 @@ describe("DisposableObject and DisposeHandler", () => {
disposableObject.dispose(); disposableObject.dispose();
expect(disposable1.dispose).not.toBeCalled(); expect(disposable1.dispose).not.toHaveBeenCalled();
expect(disposable2.dispose).not.toBeCalled(); expect(disposable2.dispose).not.toHaveBeenCalled();
expect(disposable3.dispose).not.toBeCalled(); expect(disposable3.dispose).not.toHaveBeenCalled();
expect(disposable4.dispose).not.toBeCalled(); expect(disposable4.dispose).not.toHaveBeenCalled();
}); });
class MyDisposableObject extends DisposableObject { class MyDisposableObject extends DisposableObject {

View File

@@ -139,7 +139,7 @@ describe("db config store", () => {
const configStore = new DbConfigStore(app, false); const configStore = new DbConfigStore(app, false);
await configStore.initialize(); await configStore.initialize();
expect(executeCommand).toBeCalledWith( expect(executeCommand).toHaveBeenCalledWith(
"setContext", "setContext",
"codeQLVariantAnalysisRepositories.configError", "codeQLVariantAnalysisRepositories.configError",
true, true,
@@ -157,7 +157,7 @@ describe("db config store", () => {
const configStore = new DbConfigStore(app, false); const configStore = new DbConfigStore(app, false);
await configStore.initialize(); await configStore.initialize();
expect(executeCommand).toBeCalledWith( expect(executeCommand).toHaveBeenCalledWith(
"setContext", "setContext",
"codeQLVariantAnalysisRepositories.configError", "codeQLVariantAnalysisRepositories.configError",
false, false,

View File

@@ -96,7 +96,7 @@ describe("Variant Analysis Manager", () => {
await variantAnalysisManager.rehydrateVariantAnalysis(variantAnalysis); await variantAnalysisManager.rehydrateVariantAnalysis(variantAnalysis);
expect(stub).toBeCalledTimes(1); expect(stub).toHaveBeenCalledTimes(1);
}); });
}); });
@@ -423,7 +423,7 @@ describe("Variant Analysis Manager", () => {
); );
expect(variantAnalysisManager.downloadsQueueSize()).toBe(0); expect(variantAnalysisManager.downloadsQueueSize()).toBe(0);
expect(getResultsSpy).toBeCalledTimes(3); expect(getResultsSpy).toHaveBeenCalledTimes(3);
}); });
}); });
@@ -451,7 +451,7 @@ describe("Variant Analysis Manager", () => {
await variantAnalysisManager.removeVariantAnalysis(dummyVariantAnalysis); await variantAnalysisManager.removeVariantAnalysis(dummyVariantAnalysis);
expect(removeAnalysisResultsStub).toBeCalledTimes(1); expect(removeAnalysisResultsStub).toHaveBeenCalledTimes(1);
expect(variantAnalysisManager.variantAnalysesSize).toBe(0); expect(variantAnalysisManager.variantAnalysesSize).toBe(0);
await expect( await expect(
@@ -610,7 +610,7 @@ describe("Variant Analysis Manager", () => {
it("should return cancel if valid", async () => { it("should return cancel if valid", async () => {
await variantAnalysisManager.cancelVariantAnalysis(variantAnalysis.id); await variantAnalysisManager.cancelVariantAnalysis(variantAnalysis.id);
expect(mockCancelVariantAnalysis).toBeCalledWith( expect(mockCancelVariantAnalysis).toHaveBeenCalledWith(
app.credentials, app.credentials,
variantAnalysis, variantAnalysis,
); );
@@ -656,7 +656,7 @@ describe("Variant Analysis Manager", () => {
variantAnalysis.id, variantAnalysis.id,
); );
expect(writeTextStub).not.toBeCalled(); expect(writeTextStub).not.toHaveBeenCalled();
}); });
}); });
@@ -682,7 +682,7 @@ describe("Variant Analysis Manager", () => {
variantAnalysis.id, variantAnalysis.id,
); );
expect(writeTextStub).not.toBeCalled(); expect(writeTextStub).not.toHaveBeenCalled();
}); });
}); });
@@ -722,7 +722,7 @@ describe("Variant Analysis Manager", () => {
variantAnalysis.id, variantAnalysis.id,
); );
expect(writeTextStub).toBeCalledTimes(1); expect(writeTextStub).toHaveBeenCalledTimes(1);
}); });
it("should be valid JSON when put in object", async () => { it("should be valid JSON when put in object", async () => {

View File

@@ -121,7 +121,7 @@ describe("Variant Analysis Monitor", () => {
); );
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis); await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
expect(mockEecuteCommand).toBeCalledTimes(succeededRepos.length); expect(mockEecuteCommand).toHaveBeenCalledTimes(succeededRepos.length);
succeededRepos.forEach((succeededRepo, index) => { succeededRepos.forEach((succeededRepo, index) => {
expect(mockEecuteCommand).toHaveBeenNthCalledWith( expect(mockEecuteCommand).toHaveBeenNthCalledWith(
@@ -197,8 +197,8 @@ describe("Variant Analysis Monitor", () => {
it("should trigger a download extension command for each repo", async () => { it("should trigger a download extension command for each repo", async () => {
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis); await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
expect(mockGetVariantAnalysis).toBeCalledTimes(4); expect(mockGetVariantAnalysis).toHaveBeenCalledTimes(4);
expect(mockEecuteCommand).toBeCalledTimes(5); expect(mockEecuteCommand).toHaveBeenCalledTimes(5);
}); });
}); });
@@ -261,7 +261,7 @@ describe("Variant Analysis Monitor", () => {
it("should only trigger the warning once per error", async () => { it("should only trigger the warning once per error", async () => {
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis); await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
expect(logger.showWarningMessage).toBeCalledTimes(4); expect(logger.showWarningMessage).toHaveBeenCalledTimes(4);
expect(logger.showWarningMessage).toHaveBeenNthCalledWith( expect(logger.showWarningMessage).toHaveBeenNthCalledWith(
1, 1,
expect.stringMatching(/No internet connection/), expect.stringMatching(/No internet connection/),
@@ -291,7 +291,7 @@ describe("Variant Analysis Monitor", () => {
it("should not try to download any repos", async () => { it("should not try to download any repos", async () => {
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis); await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
expect(mockEecuteCommand).not.toBeCalled(); expect(mockEecuteCommand).not.toHaveBeenCalled();
}); });
}); });

View File

@@ -105,7 +105,7 @@ describe("Variant Analysis Manager", () => {
cancellationTokenSource.token, cancellationTokenSource.token,
); );
expect(executeCommandSpy).toBeCalledWith( expect(executeCommandSpy).toHaveBeenCalledWith(
"codeQL.monitorNewVariantAnalysis", "codeQL.monitorNewVariantAnalysis",
expect.objectContaining({ expect.objectContaining({
id: mockApiResponse.id, id: mockApiResponse.id,
@@ -113,8 +113,8 @@ describe("Variant Analysis Manager", () => {
}), }),
); );
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1); expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1); expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
}); });
it("should run a remote query that is not part of a qlpack", async () => { it("should run a remote query that is not part of a qlpack", async () => {
@@ -126,7 +126,7 @@ describe("Variant Analysis Manager", () => {
cancellationTokenSource.token, cancellationTokenSource.token,
); );
expect(executeCommandSpy).toBeCalledWith( expect(executeCommandSpy).toHaveBeenCalledWith(
"codeQL.monitorNewVariantAnalysis", "codeQL.monitorNewVariantAnalysis",
expect.objectContaining({ expect.objectContaining({
id: mockApiResponse.id, id: mockApiResponse.id,
@@ -134,8 +134,8 @@ describe("Variant Analysis Manager", () => {
}), }),
); );
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1); expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1); expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
}); });
it("should run a remote query that is nested inside a qlpack", async () => { it("should run a remote query that is nested inside a qlpack", async () => {
@@ -147,7 +147,7 @@ describe("Variant Analysis Manager", () => {
cancellationTokenSource.token, cancellationTokenSource.token,
); );
expect(executeCommandSpy).toBeCalledWith( expect(executeCommandSpy).toHaveBeenCalledWith(
"codeQL.monitorNewVariantAnalysis", "codeQL.monitorNewVariantAnalysis",
expect.objectContaining({ expect.objectContaining({
id: mockApiResponse.id, id: mockApiResponse.id,
@@ -155,8 +155,8 @@ describe("Variant Analysis Manager", () => {
}), }),
); );
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1); expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1); expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
}); });
it("should cancel a run before uploading", async () => { it("should cancel a run before uploading", async () => {
@@ -318,8 +318,8 @@ describe("Variant Analysis Manager", () => {
cancellationTokenSource.token, cancellationTokenSource.token,
); );
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1); expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
expect(executeCommandSpy).toBeCalledWith( expect(executeCommandSpy).toHaveBeenCalledWith(
"codeQL.monitorNewVariantAnalysis", "codeQL.monitorNewVariantAnalysis",
expect.objectContaining({ expect.objectContaining({
query: expect.objectContaining({ filePath: fileUri.fsPath }), query: expect.objectContaining({ filePath: fileUri.fsPath }),

View File

@@ -130,13 +130,13 @@ describe("local databases", () => {
await (databaseManager as any).addDatabaseItem(mockDbItem); await (databaseManager as any).addDatabaseItem(mockDbItem);
expect((databaseManager as any)._databaseItems).toEqual([mockDbItem]); expect((databaseManager as any)._databaseItems).toEqual([mockDbItem]);
expect(updateSpy).toBeCalledWith("databaseList", [ expect(updateSpy).toHaveBeenCalledWith("databaseList", [
{ {
options: mockDbOptions(), options: mockDbOptions(),
uri: dbLocationUri(dir).toString(true), uri: dbLocationUri(dir).toString(true),
}, },
]); ]);
expect(onDidChangeDatabaseItem).toBeCalledWith({ expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
item: undefined, item: undefined,
kind: DatabaseEventKind.Add, kind: DatabaseEventKind.Add,
}); });
@@ -147,8 +147,8 @@ describe("local databases", () => {
// now remove the item // now remove the item
await databaseManager.removeDatabaseItem(mockDbItem); await databaseManager.removeDatabaseItem(mockDbItem);
expect((databaseManager as any)._databaseItems).toEqual([]); expect((databaseManager as any)._databaseItems).toEqual([]);
expect(updateSpy).toBeCalledWith("databaseList", []); expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
expect(onDidChangeDatabaseItem).toBeCalledWith({ expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
item: undefined, item: undefined,
kind: DatabaseEventKind.Remove, kind: DatabaseEventKind.Remove,
}); });
@@ -164,14 +164,14 @@ describe("local databases", () => {
await databaseManager.renameDatabaseItem(mockDbItem, "new name"); await databaseManager.renameDatabaseItem(mockDbItem, "new name");
expect(mockDbItem.name).toBe("new name"); expect(mockDbItem.name).toBe("new name");
expect(updateSpy).toBeCalledWith("databaseList", [ expect(updateSpy).toHaveBeenCalledWith("databaseList", [
{ {
options: { ...mockDbOptions(), displayName: "new name" }, options: { ...mockDbOptions(), displayName: "new name" },
uri: dbLocationUri(dir).toString(true), uri: dbLocationUri(dir).toString(true),
}, },
]); ]);
expect(onDidChangeDatabaseItem).toBeCalledWith({ expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
item: undefined, item: undefined,
kind: DatabaseEventKind.Rename, kind: DatabaseEventKind.Rename,
}); });
@@ -187,7 +187,7 @@ describe("local databases", () => {
await (databaseManager as any).addDatabaseItem(mockDbItem); await (databaseManager as any).addDatabaseItem(mockDbItem);
expect(databaseManager.databaseItems).toEqual([mockDbItem]); expect(databaseManager.databaseItems).toEqual([mockDbItem]);
expect(updateSpy).toBeCalledWith("databaseList", [ expect(updateSpy).toHaveBeenCalledWith("databaseList", [
{ {
uri: dbLocationUri(dir).toString(true), uri: dbLocationUri(dir).toString(true),
options: mockDbOptions(), options: mockDbOptions(),
@@ -198,7 +198,7 @@ describe("local databases", () => {
item: undefined, item: undefined,
kind: DatabaseEventKind.Add, kind: DatabaseEventKind.Add,
}; };
expect(onDidChangeDatabaseItem).toBeCalledWith(mockEvent); expect(onDidChangeDatabaseItem).toHaveBeenCalledWith(mockEvent);
}); });
it("should add a database item source archive", async () => { it("should add a database item source archive", async () => {
@@ -234,9 +234,9 @@ describe("local databases", () => {
await databaseManager.removeDatabaseItem(mockDbItem); await databaseManager.removeDatabaseItem(mockDbItem);
expect(databaseManager.databaseItems).toEqual([]); expect(databaseManager.databaseItems).toEqual([]);
expect(updateSpy).toBeCalledWith("databaseList", []); expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
// should remove the folder // should remove the folder
expect(workspace.updateWorkspaceFolders).toBeCalledWith(0, 1); expect(workspace.updateWorkspaceFolders).toHaveBeenCalledWith(0, 1);
// should also delete the db contents // should also delete the db contents
await expect(pathExists(mockDbItem.databaseUri.fsPath)).resolves.toBe( await expect(pathExists(mockDbItem.databaseUri.fsPath)).resolves.toBe(
@@ -262,9 +262,9 @@ describe("local databases", () => {
await databaseManager.removeDatabaseItem(mockDbItem); await databaseManager.removeDatabaseItem(mockDbItem);
expect(databaseManager.databaseItems).toEqual([]); expect(databaseManager.databaseItems).toEqual([]);
expect(updateSpy).toBeCalledWith("databaseList", []); expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
// should remove the folder // should remove the folder
expect(workspace.updateWorkspaceFolders).toBeCalledWith(0, 1); expect(workspace.updateWorkspaceFolders).toHaveBeenCalledWith(0, 1);
// should NOT delete the db contents // should NOT delete the db contents
await expect(pathExists(mockDbItem.databaseUri.fsPath)).resolves.toBe( await expect(pathExists(mockDbItem.databaseUri.fsPath)).resolves.toBe(
@@ -279,12 +279,12 @@ describe("local databases", () => {
await (databaseManager as any).addDatabaseItem(mockDbItem); await (databaseManager as any).addDatabaseItem(mockDbItem);
// Should have registered this database // Should have registered this database
expect(registerSpy).toBeCalledWith(mockDbItem); expect(registerSpy).toHaveBeenCalledWith(mockDbItem);
await databaseManager.removeDatabaseItem(mockDbItem); await databaseManager.removeDatabaseItem(mockDbItem);
// Should have deregistered this database // Should have deregistered this database
expect(deregisterSpy).toBeCalledWith(mockDbItem); expect(deregisterSpy).toHaveBeenCalledWith(mockDbItem);
}); });
}); });
@@ -618,7 +618,7 @@ describe("local databases", () => {
it("should offer the user to set up a skeleton QL pack", async () => { it("should offer the user to set up a skeleton QL pack", async () => {
await (databaseManager as any).createSkeletonPacks(mockDbItem); await (databaseManager as any).createSkeletonPacks(mockDbItem);
expect(showNeverAskAgainDialogSpy).toBeCalledTimes(1); expect(showNeverAskAgainDialogSpy).toHaveBeenCalledTimes(1);
}); });
it("should return early if the user refuses help", async () => { it("should return early if the user refuses help", async () => {
@@ -628,7 +628,7 @@ describe("local databases", () => {
await (databaseManager as any).createSkeletonPacks(mockDbItem); await (databaseManager as any).createSkeletonPacks(mockDbItem);
expect(generateSpy).not.toBeCalled(); expect(generateSpy).not.toHaveBeenCalled();
}); });
it("should return early if the user escapes out of the dialog", async () => { it("should return early if the user escapes out of the dialog", async () => {
@@ -638,7 +638,7 @@ describe("local databases", () => {
await (databaseManager as any).createSkeletonPacks(mockDbItem); await (databaseManager as any).createSkeletonPacks(mockDbItem);
expect(generateSpy).not.toBeCalled(); expect(generateSpy).not.toHaveBeenCalled();
}); });
it("should return early and write choice to settings if user wants to never be asked again", async () => { it("should return early and write choice to settings if user wants to never be asked again", async () => {
@@ -652,14 +652,14 @@ describe("local databases", () => {
await (databaseManager as any).createSkeletonPacks(mockDbItem); await (databaseManager as any).createSkeletonPacks(mockDbItem);
expect(generateSpy).not.toBeCalled(); expect(generateSpy).not.toHaveBeenCalled();
expect(setAutogenerateQlPacksSpy).toHaveBeenCalledWith("never"); expect(setAutogenerateQlPacksSpy).toHaveBeenCalledWith("never");
}); });
it("should create the skeleton QL pack for the user", async () => { it("should create the skeleton QL pack for the user", async () => {
await (databaseManager as any).createSkeletonPacks(mockDbItem); await (databaseManager as any).createSkeletonPacks(mockDbItem);
expect(generateSpy).toBeCalled(); expect(generateSpy).toHaveBeenCalled();
}); });
}); });
@@ -694,7 +694,7 @@ describe("local databases", () => {
await (databaseManager as any).createSkeletonPacks(mockDbItem); await (databaseManager as any).createSkeletonPacks(mockDbItem);
expect(generateSpy).not.toBeCalled(); expect(generateSpy).not.toHaveBeenCalled();
}); });
}); });
}); });
@@ -742,7 +742,7 @@ describe("local databases", () => {
mockDbItem.origin, mockDbItem.origin,
); );
expect(resolveDatabaseContentsSpy).toBeCalledTimes(2); expect(resolveDatabaseContentsSpy).toHaveBeenCalledTimes(2);
}); });
it("should set the database as the currently selected one", async () => { it("should set the database as the currently selected one", async () => {
@@ -751,7 +751,7 @@ describe("local databases", () => {
mockDbItem.origin, mockDbItem.origin,
); );
expect(setCurrentDatabaseItemSpy).toBeCalledTimes(1); expect(setCurrentDatabaseItemSpy).toHaveBeenCalledTimes(1);
}); });
it("should not add database source archive folder when `codeQL.addingDatabases.addDatabaseSourceToWorkspace` is `false`", async () => { it("should not add database source archive folder when `codeQL.addingDatabases.addDatabaseSourceToWorkspace` is `false`", async () => {
@@ -762,7 +762,7 @@ describe("local databases", () => {
mockDbItem.origin, mockDbItem.origin,
); );
expect(addDatabaseSourceArchiveFolderSpy).toBeCalledTimes(0); expect(addDatabaseSourceArchiveFolderSpy).toHaveBeenCalledTimes(0);
}); });
it("should add database source archive folder when `codeQL.addingDatabases.addDatabaseSourceToWorkspace` is `true`", async () => { it("should add database source archive folder when `codeQL.addingDatabases.addDatabaseSourceToWorkspace` is `true`", async () => {
@@ -773,7 +773,7 @@ describe("local databases", () => {
mockDbItem.origin, mockDbItem.origin,
); );
expect(addDatabaseSourceArchiveFolderSpy).toBeCalledTimes(1); expect(addDatabaseSourceArchiveFolderSpy).toHaveBeenCalledTimes(1);
}); });
describe("when codeQL.codespacesTemplate is set to true", () => { describe("when codeQL.codespacesTemplate is set to true", () => {
@@ -793,7 +793,7 @@ describe("local databases", () => {
{ isTutorialDatabase }, { isTutorialDatabase },
); );
expect(createSkeletonPacksSpy).toBeCalledTimes(0); expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(0);
}); });
}); });
@@ -806,7 +806,7 @@ describe("local databases", () => {
mockDbItem.origin, mockDbItem.origin,
); );
expect(createSkeletonPacksSpy).toBeCalledTimes(1); expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(1);
}); });
}); });
}); });
@@ -819,7 +819,7 @@ describe("local databases", () => {
mockDbItem.databaseUri, mockDbItem.databaseUri,
mockDbItem.origin, mockDbItem.origin,
); );
expect(createSkeletonPacksSpy).toBeCalledTimes(0); expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(0);
}); });
}); });
}); });

View File

@@ -39,7 +39,7 @@ describe("QueryTreeDataProvider", () => {
); );
expect(dataProvider.getChildren()).toEqual([]); expect(dataProvider.getChildren()).toEqual([]);
expect(executeCommand).toBeCalledWith( expect(executeCommand).toHaveBeenCalledWith(
"setContext", "setContext",
"codeQL.noQueries", "codeQL.noQueries",
true, true,
@@ -118,7 +118,7 @@ describe("QueryTreeDataProvider", () => {
onDidChangeQueriesEmitter.fire(); onDidChangeQueriesEmitter.fire();
expect(dataProvider.getChildren().length).toEqual(2); expect(dataProvider.getChildren().length).toEqual(2);
expect(executeCommand).toBeCalledWith( expect(executeCommand).toHaveBeenCalledWith(
"setContext", "setContext",
"codeQL.noQueries", "codeQL.noQueries",
false, false,

View File

@@ -114,8 +114,8 @@ describe("Launcher path", () => {
expect(result).toBe(pathToCmd); expect(result).toBe(pathToCmd);
// no warning or error message // no warning or error message
expect(warnSpy).toBeCalledTimes(0); expect(warnSpy).toHaveBeenCalledTimes(0);
expect(errorSpy).toBeCalledTimes(0); expect(errorSpy).toHaveBeenCalledTimes(0);
}); });
it("should warn when deprecated launcher is used, and new launcher is available", async () => { it("should warn when deprecated launcher is used, and new launcher is available", async () => {
@@ -132,8 +132,8 @@ describe("Launcher path", () => {
expect(result).toBe(pathToCmd); expect(result).toBe(pathToCmd);
// has warning message // has warning message
expect(warnSpy).toBeCalledTimes(1); expect(warnSpy).toHaveBeenCalledTimes(1);
expect(errorSpy).toBeCalledTimes(0); expect(errorSpy).toHaveBeenCalledTimes(0);
}); });
it("should warn when launcher path is incorrect", async () => { it("should warn when launcher path is incorrect", async () => {
@@ -147,7 +147,7 @@ describe("Launcher path", () => {
expect(result).toBeUndefined(); expect(result).toBeUndefined();
// no error message // no error message
expect(warnSpy).toBeCalledTimes(0); expect(warnSpy).toHaveBeenCalledTimes(0);
expect(errorSpy).toBeCalledTimes(1); expect(errorSpy).toHaveBeenCalledTimes(1);
}); });
}); });

View File

@@ -29,7 +29,7 @@ describe("tryOpenExternalFile", () => {
Uri.file("xxx"), Uri.file("xxx"),
expect.anything(), expect.anything(),
); );
expect(executeCommand).not.toBeCalled(); expect(executeCommand).not.toHaveBeenCalled();
}); });
[ [
@@ -61,8 +61,8 @@ describe("tryOpenExternalFile", () => {
const uri = Uri.file("xxx"); const uri = Uri.file("xxx");
expect(showTextDocumentSpy).toHaveBeenCalledTimes(1); expect(showTextDocumentSpy).toHaveBeenCalledTimes(1);
expect(showTextDocumentSpy).toHaveBeenCalledWith(uri, expect.anything()); expect(showTextDocumentSpy).toHaveBeenCalledWith(uri, expect.anything());
expect(showInformationMessageSpy).toBeCalled(); expect(showInformationMessageSpy).toHaveBeenCalled();
expect(executeCommand).not.toBeCalled(); expect(executeCommand).not.toHaveBeenCalled();
}); });
}); });
}); });

View File

@@ -17,18 +17,18 @@ describe("helpers", () => {
listener({ length: firstStep }); listener({ length: firstStep });
listener({ length: secondStep }); listener({ length: secondStep });
expect(progressSpy).toBeCalledTimes(3); expect(progressSpy).toHaveBeenCalledTimes(3);
expect(progressSpy).toBeCalledWith({ expect(progressSpy).toHaveBeenCalledWith({
step: 0, step: 0,
maxStep: max, maxStep: max,
message: "My prefix [0.0 MB of 4.0 MB]", message: "My prefix [0.0 MB of 4.0 MB]",
}); });
expect(progressSpy).toBeCalledWith({ expect(progressSpy).toHaveBeenCalledWith({
step: firstStep, step: firstStep,
maxStep: max, maxStep: max,
message: "My prefix [1.6 MB of 4.0 MB]", message: "My prefix [1.6 MB of 4.0 MB]",
}); });
expect(progressSpy).toBeCalledWith({ expect(progressSpy).toHaveBeenCalledWith({
step: firstStep + secondStep, step: firstStep + secondStep,
maxStep: max, maxStep: max,
message: "My prefix [3.6 MB of 4.0 MB]", message: "My prefix [3.6 MB of 4.0 MB]",
@@ -48,10 +48,10 @@ describe("helpers", () => {
); );
// There are no listeners registered to this readable // There are no listeners registered to this readable
expect(mockReadable.on).not.toBeCalled(); expect(mockReadable.on).not.toHaveBeenCalled();
expect(progressSpy).toBeCalledTimes(1); expect(progressSpy).toHaveBeenCalledTimes(1);
expect(progressSpy).toBeCalledWith({ expect(progressSpy).toHaveBeenCalledWith({
step: 1, step: 1,
maxStep: 2, maxStep: 2,
message: "My prefix (Size unknown)", message: "My prefix (Size unknown)",

View File

@@ -145,7 +145,7 @@ describe("database-fetcher", () => {
await expect( await expect(
convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy), convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy),
).rejects.toThrow(/Unable to get database/); ).rejects.toThrow(/Unable to get database/);
expect(progressSpy).toBeCalledTimes(0); expect(progressSpy).toHaveBeenCalledTimes(0);
}); });
// User has access to the repository, but there are no databases for any language. // User has access to the repository, but there are no databases for any language.
@@ -159,7 +159,7 @@ describe("database-fetcher", () => {
await expect( await expect(
convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy), convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy),
).rejects.toThrow(/Unable to get database/); ).rejects.toThrow(/Unable to get database/);
expect(progressSpy).toBeCalledTimes(1); expect(progressSpy).toHaveBeenCalledTimes(1);
}); });
describe("when language is already provided", () => { describe("when language is already provided", () => {

View File

@@ -55,9 +55,9 @@ describe("AstBuilder", () => {
const bqrsPath = path.normalize("/a/b/c/results.bqrs"); const bqrsPath = path.normalize("/a/b/c/results.bqrs");
const options = { entities: ["id", "url", "string"] }; const options = { entities: ["id", "url", "string"] };
expect(mockCli.bqrsDecode).toBeCalledWith(bqrsPath, "nodes", options); expect(mockCli.bqrsDecode).toHaveBeenCalledWith(bqrsPath, "nodes", options);
expect(mockCli.bqrsDecode).toBeCalledWith(bqrsPath, "edges", options); expect(mockCli.bqrsDecode).toHaveBeenCalledWith(bqrsPath, "edges", options);
expect(mockCli.bqrsDecode).toBeCalledWith( expect(mockCli.bqrsDecode).toHaveBeenCalledWith(
bqrsPath, bqrsPath,
"graphProperties", "graphProperties",
options, options,

View File

@@ -86,9 +86,9 @@ describe("AstViewer", () => {
const mockEvent = createMockEvent(selectionRange, fileUri); const mockEvent = createMockEvent(selectionRange, fileUri);
(viewer as any).updateTreeSelection(mockEvent); (viewer as any).updateTreeSelection(mockEvent);
if (expectedSelection) { if (expectedSelection) {
expect(revealMock).toBeCalledWith(expectedSelection); expect(revealMock).toHaveBeenCalledWith(expectedSelection);
} else { } else {
expect(revealMock).not.toBeCalled(); expect(revealMock).not.toHaveBeenCalled();
} }
} }

View File

@@ -49,7 +49,7 @@ describe("qlpackOfDatabase", () => {
dbschemePack: "my-qlpack", dbschemePack: "my-qlpack",
dbschemePackIsLibraryPack: false, dbschemePackIsLibraryPack: false,
}); });
expect(getPrimaryDbschemeSpy).toBeCalledWith("/path/to/database"); expect(getPrimaryDbschemeSpy).toHaveBeenCalledWith("/path/to/database");
}); });
}); });

View File

@@ -594,7 +594,7 @@ describe("QueryHistoryManager", () => {
const cancelSpy = jest.spyOn(inProgress1, "cancel"); const cancelSpy = jest.spyOn(inProgress1, "cancel");
await queryHistoryManager.handleCancel([inProgress1]); await queryHistoryManager.handleCancel([inProgress1]);
expect(cancelSpy).toBeCalledTimes(1); expect(cancelSpy).toHaveBeenCalledTimes(1);
}); });
it("should cancel multiple local queries", async () => { it("should cancel multiple local queries", async () => {
@@ -608,8 +608,8 @@ describe("QueryHistoryManager", () => {
const cancelSpy2 = jest.spyOn(inProgress2, "cancel"); const cancelSpy2 = jest.spyOn(inProgress2, "cancel");
await queryHistoryManager.handleCancel([inProgress1, inProgress2]); await queryHistoryManager.handleCancel([inProgress1, inProgress2]);
expect(cancelSpy1).toBeCalled(); expect(cancelSpy1).toHaveBeenCalled();
expect(cancelSpy2).toBeCalled(); expect(cancelSpy2).toHaveBeenCalled();
}); });
it("should cancel a single variant analysis", async () => { it("should cancel a single variant analysis", async () => {
@@ -619,7 +619,7 @@ describe("QueryHistoryManager", () => {
const inProgress1 = variantAnalysisHistory[1]; const inProgress1 = variantAnalysisHistory[1];
await queryHistoryManager.handleCancel([inProgress1]); await queryHistoryManager.handleCancel([inProgress1]);
expect(cancelVariantAnalysisSpy).toBeCalledWith( expect(cancelVariantAnalysisSpy).toHaveBeenCalledWith(
inProgress1.variantAnalysis.id, inProgress1.variantAnalysis.id,
); );
}); });
@@ -632,10 +632,10 @@ describe("QueryHistoryManager", () => {
const inProgress2 = variantAnalysisHistory[3]; const inProgress2 = variantAnalysisHistory[3];
await queryHistoryManager.handleCancel([inProgress1, inProgress2]); await queryHistoryManager.handleCancel([inProgress1, inProgress2]);
expect(cancelVariantAnalysisSpy).toBeCalledWith( expect(cancelVariantAnalysisSpy).toHaveBeenCalledWith(
inProgress1.variantAnalysis.id, inProgress1.variantAnalysis.id,
); );
expect(cancelVariantAnalysisSpy).toBeCalledWith( expect(cancelVariantAnalysisSpy).toHaveBeenCalledWith(
inProgress2.variantAnalysis.id, inProgress2.variantAnalysis.id,
); );
}); });
@@ -650,7 +650,7 @@ describe("QueryHistoryManager", () => {
const cancelSpy = jest.spyOn(completed, "cancel"); const cancelSpy = jest.spyOn(completed, "cancel");
await queryHistoryManager.handleCancel([completed]); await queryHistoryManager.handleCancel([completed]);
expect(cancelSpy).not.toBeCalledTimes(1); expect(cancelSpy).not.toHaveBeenCalledTimes(1);
}); });
it("should not cancel multiple local queries", async () => { it("should not cancel multiple local queries", async () => {
@@ -664,8 +664,8 @@ describe("QueryHistoryManager", () => {
const cancelSpy2 = jest.spyOn(failed, "cancel"); const cancelSpy2 = jest.spyOn(failed, "cancel");
await queryHistoryManager.handleCancel([completed, failed]); await queryHistoryManager.handleCancel([completed, failed]);
expect(cancelSpy).not.toBeCalledTimes(1); expect(cancelSpy).not.toHaveBeenCalledTimes(1);
expect(cancelSpy2).not.toBeCalledTimes(1); expect(cancelSpy2).not.toHaveBeenCalledTimes(1);
}); });
it("should not cancel a single variant analysis", async () => { it("should not cancel a single variant analysis", async () => {
@@ -675,7 +675,7 @@ describe("QueryHistoryManager", () => {
const completedVariantAnalysis = variantAnalysisHistory[0]; const completedVariantAnalysis = variantAnalysisHistory[0];
await queryHistoryManager.handleCancel([completedVariantAnalysis]); await queryHistoryManager.handleCancel([completedVariantAnalysis]);
expect(cancelVariantAnalysisSpy).not.toBeCalledWith( expect(cancelVariantAnalysisSpy).not.toHaveBeenCalledWith(
completedVariantAnalysis.variantAnalysis, completedVariantAnalysis.variantAnalysis,
); );
}); });
@@ -691,10 +691,10 @@ describe("QueryHistoryManager", () => {
completedVariantAnalysis, completedVariantAnalysis,
failedVariantAnalysis, failedVariantAnalysis,
]); ]);
expect(cancelVariantAnalysisSpy).not.toBeCalledWith( expect(cancelVariantAnalysisSpy).not.toHaveBeenCalledWith(
completedVariantAnalysis.variantAnalysis.id, completedVariantAnalysis.variantAnalysis.id,
); );
expect(cancelVariantAnalysisSpy).not.toBeCalledWith( expect(cancelVariantAnalysisSpy).not.toHaveBeenCalledWith(
failedVariantAnalysis.variantAnalysis.id, failedVariantAnalysis.variantAnalysis.id,
); );
}); });
@@ -708,7 +708,7 @@ describe("QueryHistoryManager", () => {
const item = localQueryHistory[4]; const item = localQueryHistory[4];
await queryHistoryManager.handleCopyRepoList(item); await queryHistoryManager.handleCopyRepoList(item);
expect(executeCommand).not.toBeCalled(); expect(executeCommand).not.toHaveBeenCalled();
}); });
it("should copy repo list for a single variant analysis", async () => { it("should copy repo list for a single variant analysis", async () => {
@@ -718,9 +718,9 @@ describe("QueryHistoryManager", () => {
const item = variantAnalysisHistory[1]; const item = variantAnalysisHistory[1];
await queryHistoryManager.handleCopyRepoList(item); await queryHistoryManager.handleCopyRepoList(item);
expect(variantAnalysisManagerStub.copyRepoListToClipboard).toBeCalledWith( expect(
item.variantAnalysis.id, variantAnalysisManagerStub.copyRepoListToClipboard,
); ).toHaveBeenCalledWith(item.variantAnalysis.id);
}); });
}); });
@@ -731,7 +731,7 @@ describe("QueryHistoryManager", () => {
const item = localQueryHistory[4]; const item = localQueryHistory[4];
await queryHistoryManager.handleExportResults(item); await queryHistoryManager.handleExportResults(item);
expect(variantAnalysisManagerStub.exportResults).not.toBeCalled(); expect(variantAnalysisManagerStub.exportResults).not.toHaveBeenCalled();
}); });
it("should export results for a single variant analysis", async () => { it("should export results for a single variant analysis", async () => {
@@ -739,7 +739,7 @@ describe("QueryHistoryManager", () => {
const item = variantAnalysisHistory[1]; const item = variantAnalysisHistory[1];
await queryHistoryManager.handleExportResults(item); await queryHistoryManager.handleExportResults(item);
expect(variantAnalysisManagerStub.exportResults).toBeCalledWith( expect(variantAnalysisManagerStub.exportResults).toHaveBeenCalledWith(
item.variantAnalysis.id, item.variantAnalysis.id,
); );
}); });
@@ -801,7 +801,7 @@ describe("QueryHistoryManager", () => {
queryHistoryManager as any queryHistoryManager as any
).findOtherQueryToCompare(thisQuery, [thisQuery, localQueryHistory[0]]); ).findOtherQueryToCompare(thisQuery, [thisQuery, localQueryHistory[0]]);
expect(otherQuery).toBe(localQueryHistory[0]); expect(otherQuery).toBe(localQueryHistory[0]);
expect(showQuickPickSpy).not.toBeCalled(); expect(showQuickPickSpy).not.toHaveBeenCalled();
}); });
it("should throw an error when a databases are not the same", async () => { it("should throw an error when a databases are not the same", async () => {
@@ -850,7 +850,7 @@ describe("QueryHistoryManager", () => {
await queryHistoryManager.handleCompareWith(localQueryHistory[0], [ await queryHistoryManager.handleCompareWith(localQueryHistory[0], [
localQueryHistory[0], localQueryHistory[0],
]); ]);
expect(doCompareCallback).not.toBeCalled(); expect(doCompareCallback).not.toHaveBeenCalled();
}); });
it("should throw an error when a query is not successful", async () => { it("should throw an error when a query is not successful", async () => {

View File

@@ -119,7 +119,7 @@ describe("Variant Analyses and QueryHistoryManager", () => {
it("should read query history that has variant analysis history items", async () => { it("should read query history that has variant analysis history items", async () => {
await qhm.readQueryHistory(); await qhm.readQueryHistory();
expect(rehydrateVariantAnalysisStub).toBeCalledTimes(2); expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
expect(rehydrateVariantAnalysisStub).toHaveBeenNthCalledWith( expect(rehydrateVariantAnalysisStub).toHaveBeenNthCalledWith(
1, 1,
rawQueryHistory[0].variantAnalysis, rawQueryHistory[0].variantAnalysis,
@@ -142,8 +142,8 @@ describe("Variant Analyses and QueryHistoryManager", () => {
// Add it back to the history // Add it back to the history
qhm.addQuery(rawQueryHistory[0]); qhm.addQuery(rawQueryHistory[0]);
expect(removeVariantAnalysisStub).toBeCalledTimes(1); expect(removeVariantAnalysisStub).toHaveBeenCalledTimes(1);
expect(rehydrateVariantAnalysisStub).toBeCalledTimes(2); expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
expect(qhm.treeDataProvider.allHistory).toEqual([ expect(qhm.treeDataProvider.allHistory).toEqual([
rawQueryHistory[1], rawQueryHistory[1],
rawQueryHistory[0], rawQueryHistory[0],
@@ -184,7 +184,9 @@ describe("Variant Analyses and QueryHistoryManager", () => {
await qhm.readQueryHistory(); await qhm.readQueryHistory();
await qhm.handleItemClicked(qhm.treeDataProvider.allHistory[0]); await qhm.handleItemClicked(qhm.treeDataProvider.allHistory[0]);
expect(showViewStub).toBeCalledWith(rawQueryHistory[0].variantAnalysis.id); expect(showViewStub).toHaveBeenCalledWith(
rawQueryHistory[0].variantAnalysis.id,
);
}); });
it("should get the query text", async () => { it("should get the query text", async () => {

View File

@@ -130,7 +130,7 @@ describe("query-results", () => {
queryPath, queryPath,
"sortedResults-cc8589f226adc134f87f2438e10075e0667571c72342068e2281e0b3b65e1092.bqrs", "sortedResults-cc8589f226adc134f87f2438e10075e0667571c72342068e2281e0b3b65e1092.bqrs",
); );
expect(spy).toBeCalledWith( expect(spy).toHaveBeenCalledWith(
expectedResultsPath, expectedResultsPath,
expectedSortedResultsPath, expectedSortedResultsPath,
"a-result-set-name", "a-result-set-name",
@@ -189,7 +189,7 @@ describe("query-results", () => {
); );
expect(results).toEqual({ a: "1234", t: "SarifInterpretationData" }); expect(results).toEqual({ a: "1234", t: "SarifInterpretationData" });
expect(spy).toBeCalledWith( expect(spy).toHaveBeenCalledWith(
metadata, metadata,
resultsPath, resultsPath,
interpretedResultsPath, interpretedResultsPath,
@@ -214,7 +214,7 @@ describe("query-results", () => {
sourceInfo as SourceInfo, sourceInfo as SourceInfo,
); );
expect(results).toEqual({ a: "1234", t: "SarifInterpretationData" }); expect(results).toEqual({ a: "1234", t: "SarifInterpretationData" });
expect(spy).toBeCalledWith( expect(spy).toHaveBeenCalledWith(
{ kind: "my-kind", id: "dummy-id", scored: undefined }, { kind: "my-kind", id: "dummy-id", scored: undefined },
resultsPath, resultsPath,
interpretedResultsPath, interpretedResultsPath,
@@ -245,7 +245,7 @@ describe("query-results", () => {
sourceInfo as SourceInfo, sourceInfo as SourceInfo,
); );
// We do not re-interpret if we are reading from a SARIF file. // We do not re-interpret if we are reading from a SARIF file.
expect(spy).not.toBeCalled(); expect(spy).not.toHaveBeenCalled();
expect(results).toHaveProperty("t", "SarifInterpretationData"); expect(results).toHaveProperty("t", "SarifInterpretationData");
expect(results).toHaveProperty("runs[0].results"); expect(results).toHaveProperty("runs[0].results");
@@ -279,7 +279,7 @@ describe("query-results", () => {
); );
// We do not attempt to re-interpret if we are reading from a SARIF file. // We do not attempt to re-interpret if we are reading from a SARIF file.
expect(spy).not.toBeCalled(); expect(spy).not.toHaveBeenCalled();
}, },
2 * 60 * 1000, // up to 2 minutes per test 2 * 60 * 1000, // up to 2 minutes per test
); );
@@ -336,7 +336,7 @@ describe("query-results", () => {
sourceInfo as SourceInfo, sourceInfo as SourceInfo,
); );
// We do not re-interpret if we are reading from a SARIF file. // We do not re-interpret if we are reading from a SARIF file.
expect(spy).not.toBeCalled(); expect(spy).not.toHaveBeenCalled();
expect(results).toHaveProperty("t", "SarifInterpretationData"); expect(results).toHaveProperty("t", "SarifInterpretationData");
expect(results).toHaveProperty("runs[0].results"); expect(results).toHaveProperty("runs[0].results");
@@ -400,7 +400,7 @@ describe("query-results", () => {
); );
// We do not attempt to re-interpret if we are reading from a SARIF file. // We do not attempt to re-interpret if we are reading from a SARIF file.
expect(spy).not.toBeCalled(); expect(spy).not.toHaveBeenCalled();
}, },
2 * 60 * 1000, // up to 2 minutes per test 2 * 60 * 1000, // up to 2 minutes per test
); );

View File

@@ -95,8 +95,8 @@ describe("test-adapter", () => {
const request = new TestRunRequest([rootItem]); const request = new TestRunRequest([rootItem]);
await testManager.run(request, new CancellationTokenSource().token); await testManager.run(request, new CancellationTokenSource().token);
expect(enqueuedSpy).toBeCalledTimes(3); expect(enqueuedSpy).toHaveBeenCalledTimes(3);
expect(passedSpy).toBeCalledTimes(1); expect(passedSpy).toHaveBeenCalledTimes(1);
expect(passedSpy).toHaveBeenCalledWith(childItems[0], 3000); expect(passedSpy).toHaveBeenCalledWith(childItems[0], 3000);
expect(erroredSpy).toHaveBeenCalledTimes(1); expect(erroredSpy).toHaveBeenCalledTimes(1);
expect(erroredSpy).toHaveBeenCalledWith( expect(erroredSpy).toHaveBeenCalledWith(
@@ -121,7 +121,7 @@ describe("test-adapter", () => {
], ],
11000, 11000,
); );
expect(failedSpy).toBeCalledTimes(1); expect(failedSpy).toHaveBeenCalledTimes(1);
expect(endSpy).toBeCalledTimes(1); expect(endSpy).toHaveBeenCalledTimes(1);
}); });
}); });

View File

@@ -94,7 +94,7 @@ describe("test-runner", () => {
eventHandlerSpy, eventHandlerSpy,
); );
expect(eventHandlerSpy).toBeCalledTimes(3); expect(eventHandlerSpy).toHaveBeenCalledTimes(3);
expect(eventHandlerSpy).toHaveBeenNthCalledWith(1, { expect(eventHandlerSpy).toHaveBeenNthCalledWith(1, {
test: mockTestsInfo.dPath, test: mockTestsInfo.dPath,
@@ -160,24 +160,24 @@ describe("test-runner", () => {
setCurrentDatabaseItemSpy.mock.invocationCallOrder[0], setCurrentDatabaseItemSpy.mock.invocationCallOrder[0],
).toBeGreaterThan(openDatabaseSpy.mock.invocationCallOrder[0]); ).toBeGreaterThan(openDatabaseSpy.mock.invocationCallOrder[0]);
expect(removeDatabaseItemSpy).toBeCalledTimes(1); expect(removeDatabaseItemSpy).toHaveBeenCalledTimes(1);
expect(removeDatabaseItemSpy).toBeCalledWith(preTestDatabaseItem); expect(removeDatabaseItemSpy).toHaveBeenCalledWith(preTestDatabaseItem);
expect(openDatabaseSpy).toBeCalledTimes(1); expect(openDatabaseSpy).toHaveBeenCalledTimes(1);
expect(openDatabaseSpy).toBeCalledWith( expect(openDatabaseSpy).toHaveBeenCalledWith(
preTestDatabaseItem.databaseUri, preTestDatabaseItem.databaseUri,
preTestDatabaseItem.origin, preTestDatabaseItem.origin,
false, false,
); );
expect(renameDatabaseItemSpy).toBeCalledTimes(1); expect(renameDatabaseItemSpy).toHaveBeenCalledTimes(1);
expect(renameDatabaseItemSpy).toBeCalledWith( expect(renameDatabaseItemSpy).toHaveBeenCalledWith(
postTestDatabaseItem, postTestDatabaseItem,
preTestDatabaseItem.name, preTestDatabaseItem.name,
); );
expect(setCurrentDatabaseItemSpy).toBeCalledTimes(1); expect(setCurrentDatabaseItemSpy).toHaveBeenCalledTimes(1);
expect(setCurrentDatabaseItemSpy).toBeCalledWith( expect(setCurrentDatabaseItemSpy).toHaveBeenCalledWith(
postTestDatabaseItem, postTestDatabaseItem,
true, true,
); );

View File

@@ -152,17 +152,17 @@ describe("telemetry reporting", () => {
expect(telemetryListener._reporter).toBeDefined(); expect(telemetryListener._reporter).toBeDefined();
expect(telemetryListener._reporter).not.toBe(firstReporter); expect(telemetryListener._reporter).not.toBe(firstReporter);
expect(disposeSpy).toBeCalledTimes(1); expect(disposeSpy).toHaveBeenCalledTimes(1);
// initializing a third time continues to dispose // initializing a third time continues to dispose
await telemetryListener.initialize(); await telemetryListener.initialize();
expect(disposeSpy).toBeCalledTimes(2); expect(disposeSpy).toHaveBeenCalledTimes(2);
}); });
it("should reinitialize reporter when extension setting changes", async () => { it("should reinitialize reporter when extension setting changes", async () => {
await telemetryListener.initialize(); await telemetryListener.initialize();
expect(disposeSpy).not.toBeCalled(); expect(disposeSpy).not.toHaveBeenCalled();
expect(telemetryListener._reporter).toBeDefined(); expect(telemetryListener._reporter).toBeDefined();
// this disables the reporter // this disables the reporter
@@ -170,13 +170,13 @@ describe("telemetry reporting", () => {
expect(telemetryListener._reporter).toBeUndefined(); expect(telemetryListener._reporter).toBeUndefined();
expect(disposeSpy).toBeCalledTimes(1); expect(disposeSpy).toHaveBeenCalledTimes(1);
// creates a new reporter, but does not dispose again // creates a new reporter, but does not dispose again
await enableTelemetry("codeQL.telemetry", true); await enableTelemetry("codeQL.telemetry", true);
expect(telemetryListener._reporter).toBeDefined(); expect(telemetryListener._reporter).toBeDefined();
expect(disposeSpy).toBeCalledTimes(1); expect(disposeSpy).toHaveBeenCalledTimes(1);
}); });
it("should set userOprIn to false when global setting changes", async () => { it("should set userOprIn to false when global setting changes", async () => {
@@ -205,7 +205,7 @@ describe("telemetry reporting", () => {
}, },
{ executionTime: 1234 }, { executionTime: 1234 },
); );
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
}); });
it("should send a command usage event with an error", async () => { it("should send a command usage event with an error", async () => {
@@ -227,7 +227,7 @@ describe("telemetry reporting", () => {
}, },
{ executionTime: 1234 }, { executionTime: 1234 },
); );
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
}); });
it("should send a command usage event with a cli version", async () => { it("should send a command usage event with a cli version", async () => {
@@ -250,7 +250,7 @@ describe("telemetry reporting", () => {
}, },
{ executionTime: 1234 }, { executionTime: 1234 },
); );
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
// Verify that if the cli version is not set, then the telemetry falls back to "not-set" // Verify that if the cli version is not set, then the telemetry falls back to "not-set"
sendTelemetryEventSpy.mockClear(); sendTelemetryEventSpy.mockClear();
@@ -272,7 +272,7 @@ describe("telemetry reporting", () => {
}, },
{ executionTime: 5678 }, { executionTime: 5678 },
); );
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
}); });
it("should avoid sending an event when telemetry is disabled", async () => { it("should avoid sending an event when telemetry is disabled", async () => {
@@ -282,8 +282,8 @@ describe("telemetry reporting", () => {
telemetryListener.sendCommandUsage("command-id", 1234, undefined); telemetryListener.sendCommandUsage("command-id", 1234, undefined);
telemetryListener.sendCommandUsage("command-id", 1234, new Error()); telemetryListener.sendCommandUsage("command-id", 1234, new Error());
expect(sendTelemetryEventSpy).not.toBeCalled(); expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
}); });
it("should send an event when telemetry is re-enabled", async () => { it("should send an event when telemetry is re-enabled", async () => {
@@ -303,7 +303,7 @@ describe("telemetry reporting", () => {
}, },
{ executionTime: 1234 }, { executionTime: 1234 },
); );
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
}); });
it("should filter undesired properties from telemetry payload", async () => { it("should filter undesired properties from telemetry payload", async () => {
@@ -361,7 +361,7 @@ describe("telemetry reporting", () => {
await wait(500); await wait(500);
// Dialog opened, user clicks "yes" and telemetry enabled // Dialog opened, user clicks "yes" and telemetry enabled
expect(showInformationMessageSpy).toBeCalledTimes(1); expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
expect(ENABLE_TELEMETRY.getValue()).toBe(true); expect(ENABLE_TELEMETRY.getValue()).toBe(true);
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(true); expect(ctx.globalState.get("telemetry-request-viewed")).toBe(true);
}); });
@@ -374,7 +374,7 @@ describe("telemetry reporting", () => {
await telemetryListener.initialize(); await telemetryListener.initialize();
// Dialog opened, user clicks "no" and telemetry disabled // Dialog opened, user clicks "no" and telemetry disabled
expect(showInformationMessageSpy).toBeCalledTimes(1); expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
expect(ENABLE_TELEMETRY.getValue()).toBe(false); expect(ENABLE_TELEMETRY.getValue()).toBe(false);
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(true); expect(ctx.globalState.get("telemetry-request-viewed")).toBe(true);
}); });
@@ -387,7 +387,7 @@ describe("telemetry reporting", () => {
await enableTelemetry("codeQL.telemetry", false); await enableTelemetry("codeQL.telemetry", false);
// Dialog opened, and user closes without interacting with it // Dialog opened, and user closes without interacting with it
expect(showInformationMessageSpy).toBeCalledTimes(1); expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
expect(ENABLE_TELEMETRY.getValue()).toBe(false); expect(ENABLE_TELEMETRY.getValue()).toBe(false);
// dialog was canceled, so should not have marked as viewed // dialog was canceled, so should not have marked as viewed
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(false); expect(ctx.globalState.get("telemetry-request-viewed")).toBe(false);
@@ -406,7 +406,7 @@ describe("telemetry reporting", () => {
// Dialog opened, and user closes without interacting with it // Dialog opened, and user closes without interacting with it
// Telemetry state should not have changed // Telemetry state should not have changed
expect(showInformationMessageSpy).toBeCalledTimes(1); expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
expect(ENABLE_TELEMETRY.getValue()).toBe(true); expect(ENABLE_TELEMETRY.getValue()).toBe(true);
// dialog was canceled, so should not have marked as viewed // dialog was canceled, so should not have marked as viewed
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(false); expect(ctx.globalState.get("telemetry-request-viewed")).toBe(false);
@@ -426,7 +426,7 @@ describe("telemetry reporting", () => {
await telemetryListener.initialize(); await telemetryListener.initialize();
// popup should not be shown even though we have initialized telemetry // popup should not be shown even though we have initialized telemetry
expect(showInformationMessageSpy).not.toBeCalled(); expect(showInformationMessageSpy).not.toHaveBeenCalled();
}); });
// This test is failing because codeQL.canary is not a registered configuration. // This test is failing because codeQL.canary is not a registered configuration.
@@ -447,7 +447,7 @@ describe("telemetry reporting", () => {
// now, we should have to click through the telemetry requestor again // now, we should have to click through the telemetry requestor again
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(false); expect(ctx.globalState.get("telemetry-request-viewed")).toBe(false);
expect(showInformationMessageSpy).toBeCalledTimes(1); expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
}); });
it("should send a ui-interaction telementry event", async () => { it("should send a ui-interaction telementry event", async () => {
@@ -464,7 +464,7 @@ describe("telemetry reporting", () => {
}, },
{}, {},
); );
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
}); });
it("should send a ui-interaction telementry event with a cli version", async () => { it("should send a ui-interaction telementry event with a cli version", async () => {
@@ -482,7 +482,7 @@ describe("telemetry reporting", () => {
}, },
{}, {},
); );
expect(sendTelemetryErrorEventSpy).not.toBeCalled(); expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
}); });
it("should send an error telementry event", async () => { it("should send an error telementry event", async () => {
@@ -490,7 +490,7 @@ describe("telemetry reporting", () => {
telemetryListener.sendError(redactableError`test`); telemetryListener.sendError(redactableError`test`);
expect(sendTelemetryEventSpy).not.toBeCalled(); expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith( expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith(
"error", "error",
{ {
@@ -509,7 +509,7 @@ describe("telemetry reporting", () => {
telemetryListener.sendError(redactableError`test`); telemetryListener.sendError(redactableError`test`);
expect(sendTelemetryEventSpy).not.toBeCalled(); expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith( expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith(
"error", "error",
{ {
@@ -529,7 +529,7 @@ describe("telemetry reporting", () => {
redactableError`test message with secret information: ${42} and more ${"secret"} parts`, redactableError`test message with secret information: ${42} and more ${"secret"} parts`,
); );
expect(sendTelemetryEventSpy).not.toBeCalled(); expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith( expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith(
"error", "error",
{ {