Skip to content

Commit 70ce93c

Browse files
committed
Replace toBeCalledTimes
1 parent abc71b5 commit 70ce93c

File tree

12 files changed

+58
-58
lines changed

12 files changed

+58
-58
lines changed

extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-manager.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe("Variant Analysis Manager", () => {
9696

9797
await variantAnalysisManager.rehydrateVariantAnalysis(variantAnalysis);
9898

99-
expect(stub).toBeCalledTimes(1);
99+
expect(stub).toHaveBeenCalledTimes(1);
100100
});
101101
});
102102

@@ -423,7 +423,7 @@ describe("Variant Analysis Manager", () => {
423423
);
424424

425425
expect(variantAnalysisManager.downloadsQueueSize()).toBe(0);
426-
expect(getResultsSpy).toBeCalledTimes(3);
426+
expect(getResultsSpy).toHaveBeenCalledTimes(3);
427427
});
428428
});
429429

@@ -451,7 +451,7 @@ describe("Variant Analysis Manager", () => {
451451

452452
await variantAnalysisManager.removeVariantAnalysis(dummyVariantAnalysis);
453453

454-
expect(removeAnalysisResultsStub).toBeCalledTimes(1);
454+
expect(removeAnalysisResultsStub).toHaveBeenCalledTimes(1);
455455
expect(variantAnalysisManager.variantAnalysesSize).toBe(0);
456456

457457
await expect(
@@ -722,7 +722,7 @@ describe("Variant Analysis Manager", () => {
722722
variantAnalysis.id,
723723
);
724724

725-
expect(writeTextStub).toBeCalledTimes(1);
725+
expect(writeTextStub).toHaveBeenCalledTimes(1);
726726
});
727727

728728
it("should be valid JSON when put in object", async () => {

extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-monitor.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe("Variant Analysis Monitor", () => {
121121
);
122122
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
123123

124-
expect(mockEecuteCommand).toBeCalledTimes(succeededRepos.length);
124+
expect(mockEecuteCommand).toHaveBeenCalledTimes(succeededRepos.length);
125125

126126
succeededRepos.forEach((succeededRepo, index) => {
127127
expect(mockEecuteCommand).toHaveBeenNthCalledWith(
@@ -197,8 +197,8 @@ describe("Variant Analysis Monitor", () => {
197197
it("should trigger a download extension command for each repo", async () => {
198198
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
199199

200-
expect(mockGetVariantAnalysis).toBeCalledTimes(4);
201-
expect(mockEecuteCommand).toBeCalledTimes(5);
200+
expect(mockGetVariantAnalysis).toHaveBeenCalledTimes(4);
201+
expect(mockEecuteCommand).toHaveBeenCalledTimes(5);
202202
});
203203
});
204204

@@ -261,7 +261,7 @@ describe("Variant Analysis Monitor", () => {
261261
it("should only trigger the warning once per error", async () => {
262262
await variantAnalysisMonitor.monitorVariantAnalysis(variantAnalysis);
263263

264-
expect(logger.showWarningMessage).toBeCalledTimes(4);
264+
expect(logger.showWarningMessage).toHaveBeenCalledTimes(4);
265265
expect(logger.showWarningMessage).toHaveBeenNthCalledWith(
266266
1,
267267
expect.stringMatching(/No internet connection/),

extensions/ql-vscode/test/vscode-tests/cli-integration/variant-analysis/variant-analysis-manager.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ describe("Variant Analysis Manager", () => {
113113
}),
114114
);
115115

116-
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
117-
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
116+
expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
117+
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
118118
});
119119

120120
it("should run a remote query that is not part of a qlpack", async () => {
@@ -134,8 +134,8 @@ describe("Variant Analysis Manager", () => {
134134
}),
135135
);
136136

137-
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
138-
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
137+
expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
138+
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
139139
});
140140

141141
it("should run a remote query that is nested inside a qlpack", async () => {
@@ -155,8 +155,8 @@ describe("Variant Analysis Manager", () => {
155155
}),
156156
);
157157

158-
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
159-
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
158+
expect(mockGetRepositoryFromNwo).toHaveBeenCalledTimes(1);
159+
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
160160
});
161161

162162
it("should cancel a run before uploading", async () => {
@@ -318,7 +318,7 @@ describe("Variant Analysis Manager", () => {
318318
cancellationTokenSource.token,
319319
);
320320

321-
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
321+
expect(mockSubmitVariantAnalysis).toHaveBeenCalledTimes(1);
322322
expect(executeCommandSpy).toHaveBeenCalledWith(
323323
"codeQL.monitorNewVariantAnalysis",
324324
expect.objectContaining({

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ describe("local databases", () => {
618618
it("should offer the user to set up a skeleton QL pack", async () => {
619619
await (databaseManager as any).createSkeletonPacks(mockDbItem);
620620

621-
expect(showNeverAskAgainDialogSpy).toBeCalledTimes(1);
621+
expect(showNeverAskAgainDialogSpy).toHaveBeenCalledTimes(1);
622622
});
623623

624624
it("should return early if the user refuses help", async () => {
@@ -742,7 +742,7 @@ describe("local databases", () => {
742742
mockDbItem.origin,
743743
);
744744

745-
expect(resolveDatabaseContentsSpy).toBeCalledTimes(2);
745+
expect(resolveDatabaseContentsSpy).toHaveBeenCalledTimes(2);
746746
});
747747

748748
it("should set the database as the currently selected one", async () => {
@@ -751,7 +751,7 @@ describe("local databases", () => {
751751
mockDbItem.origin,
752752
);
753753

754-
expect(setCurrentDatabaseItemSpy).toBeCalledTimes(1);
754+
expect(setCurrentDatabaseItemSpy).toHaveBeenCalledTimes(1);
755755
});
756756

757757
it("should not add database source archive folder when `codeQL.addingDatabases.addDatabaseSourceToWorkspace` is `false`", async () => {
@@ -762,7 +762,7 @@ describe("local databases", () => {
762762
mockDbItem.origin,
763763
);
764764

765-
expect(addDatabaseSourceArchiveFolderSpy).toBeCalledTimes(0);
765+
expect(addDatabaseSourceArchiveFolderSpy).toHaveBeenCalledTimes(0);
766766
});
767767

768768
it("should add database source archive folder when `codeQL.addingDatabases.addDatabaseSourceToWorkspace` is `true`", async () => {
@@ -773,7 +773,7 @@ describe("local databases", () => {
773773
mockDbItem.origin,
774774
);
775775

776-
expect(addDatabaseSourceArchiveFolderSpy).toBeCalledTimes(1);
776+
expect(addDatabaseSourceArchiveFolderSpy).toHaveBeenCalledTimes(1);
777777
});
778778

779779
describe("when codeQL.codespacesTemplate is set to true", () => {
@@ -793,7 +793,7 @@ describe("local databases", () => {
793793
{ isTutorialDatabase },
794794
);
795795

796-
expect(createSkeletonPacksSpy).toBeCalledTimes(0);
796+
expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(0);
797797
});
798798
});
799799

@@ -806,7 +806,7 @@ describe("local databases", () => {
806806
mockDbItem.origin,
807807
);
808808

809-
expect(createSkeletonPacksSpy).toBeCalledTimes(1);
809+
expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(1);
810810
});
811811
});
812812
});
@@ -819,7 +819,7 @@ describe("local databases", () => {
819819
mockDbItem.databaseUri,
820820
mockDbItem.origin,
821821
);
822-
expect(createSkeletonPacksSpy).toBeCalledTimes(0);
822+
expect(createSkeletonPacksSpy).toHaveBeenCalledTimes(0);
823823
});
824824
});
825825
});

extensions/ql-vscode/test/vscode-tests/no-workspace/codeql-cli/distribution.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ describe("Launcher path", () => {
114114
expect(result).toBe(pathToCmd);
115115

116116
// no warning or error message
117-
expect(warnSpy).toBeCalledTimes(0);
118-
expect(errorSpy).toBeCalledTimes(0);
117+
expect(warnSpy).toHaveBeenCalledTimes(0);
118+
expect(errorSpy).toHaveBeenCalledTimes(0);
119119
});
120120

121121
it("should warn when deprecated launcher is used, and new launcher is available", async () => {
@@ -132,8 +132,8 @@ describe("Launcher path", () => {
132132
expect(result).toBe(pathToCmd);
133133

134134
// has warning message
135-
expect(warnSpy).toBeCalledTimes(1);
136-
expect(errorSpy).toBeCalledTimes(0);
135+
expect(warnSpy).toHaveBeenCalledTimes(1);
136+
expect(errorSpy).toHaveBeenCalledTimes(0);
137137
});
138138

139139
it("should warn when launcher path is incorrect", async () => {
@@ -147,7 +147,7 @@ describe("Launcher path", () => {
147147
expect(result).toBeUndefined();
148148

149149
// no error message
150-
expect(warnSpy).toBeCalledTimes(0);
151-
expect(errorSpy).toBeCalledTimes(1);
150+
expect(warnSpy).toHaveBeenCalledTimes(0);
151+
expect(errorSpy).toHaveBeenCalledTimes(1);
152152
});
153153
});

extensions/ql-vscode/test/vscode-tests/no-workspace/common/vscode/progress.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe("helpers", () => {
1717
listener({ length: firstStep });
1818
listener({ length: secondStep });
1919

20-
expect(progressSpy).toBeCalledTimes(3);
20+
expect(progressSpy).toHaveBeenCalledTimes(3);
2121
expect(progressSpy).toHaveBeenCalledWith({
2222
step: 0,
2323
maxStep: max,
@@ -50,7 +50,7 @@ describe("helpers", () => {
5050
// There are no listeners registered to this readable
5151
expect(mockReadable.on).not.toHaveBeenCalled();
5252

53-
expect(progressSpy).toBeCalledTimes(1);
53+
expect(progressSpy).toHaveBeenCalledTimes(1);
5454
expect(progressSpy).toHaveBeenCalledWith({
5555
step: 1,
5656
maxStep: 2,

extensions/ql-vscode/test/vscode-tests/no-workspace/databases/database-fetcher.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe("database-fetcher", () => {
145145
await expect(
146146
convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy),
147147
).rejects.toThrow(/Unable to get database/);
148-
expect(progressSpy).toBeCalledTimes(0);
148+
expect(progressSpy).toHaveBeenCalledTimes(0);
149149
});
150150

151151
// User has access to the repository, but there are no databases for any language.
@@ -159,7 +159,7 @@ describe("database-fetcher", () => {
159159
await expect(
160160
convertGithubNwoToDatabaseUrl(githubRepo, octokit, progressSpy),
161161
).rejects.toThrow(/Unable to get database/);
162-
expect(progressSpy).toBeCalledTimes(1);
162+
expect(progressSpy).toHaveBeenCalledTimes(1);
163163
});
164164

165165
describe("when language is already provided", () => {

extensions/ql-vscode/test/vscode-tests/no-workspace/query-history/query-history-manager.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ describe("QueryHistoryManager", () => {
594594
const cancelSpy = jest.spyOn(inProgress1, "cancel");
595595

596596
await queryHistoryManager.handleCancel([inProgress1]);
597-
expect(cancelSpy).toBeCalledTimes(1);
597+
expect(cancelSpy).toHaveBeenCalledTimes(1);
598598
});
599599

600600
it("should cancel multiple local queries", async () => {
@@ -650,7 +650,7 @@ describe("QueryHistoryManager", () => {
650650
const cancelSpy = jest.spyOn(completed, "cancel");
651651

652652
await queryHistoryManager.handleCancel([completed]);
653-
expect(cancelSpy).not.toBeCalledTimes(1);
653+
expect(cancelSpy).not.toHaveBeenCalledTimes(1);
654654
});
655655

656656
it("should not cancel multiple local queries", async () => {
@@ -664,8 +664,8 @@ describe("QueryHistoryManager", () => {
664664
const cancelSpy2 = jest.spyOn(failed, "cancel");
665665

666666
await queryHistoryManager.handleCancel([completed, failed]);
667-
expect(cancelSpy).not.toBeCalledTimes(1);
668-
expect(cancelSpy2).not.toBeCalledTimes(1);
667+
expect(cancelSpy).not.toHaveBeenCalledTimes(1);
668+
expect(cancelSpy2).not.toHaveBeenCalledTimes(1);
669669
});
670670

671671
it("should not cancel a single variant analysis", async () => {

extensions/ql-vscode/test/vscode-tests/no-workspace/query-history/variant-analysis-history.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe("Variant Analyses and QueryHistoryManager", () => {
119119
it("should read query history that has variant analysis history items", async () => {
120120
await qhm.readQueryHistory();
121121

122-
expect(rehydrateVariantAnalysisStub).toBeCalledTimes(2);
122+
expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
123123
expect(rehydrateVariantAnalysisStub).toHaveBeenNthCalledWith(
124124
1,
125125
rawQueryHistory[0].variantAnalysis,
@@ -142,8 +142,8 @@ describe("Variant Analyses and QueryHistoryManager", () => {
142142

143143
// Add it back to the history
144144
qhm.addQuery(rawQueryHistory[0]);
145-
expect(removeVariantAnalysisStub).toBeCalledTimes(1);
146-
expect(rehydrateVariantAnalysisStub).toBeCalledTimes(2);
145+
expect(removeVariantAnalysisStub).toHaveBeenCalledTimes(1);
146+
expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
147147
expect(qhm.treeDataProvider.allHistory).toEqual([
148148
rawQueryHistory[1],
149149
rawQueryHistory[0],

extensions/ql-vscode/test/vscode-tests/no-workspace/query-testing/test-adapter.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ describe("test-adapter", () => {
9595
const request = new TestRunRequest([rootItem]);
9696
await testManager.run(request, new CancellationTokenSource().token);
9797

98-
expect(enqueuedSpy).toBeCalledTimes(3);
99-
expect(passedSpy).toBeCalledTimes(1);
98+
expect(enqueuedSpy).toHaveBeenCalledTimes(3);
99+
expect(passedSpy).toHaveBeenCalledTimes(1);
100100
expect(passedSpy).toHaveBeenCalledWith(childItems[0], 3000);
101101
expect(erroredSpy).toHaveBeenCalledTimes(1);
102102
expect(erroredSpy).toHaveBeenCalledWith(
@@ -121,7 +121,7 @@ describe("test-adapter", () => {
121121
],
122122
11000,
123123
);
124-
expect(failedSpy).toBeCalledTimes(1);
125-
expect(endSpy).toBeCalledTimes(1);
124+
expect(failedSpy).toHaveBeenCalledTimes(1);
125+
expect(endSpy).toHaveBeenCalledTimes(1);
126126
});
127127
});

0 commit comments

Comments
 (0)