Replace toBeCalledTimes
This commit is contained in:
@@ -96,7 +96,7 @@ describe("Variant Analysis Manager", () => {
|
||||
|
||||
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(getResultsSpy).toBeCalledTimes(3);
|
||||
expect(getResultsSpy).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -451,7 +451,7 @@ describe("Variant Analysis Manager", () => {
|
||||
|
||||
await variantAnalysisManager.removeVariantAnalysis(dummyVariantAnalysis);
|
||||
|
||||
expect(removeAnalysisResultsStub).toBeCalledTimes(1);
|
||||
expect(removeAnalysisResultsStub).toHaveBeenCalledTimes(1);
|
||||
expect(variantAnalysisManager.variantAnalysesSize).toBe(0);
|
||||
|
||||
await expect(
|
||||
@@ -722,7 +722,7 @@ describe("Variant Analysis Manager", () => {
|
||||
variantAnalysis.id,
|
||||
);
|
||||
|
||||
expect(writeTextStub).toBeCalledTimes(1);
|
||||
expect(writeTextStub).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should be valid JSON when put in object", async () => {
|
||||
|
||||
@@ -121,7 +121,7 @@ describe("Variant Analysis Monitor", () => {
|
||||
);
|
||||
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
|
||||
|
||||
expect(mockEecuteCommand).toBeCalledTimes(succeededRepos.length);
|
||||
expect(mockEecuteCommand).toHaveBeenCalledTimes(succeededRepos.length);
|
||||
|
||||
succeededRepos.forEach((succeededRepo, index) => {
|
||||
expect(mockEecuteCommand).toHaveBeenNthCalledWith(
|
||||
@@ -197,8 +197,8 @@ describe("Variant Analysis Monitor", () => {
|
||||
it("should trigger a download extension command for each repo", async () => {
|
||||
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
|
||||
|
||||
expect(mockGetVariantAnalysis).toBeCalledTimes(4);
|
||||
expect(mockEecuteCommand).toBeCalledTimes(5);
|
||||
expect(mockGetVariantAnalysis).toHaveBeenCalledTimes(4);
|
||||
expect(mockEecuteCommand).toHaveBeenCalledTimes(5);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -261,7 +261,7 @@ describe("Variant Analysis Monitor", () => {
|
||||
it("should only trigger the warning once per error", async () => {
|
||||
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
|
||||
|
||||
expect(logger.showWarningMessage).toBeCalledTimes(4);
|
||||
expect(logger.showWarningMessage).toHaveBeenCalledTimes(4);
|
||||
expect(logger.showWarningMessage).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
expect.stringMatching(/No internet connection/),
|
||||
|
||||
@@ -113,8 +113,8 @@ describe("Variant Analysis Manager", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
|
||||
expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should run a remote query that is not part of a qlpack", async () => {
|
||||
@@ -134,8 +134,8 @@ describe("Variant Analysis Manager", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
|
||||
expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should run a remote query that is nested inside a qlpack", async () => {
|
||||
@@ -155,8 +155,8 @@ describe("Variant Analysis Manager", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
|
||||
expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should cancel a run before uploading", async () => {
|
||||
@@ -318,7 +318,7 @@ describe("Variant Analysis Manager", () => {
|
||||
cancellationTokenSource.token,
|
||||
);
|
||||
|
||||
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
|
||||
expect(executeCommandSpy).toHaveBeenCalledWith(
|
||||
"codeQL.monitorNewVariantAnalysis",
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -618,7 +618,7 @@ describe("local databases", () => {
|
||||
it("should offer the user to set up a skeleton QL pack", async () => {
|
||||
await (databaseManager as any).createSkeletonPacks(mockDbItem);
|
||||
|
||||
expect(showNeverAskAgainDialogSpy).toBeCalledTimes(1);
|
||||
expect(showNeverAskAgainDialogSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should return early if the user refuses help", async () => {
|
||||
@@ -742,7 +742,7 @@ describe("local databases", () => {
|
||||
mockDbItem.origin,
|
||||
);
|
||||
|
||||
expect(resolveDatabaseContentsSpy).toBeCalledTimes(2);
|
||||
expect(resolveDatabaseContentsSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("should set the database as the currently selected one", async () => {
|
||||
@@ -751,7 +751,7 @@ describe("local databases", () => {
|
||||
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 () => {
|
||||
@@ -762,7 +762,7 @@ describe("local databases", () => {
|
||||
mockDbItem.origin,
|
||||
);
|
||||
|
||||
expect(addDatabaseSourceArchiveFolderSpy).toBeCalledTimes(0);
|
||||
expect(addDatabaseSourceArchiveFolderSpy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it("should add database source archive folder when `codeQL.addingDatabases.addDatabaseSourceToWorkspace` is `true`", async () => {
|
||||
@@ -773,7 +773,7 @@ describe("local databases", () => {
|
||||
mockDbItem.origin,
|
||||
);
|
||||
|
||||
expect(addDatabaseSourceArchiveFolderSpy).toBeCalledTimes(1);
|
||||
expect(addDatabaseSourceArchiveFolderSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
describe("when codeQL.codespacesTemplate is set to true", () => {
|
||||
@@ -793,7 +793,7 @@ describe("local databases", () => {
|
||||
{ isTutorialDatabase },
|
||||
);
|
||||
|
||||
expect(createSkeletonPacksSpy).toBeCalledTimes(0);
|
||||
expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -806,7 +806,7 @@ describe("local databases", () => {
|
||||
mockDbItem.origin,
|
||||
);
|
||||
|
||||
expect(createSkeletonPacksSpy).toBeCalledTimes(1);
|
||||
expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -819,7 +819,7 @@ describe("local databases", () => {
|
||||
mockDbItem.databaseUri,
|
||||
mockDbItem.origin,
|
||||
);
|
||||
expect(createSkeletonPacksSpy).toBeCalledTimes(0);
|
||||
expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -114,8 +114,8 @@ describe("Launcher path", () => {
|
||||
expect(result).toBe(pathToCmd);
|
||||
|
||||
// no warning or error message
|
||||
expect(warnSpy).toBeCalledTimes(0);
|
||||
expect(errorSpy).toBeCalledTimes(0);
|
||||
expect(warnSpy).toHaveBeenCalledTimes(0);
|
||||
expect(errorSpy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
// has warning message
|
||||
expect(warnSpy).toBeCalledTimes(1);
|
||||
expect(errorSpy).toBeCalledTimes(0);
|
||||
expect(warnSpy).toHaveBeenCalledTimes(1);
|
||||
expect(errorSpy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it("should warn when launcher path is incorrect", async () => {
|
||||
@@ -147,7 +147,7 @@ describe("Launcher path", () => {
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
// no error message
|
||||
expect(warnSpy).toBeCalledTimes(0);
|
||||
expect(errorSpy).toBeCalledTimes(1);
|
||||
expect(warnSpy).toHaveBeenCalledTimes(0);
|
||||
expect(errorSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ describe("helpers", () => {
|
||||
listener({ length: firstStep });
|
||||
listener({ length: secondStep });
|
||||
|
||||
expect(progressSpy).toBeCalledTimes(3);
|
||||
expect(progressSpy).toHaveBeenCalledTimes(3);
|
||||
expect(progressSpy).toHaveBeenCalledWith({
|
||||
step: 0,
|
||||
maxStep: max,
|
||||
@@ -50,7 +50,7 @@ describe("helpers", () => {
|
||||
// There are no listeners registered to this readable
|
||||
expect(mockReadable.on).not.toHaveBeenCalled();
|
||||
|
||||
expect(progressSpy).toBeCalledTimes(1);
|
||||
expect(progressSpy).toHaveBeenCalledTimes(1);
|
||||
expect(progressSpy).toHaveBeenCalledWith({
|
||||
step: 1,
|
||||
maxStep: 2,
|
||||
|
||||
@@ -145,7 +145,7 @@ describe("database-fetcher", () => {
|
||||
await expect(
|
||||
convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy),
|
||||
).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.
|
||||
@@ -159,7 +159,7 @@ describe("database-fetcher", () => {
|
||||
await expect(
|
||||
convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy),
|
||||
).rejects.toThrow(/Unable to get database/);
|
||||
expect(progressSpy).toBeCalledTimes(1);
|
||||
expect(progressSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
describe("when language is already provided", () => {
|
||||
|
||||
@@ -594,7 +594,7 @@ describe("QueryHistoryManager", () => {
|
||||
const cancelSpy = jest.spyOn(inProgress1, "cancel");
|
||||
|
||||
await queryHistoryManager.handleCancel([inProgress1]);
|
||||
expect(cancelSpy).toBeCalledTimes(1);
|
||||
expect(cancelSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should cancel multiple local queries", async () => {
|
||||
@@ -650,7 +650,7 @@ describe("QueryHistoryManager", () => {
|
||||
const cancelSpy = jest.spyOn(completed, "cancel");
|
||||
|
||||
await queryHistoryManager.handleCancel([completed]);
|
||||
expect(cancelSpy).not.toBeCalledTimes(1);
|
||||
expect(cancelSpy).not.toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should not cancel multiple local queries", async () => {
|
||||
@@ -664,8 +664,8 @@ describe("QueryHistoryManager", () => {
|
||||
const cancelSpy2 = jest.spyOn(failed, "cancel");
|
||||
|
||||
await queryHistoryManager.handleCancel([completed, failed]);
|
||||
expect(cancelSpy).not.toBeCalledTimes(1);
|
||||
expect(cancelSpy2).not.toBeCalledTimes(1);
|
||||
expect(cancelSpy).not.toHaveBeenCalledTimes(1);
|
||||
expect(cancelSpy2).not.toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should not cancel a single variant analysis", async () => {
|
||||
|
||||
@@ -119,7 +119,7 @@ describe("Variant Analyses and QueryHistoryManager", () => {
|
||||
it("should read query history that has variant analysis history items", async () => {
|
||||
await qhm.readQueryHistory();
|
||||
|
||||
expect(rehydrateVariantAnalysisStub).toBeCalledTimes(2);
|
||||
expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
|
||||
expect(rehydrateVariantAnalysisStub).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
rawQueryHistory[0].variantAnalysis,
|
||||
@@ -142,8 +142,8 @@ describe("Variant Analyses and QueryHistoryManager", () => {
|
||||
|
||||
// Add it back to the history
|
||||
qhm.addQuery(rawQueryHistory[0]);
|
||||
expect(removeVariantAnalysisStub).toBeCalledTimes(1);
|
||||
expect(rehydrateVariantAnalysisStub).toBeCalledTimes(2);
|
||||
expect(removeVariantAnalysisStub).toHaveBeenCalledTimes(1);
|
||||
expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
|
||||
expect(qhm.treeDataProvider.allHistory).toEqual([
|
||||
rawQueryHistory[1],
|
||||
rawQueryHistory[0],
|
||||
|
||||
@@ -95,8 +95,8 @@ describe("test-adapter", () => {
|
||||
const request = new TestRunRequest([rootItem]);
|
||||
await testManager.run(request, new CancellationTokenSource().token);
|
||||
|
||||
expect(enqueuedSpy).toBeCalledTimes(3);
|
||||
expect(passedSpy).toBeCalledTimes(1);
|
||||
expect(enqueuedSpy).toHaveBeenCalledTimes(3);
|
||||
expect(passedSpy).toHaveBeenCalledTimes(1);
|
||||
expect(passedSpy).toHaveBeenCalledWith(childItems[0], 3000);
|
||||
expect(erroredSpy).toHaveBeenCalledTimes(1);
|
||||
expect(erroredSpy).toHaveBeenCalledWith(
|
||||
@@ -121,7 +121,7 @@ describe("test-adapter", () => {
|
||||
],
|
||||
11000,
|
||||
);
|
||||
expect(failedSpy).toBeCalledTimes(1);
|
||||
expect(endSpy).toBeCalledTimes(1);
|
||||
expect(failedSpy).toHaveBeenCalledTimes(1);
|
||||
expect(endSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -94,7 +94,7 @@ describe("test-runner", () => {
|
||||
eventHandlerSpy,
|
||||
);
|
||||
|
||||
expect(eventHandlerSpy).toBeCalledTimes(3);
|
||||
expect(eventHandlerSpy).toHaveBeenCalledTimes(3);
|
||||
|
||||
expect(eventHandlerSpy).toHaveBeenNthCalledWith(1, {
|
||||
test: mockTestsInfo.dPath,
|
||||
@@ -160,23 +160,23 @@ describe("test-runner", () => {
|
||||
setCurrentDatabaseItemSpy.mock.invocationCallOrder[0],
|
||||
).toBeGreaterThan(openDatabaseSpy.mock.invocationCallOrder[0]);
|
||||
|
||||
expect(removeDatabaseItemSpy).toBeCalledTimes(1);
|
||||
expect(removeDatabaseItemSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeDatabaseItemSpy).toHaveBeenCalledWith(preTestDatabaseItem);
|
||||
|
||||
expect(openDatabaseSpy).toBeCalledTimes(1);
|
||||
expect(openDatabaseSpy).toHaveBeenCalledTimes(1);
|
||||
expect(openDatabaseSpy).toHaveBeenCalledWith(
|
||||
preTestDatabaseItem.databaseUri,
|
||||
preTestDatabaseItem.origin,
|
||||
false,
|
||||
);
|
||||
|
||||
expect(renameDatabaseItemSpy).toBeCalledTimes(1);
|
||||
expect(renameDatabaseItemSpy).toHaveBeenCalledTimes(1);
|
||||
expect(renameDatabaseItemSpy).toHaveBeenCalledWith(
|
||||
postTestDatabaseItem,
|
||||
preTestDatabaseItem.name,
|
||||
);
|
||||
|
||||
expect(setCurrentDatabaseItemSpy).toBeCalledTimes(1);
|
||||
expect(setCurrentDatabaseItemSpy).toHaveBeenCalledTimes(1);
|
||||
expect(setCurrentDatabaseItemSpy).toHaveBeenCalledWith(
|
||||
postTestDatabaseItem,
|
||||
true,
|
||||
|
||||
@@ -152,11 +152,11 @@ describe("telemetry reporting", () => {
|
||||
expect(telemetryListener._reporter).toBeDefined();
|
||||
expect(telemetryListener._reporter).not.toBe(firstReporter);
|
||||
|
||||
expect(disposeSpy).toBeCalledTimes(1);
|
||||
expect(disposeSpy).toHaveBeenCalledTimes(1);
|
||||
|
||||
// initializing a third time continues to dispose
|
||||
await telemetryListener.initialize();
|
||||
expect(disposeSpy).toBeCalledTimes(2);
|
||||
expect(disposeSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("should reinitialize reporter when extension setting changes", async () => {
|
||||
@@ -170,13 +170,13 @@ describe("telemetry reporting", () => {
|
||||
|
||||
expect(telemetryListener._reporter).toBeUndefined();
|
||||
|
||||
expect(disposeSpy).toBeCalledTimes(1);
|
||||
expect(disposeSpy).toHaveBeenCalledTimes(1);
|
||||
|
||||
// creates a new reporter, but does not dispose again
|
||||
await enableTelemetry("codeQL.telemetry", true);
|
||||
|
||||
expect(telemetryListener._reporter).toBeDefined();
|
||||
expect(disposeSpy).toBeCalledTimes(1);
|
||||
expect(disposeSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should set userOprIn to false when global setting changes", async () => {
|
||||
@@ -361,7 +361,7 @@ describe("telemetry reporting", () => {
|
||||
await wait(500);
|
||||
|
||||
// Dialog opened, user clicks "yes" and telemetry enabled
|
||||
expect(showInformationMessageSpy).toBeCalledTimes(1);
|
||||
expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
|
||||
expect(ENABLE_TELEMETRY.getValue()).toBe(true);
|
||||
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(true);
|
||||
});
|
||||
@@ -374,7 +374,7 @@ describe("telemetry reporting", () => {
|
||||
await telemetryListener.initialize();
|
||||
|
||||
// Dialog opened, user clicks "no" and telemetry disabled
|
||||
expect(showInformationMessageSpy).toBeCalledTimes(1);
|
||||
expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
|
||||
expect(ENABLE_TELEMETRY.getValue()).toBe(false);
|
||||
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(true);
|
||||
});
|
||||
@@ -387,7 +387,7 @@ describe("telemetry reporting", () => {
|
||||
await enableTelemetry("codeQL.telemetry", false);
|
||||
|
||||
// Dialog opened, and user closes without interacting with it
|
||||
expect(showInformationMessageSpy).toBeCalledTimes(1);
|
||||
expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
|
||||
expect(ENABLE_TELEMETRY.getValue()).toBe(false);
|
||||
// dialog was canceled, so should not have marked as viewed
|
||||
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
|
||||
// Telemetry state should not have changed
|
||||
expect(showInformationMessageSpy).toBeCalledTimes(1);
|
||||
expect(showInformationMessageSpy).toHaveBeenCalledTimes(1);
|
||||
expect(ENABLE_TELEMETRY.getValue()).toBe(true);
|
||||
// dialog was canceled, so should not have marked as viewed
|
||||
expect(ctx.globalState.get("telemetry-request-viewed")).toBe(false);
|
||||
@@ -447,7 +447,7 @@ describe("telemetry reporting", () => {
|
||||
|
||||
// now, we should have to click through the telemetry requestor again
|
||||
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 () => {
|
||||
|
||||
Reference in New Issue
Block a user