Replace toBeCalled
This commit is contained in:
@@ -34,9 +34,9 @@ describe("DisposableObject and DisposeHandler", () => {
|
||||
|
||||
disposableObject.dispose();
|
||||
|
||||
expect(disposable1.dispose).toBeCalled();
|
||||
expect(disposable2.dispose).toBeCalled();
|
||||
expect(disposable3.dispose).toBeCalled();
|
||||
expect(disposable1.dispose).toHaveBeenCalled();
|
||||
expect(disposable2.dispose).toHaveBeenCalled();
|
||||
expect(disposable3.dispose).toHaveBeenCalled();
|
||||
|
||||
// pushed items must be called in reverse order
|
||||
expect(disposable2.dispose.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
@@ -51,30 +51,30 @@ describe("DisposableObject and DisposeHandler", () => {
|
||||
|
||||
disposableObject.dispose();
|
||||
|
||||
expect(disposable1.dispose).not.toBeCalled();
|
||||
expect(disposable2.dispose).not.toBeCalled();
|
||||
expect(disposable3.dispose).not.toBeCalled();
|
||||
expect(disposable1.dispose).not.toHaveBeenCalled();
|
||||
expect(disposable2.dispose).not.toHaveBeenCalled();
|
||||
expect(disposable3.dispose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should dispose and stop tracking objects", () => {
|
||||
disposableObject.track(disposable1);
|
||||
disposableObject.disposeAndStopTracking(disposable1);
|
||||
|
||||
expect(disposable1.dispose).toBeCalled();
|
||||
expect(disposable1.dispose).toHaveBeenCalled();
|
||||
disposable1.dispose.mockClear();
|
||||
|
||||
disposableObject.dispose();
|
||||
expect(disposable1.dispose).not.toBeCalled();
|
||||
expect(disposable1.dispose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should avoid disposing an object that is not tracked", () => {
|
||||
disposableObject.push(disposable1);
|
||||
disposableObject.disposeAndStopTracking(disposable1);
|
||||
|
||||
expect(disposable1.dispose).not.toBeCalled();
|
||||
expect(disposable1.dispose).not.toHaveBeenCalled();
|
||||
|
||||
disposableObject.dispose();
|
||||
expect(disposable1.dispose).toBeCalled();
|
||||
expect(disposable1.dispose).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("ahould use a dispose handler", () => {
|
||||
@@ -91,10 +91,10 @@ describe("DisposableObject and DisposeHandler", () => {
|
||||
|
||||
disposableObject.dispose(handler);
|
||||
|
||||
expect(disposable1.dispose).toBeCalled();
|
||||
expect(disposable2.dispose).not.toBeCalled();
|
||||
expect(disposable3.dispose).toBeCalled();
|
||||
expect(disposable4.dispose).not.toBeCalled();
|
||||
expect(disposable1.dispose).toHaveBeenCalled();
|
||||
expect(disposable2.dispose).not.toHaveBeenCalled();
|
||||
expect(disposable3.dispose).toHaveBeenCalled();
|
||||
expect(disposable4.dispose).not.toHaveBeenCalled();
|
||||
|
||||
// now that disposableObject has been disposed, subsequent disposals are
|
||||
// no-ops
|
||||
@@ -105,10 +105,10 @@ describe("DisposableObject and DisposeHandler", () => {
|
||||
|
||||
disposableObject.dispose();
|
||||
|
||||
expect(disposable1.dispose).not.toBeCalled();
|
||||
expect(disposable2.dispose).not.toBeCalled();
|
||||
expect(disposable3.dispose).not.toBeCalled();
|
||||
expect(disposable4.dispose).not.toBeCalled();
|
||||
expect(disposable1.dispose).not.toHaveBeenCalled();
|
||||
expect(disposable2.dispose).not.toHaveBeenCalled();
|
||||
expect(disposable3.dispose).not.toHaveBeenCalled();
|
||||
expect(disposable4.dispose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
class MyDisposableObject extends DisposableObject {
|
||||
|
||||
@@ -656,7 +656,7 @@ describe("Variant Analysis Manager", () => {
|
||||
variantAnalysis.id,
|
||||
);
|
||||
|
||||
expect(writeTextStub).not.toBeCalled();
|
||||
expect(writeTextStub).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -682,7 +682,7 @@ describe("Variant Analysis Manager", () => {
|
||||
variantAnalysis.id,
|
||||
);
|
||||
|
||||
expect(writeTextStub).not.toBeCalled();
|
||||
expect(writeTextStub).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ describe("Variant Analysis Monitor", () => {
|
||||
it("should not try to download any repos", async () => {
|
||||
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
|
||||
|
||||
expect(mockEecuteCommand).not.toBeCalled();
|
||||
expect(mockEecuteCommand).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@ describe("local databases", () => {
|
||||
|
||||
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 () => {
|
||||
@@ -638,7 +638,7 @@ describe("local databases", () => {
|
||||
|
||||
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 () => {
|
||||
@@ -652,14 +652,14 @@ describe("local databases", () => {
|
||||
|
||||
await (databaseManager as any).createSkeletonPacks(mockDbItem);
|
||||
|
||||
expect(generateSpy).not.toBeCalled();
|
||||
expect(generateSpy).not.toHaveBeenCalled();
|
||||
expect(setAutogenerateQlPacksSpy).toHaveBeenCalledWith("never");
|
||||
});
|
||||
|
||||
it("should create the skeleton QL pack for the user", async () => {
|
||||
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);
|
||||
|
||||
expect(generateSpy).not.toBeCalled();
|
||||
expect(generateSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ describe("tryOpenExternalFile", () => {
|
||||
Uri.file("xxx"),
|
||||
expect.anything(),
|
||||
);
|
||||
expect(executeCommand).not.toBeCalled();
|
||||
expect(executeCommand).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
[
|
||||
@@ -61,8 +61,8 @@ describe("tryOpenExternalFile", () => {
|
||||
const uri = Uri.file("xxx");
|
||||
expect(showTextDocumentSpy).toHaveBeenCalledTimes(1);
|
||||
expect(showTextDocumentSpy).toHaveBeenCalledWith(uri, expect.anything());
|
||||
expect(showInformationMessageSpy).toBeCalled();
|
||||
expect(executeCommand).not.toBeCalled();
|
||||
expect(showInformationMessageSpy).toHaveBeenCalled();
|
||||
expect(executeCommand).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ describe("helpers", () => {
|
||||
);
|
||||
|
||||
// There are no listeners registered to this readable
|
||||
expect(mockReadable.on).not.toBeCalled();
|
||||
expect(mockReadable.on).not.toHaveBeenCalled();
|
||||
|
||||
expect(progressSpy).toBeCalledTimes(1);
|
||||
expect(progressSpy).toBeCalledWith({
|
||||
|
||||
@@ -88,7 +88,7 @@ describe("AstViewer", () => {
|
||||
if (expectedSelection) {
|
||||
expect(revealMock).toBeCalledWith(expectedSelection);
|
||||
} else {
|
||||
expect(revealMock).not.toBeCalled();
|
||||
expect(revealMock).not.toHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -608,8 +608,8 @@ describe("QueryHistoryManager", () => {
|
||||
const cancelSpy2 = jest.spyOn(inProgress2, "cancel");
|
||||
|
||||
await queryHistoryManager.handleCancel([inProgress1, inProgress2]);
|
||||
expect(cancelSpy1).toBeCalled();
|
||||
expect(cancelSpy2).toBeCalled();
|
||||
expect(cancelSpy1).toHaveBeenCalled();
|
||||
expect(cancelSpy2).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should cancel a single variant analysis", async () => {
|
||||
@@ -708,7 +708,7 @@ describe("QueryHistoryManager", () => {
|
||||
const item = localQueryHistory[4];
|
||||
await queryHistoryManager.handleCopyRepoList(item);
|
||||
|
||||
expect(executeCommand).not.toBeCalled();
|
||||
expect(executeCommand).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should copy repo list for a single variant analysis", async () => {
|
||||
@@ -731,7 +731,7 @@ describe("QueryHistoryManager", () => {
|
||||
const item = localQueryHistory[4];
|
||||
await queryHistoryManager.handleExportResults(item);
|
||||
|
||||
expect(variantAnalysisManagerStub.exportResults).not.toBeCalled();
|
||||
expect(variantAnalysisManagerStub.exportResults).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should export results for a single variant analysis", async () => {
|
||||
@@ -801,7 +801,7 @@ describe("QueryHistoryManager", () => {
|
||||
queryHistoryManager as any
|
||||
).findOtherQueryToCompare(thisQuery, [thisQuery, 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 () => {
|
||||
@@ -850,7 +850,7 @@ describe("QueryHistoryManager", () => {
|
||||
await queryHistoryManager.handleCompareWith(localQueryHistory[0], [
|
||||
localQueryHistory[0],
|
||||
]);
|
||||
expect(doCompareCallback).not.toBeCalled();
|
||||
expect(doCompareCallback).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should throw an error when a query is not successful", async () => {
|
||||
|
||||
@@ -245,7 +245,7 @@ describe("query-results", () => {
|
||||
sourceInfo as SourceInfo,
|
||||
);
|
||||
// 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("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.
|
||||
expect(spy).not.toBeCalled();
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
},
|
||||
2 * 60 * 1000, // up to 2 minutes per test
|
||||
);
|
||||
@@ -336,7 +336,7 @@ describe("query-results", () => {
|
||||
sourceInfo as SourceInfo,
|
||||
);
|
||||
// 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("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.
|
||||
expect(spy).not.toBeCalled();
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
},
|
||||
2 * 60 * 1000, // up to 2 minutes per test
|
||||
);
|
||||
|
||||
@@ -162,7 +162,7 @@ describe("telemetry reporting", () => {
|
||||
it("should reinitialize reporter when extension setting changes", async () => {
|
||||
await telemetryListener.initialize();
|
||||
|
||||
expect(disposeSpy).not.toBeCalled();
|
||||
expect(disposeSpy).not.toHaveBeenCalled();
|
||||
expect(telemetryListener._reporter).toBeDefined();
|
||||
|
||||
// this disables the reporter
|
||||
@@ -205,7 +205,7 @@ describe("telemetry reporting", () => {
|
||||
},
|
||||
{ executionTime: 1234 },
|
||||
);
|
||||
expect(sendTelemetryErrorEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should send a command usage event with an error", async () => {
|
||||
@@ -227,7 +227,7 @@ describe("telemetry reporting", () => {
|
||||
},
|
||||
{ executionTime: 1234 },
|
||||
);
|
||||
expect(sendTelemetryErrorEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should send a command usage event with a cli version", async () => {
|
||||
@@ -250,7 +250,7 @@ describe("telemetry reporting", () => {
|
||||
},
|
||||
{ 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"
|
||||
sendTelemetryEventSpy.mockClear();
|
||||
@@ -272,7 +272,7 @@ describe("telemetry reporting", () => {
|
||||
},
|
||||
{ executionTime: 5678 },
|
||||
);
|
||||
expect(sendTelemetryErrorEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
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, new Error());
|
||||
|
||||
expect(sendTelemetryEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryErrorEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
|
||||
expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should send an event when telemetry is re-enabled", async () => {
|
||||
@@ -303,7 +303,7 @@ describe("telemetry reporting", () => {
|
||||
},
|
||||
{ executionTime: 1234 },
|
||||
);
|
||||
expect(sendTelemetryErrorEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should filter undesired properties from telemetry payload", async () => {
|
||||
@@ -426,7 +426,7 @@ describe("telemetry reporting", () => {
|
||||
await telemetryListener.initialize();
|
||||
|
||||
// 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.
|
||||
@@ -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 () => {
|
||||
@@ -482,7 +482,7 @@ describe("telemetry reporting", () => {
|
||||
},
|
||||
{},
|
||||
);
|
||||
expect(sendTelemetryErrorEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryErrorEventSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should send an error telementry event", async () => {
|
||||
@@ -490,7 +490,7 @@ describe("telemetry reporting", () => {
|
||||
|
||||
telemetryListener.sendError(redactableError`test`);
|
||||
|
||||
expect(sendTelemetryEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
|
||||
expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith(
|
||||
"error",
|
||||
{
|
||||
@@ -509,7 +509,7 @@ describe("telemetry reporting", () => {
|
||||
|
||||
telemetryListener.sendError(redactableError`test`);
|
||||
|
||||
expect(sendTelemetryEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
|
||||
expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith(
|
||||
"error",
|
||||
{
|
||||
@@ -529,7 +529,7 @@ describe("telemetry reporting", () => {
|
||||
redactableError`test message with secret information: ${42} and more ${"secret"} parts`,
|
||||
);
|
||||
|
||||
expect(sendTelemetryEventSpy).not.toBeCalled();
|
||||
expect(sendTelemetryEventSpy).not.toHaveBeenCalled();
|
||||
expect(sendTelemetryErrorEventSpy).toHaveBeenCalledWith(
|
||||
"error",
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user