Skip to content

Commit abc71b5

Browse files
committed
Replace toBeCalledWith
1 parent fed110f commit abc71b5

14 files changed

Lines changed: 56 additions & 54 deletions

File tree

extensions/ql-vscode/test/common/logging/output-channel-logger.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ describe("OutputChannelLogger tests", function () {
5454

5555
it("should log to the output channel", async () => {
5656
await logger.log("xxx");
57-
expect(mockOutputChannel.appendLine).toBeCalledWith("xxx");
58-
expect(mockOutputChannel.append).not.toBeCalledWith("xxx");
57+
expect(mockOutputChannel.appendLine).toHaveBeenCalledWith("xxx");
58+
expect(mockOutputChannel.append).not.toHaveBeenCalledWith("xxx");
5959

6060
await logger.log("yyy", { trailingNewline: false });
61-
expect(mockOutputChannel.appendLine).not.toBeCalledWith("yyy");
62-
expect(mockOutputChannel.append).toBeCalledWith("yyy");
61+
expect(mockOutputChannel.appendLine).not.toHaveBeenCalledWith("yyy");
62+
expect(mockOutputChannel.append).toHaveBeenCalledWith("yyy");
6363

6464
const hucairz = createSideLogger(logger, "hucairz");
6565
await hucairz.log("zzz");

extensions/ql-vscode/test/unit-tests/databases/config/db-config-store.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe("db config store", () => {
139139
const configStore = new DbConfigStore(app, false);
140140
await configStore.initialize();
141141

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

160-
expect(executeCommand).toBeCalledWith(
160+
expect(executeCommand).toHaveBeenCalledWith(
161161
"setContext",
162162
"codeQLVariantAnalysisRepositories.configError",
163163
false,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ describe("Variant Analysis Manager", () => {
610610
it("should return cancel if valid", async () => {
611611
await variantAnalysisManager.cancelVariantAnalysis(variantAnalysis.id);
612612

613-
expect(mockCancelVariantAnalysis).toBeCalledWith(
613+
expect(mockCancelVariantAnalysis).toHaveBeenCalledWith(
614614
app.credentials,
615615
variantAnalysis,
616616
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe("Variant Analysis Manager", () => {
105105
cancellationTokenSource.token,
106106
);
107107

108-
expect(executeCommandSpy).toBeCalledWith(
108+
expect(executeCommandSpy).toHaveBeenCalledWith(
109109
"codeQL.monitorNewVariantAnalysis",
110110
expect.objectContaining({
111111
id: mockApiResponse.id,
@@ -126,7 +126,7 @@ describe("Variant Analysis Manager", () => {
126126
cancellationTokenSource.token,
127127
);
128128

129-
expect(executeCommandSpy).toBeCalledWith(
129+
expect(executeCommandSpy).toHaveBeenCalledWith(
130130
"codeQL.monitorNewVariantAnalysis",
131131
expect.objectContaining({
132132
id: mockApiResponse.id,
@@ -147,7 +147,7 @@ describe("Variant Analysis Manager", () => {
147147
cancellationTokenSource.token,
148148
);
149149

150-
expect(executeCommandSpy).toBeCalledWith(
150+
expect(executeCommandSpy).toHaveBeenCalledWith(
151151
"codeQL.monitorNewVariantAnalysis",
152152
expect.objectContaining({
153153
id: mockApiResponse.id,
@@ -319,7 +319,7 @@ describe("Variant Analysis Manager", () => {
319319
);
320320

321321
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
322-
expect(executeCommandSpy).toBeCalledWith(
322+
expect(executeCommandSpy).toHaveBeenCalledWith(
323323
"codeQL.monitorNewVariantAnalysis",
324324
expect.objectContaining({
325325
query: expect.objectContaining({ filePath: fileUri.fsPath }),

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ describe("local databases", () => {
130130
await (databaseManager as any).addDatabaseItem(mockDbItem);
131131

132132
expect((databaseManager as any)._databaseItems).toEqual([mockDbItem]);
133-
expect(updateSpy).toBeCalledWith("databaseList", [
133+
expect(updateSpy).toHaveBeenCalledWith("databaseList", [
134134
{
135135
options: mockDbOptions(),
136136
uri: dbLocationUri(dir).toString(true),
137137
},
138138
]);
139-
expect(onDidChangeDatabaseItem).toBeCalledWith({
139+
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
140140
item: undefined,
141141
kind: DatabaseEventKind.Add,
142142
});
@@ -147,8 +147,8 @@ describe("local databases", () => {
147147
// now remove the item
148148
await databaseManager.removeDatabaseItem(mockDbItem);
149149
expect((databaseManager as any)._databaseItems).toEqual([]);
150-
expect(updateSpy).toBeCalledWith("databaseList", []);
151-
expect(onDidChangeDatabaseItem).toBeCalledWith({
150+
expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
151+
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
152152
item: undefined,
153153
kind: DatabaseEventKind.Remove,
154154
});
@@ -164,14 +164,14 @@ describe("local databases", () => {
164164
await databaseManager.renameDatabaseItem(mockDbItem, "new name");
165165

166166
expect(mockDbItem.name).toBe("new name");
167-
expect(updateSpy).toBeCalledWith("databaseList", [
167+
expect(updateSpy).toHaveBeenCalledWith("databaseList", [
168168
{
169169
options: { ...mockDbOptions(), displayName: "new name" },
170170
uri: dbLocationUri(dir).toString(true),
171171
},
172172
]);
173173

174-
expect(onDidChangeDatabaseItem).toBeCalledWith({
174+
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
175175
item: undefined,
176176
kind: DatabaseEventKind.Rename,
177177
});
@@ -187,7 +187,7 @@ describe("local databases", () => {
187187
await (databaseManager as any).addDatabaseItem(mockDbItem);
188188

189189
expect(databaseManager.databaseItems).toEqual([mockDbItem]);
190-
expect(updateSpy).toBeCalledWith("databaseList", [
190+
expect(updateSpy).toHaveBeenCalledWith("databaseList", [
191191
{
192192
uri: dbLocationUri(dir).toString(true),
193193
options: mockDbOptions(),
@@ -198,7 +198,7 @@ describe("local databases", () => {
198198
item: undefined,
199199
kind: DatabaseEventKind.Add,
200200
};
201-
expect(onDidChangeDatabaseItem).toBeCalledWith(mockEvent);
201+
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith(mockEvent);
202202
});
203203

204204
it("should add a database item source archive", async () => {
@@ -234,9 +234,9 @@ describe("local databases", () => {
234234
await databaseManager.removeDatabaseItem(mockDbItem);
235235

236236
expect(databaseManager.databaseItems).toEqual([]);
237-
expect(updateSpy).toBeCalledWith("databaseList", []);
237+
expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
238238
// should remove the folder
239-
expect(workspace.updateWorkspaceFolders).toBeCalledWith(0, 1);
239+
expect(workspace.updateWorkspaceFolders).toHaveBeenCalledWith(0, 1);
240240

241241
// should also delete the db contents
242242
await expect(pathExists(mockDbItem.databaseUri.fsPath)).resolves.toBe(
@@ -262,9 +262,9 @@ describe("local databases", () => {
262262
await databaseManager.removeDatabaseItem(mockDbItem);
263263

264264
expect(databaseManager.databaseItems).toEqual([]);
265-
expect(updateSpy).toBeCalledWith("databaseList", []);
265+
expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
266266
// should remove the folder
267-
expect(workspace.updateWorkspaceFolders).toBeCalledWith(0, 1);
267+
expect(workspace.updateWorkspaceFolders).toHaveBeenCalledWith(0, 1);
268268

269269
// should NOT delete the db contents
270270
await expect(pathExists(mockDbItem.databaseUri.fsPath)).resolves.toBe(
@@ -279,12 +279,12 @@ describe("local databases", () => {
279279

280280
await (databaseManager as any).addDatabaseItem(mockDbItem);
281281
// Should have registered this database
282-
expect(registerSpy).toBeCalledWith(mockDbItem);
282+
expect(registerSpy).toHaveBeenCalledWith(mockDbItem);
283283

284284
await databaseManager.removeDatabaseItem(mockDbItem);
285285

286286
// Should have deregistered this database
287-
expect(deregisterSpy).toBeCalledWith(mockDbItem);
287+
expect(deregisterSpy).toHaveBeenCalledWith(mockDbItem);
288288
});
289289
});
290290

extensions/ql-vscode/test/vscode-tests/minimal-workspace/queries-panel/query-tree-data-provider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe("QueryTreeDataProvider", () => {
3939
);
4040

4141
expect(dataProvider.getChildren()).toEqual([]);
42-
expect(executeCommand).toBeCalledWith(
42+
expect(executeCommand).toHaveBeenCalledWith(
4343
"setContext",
4444
"codeQL.noQueries",
4545
true,
@@ -118,7 +118,7 @@ describe("QueryTreeDataProvider", () => {
118118
onDidChangeQueriesEmitter.fire();
119119

120120
expect(dataProvider.getChildren().length).toEqual(2);
121-
expect(executeCommand).toBeCalledWith(
121+
expect(executeCommand).toHaveBeenCalledWith(
122122
"setContext",
123123
"codeQL.noQueries",
124124
false,

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

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

2020
expect(progressSpy).toBeCalledTimes(3);
21-
expect(progressSpy).toBeCalledWith({
21+
expect(progressSpy).toHaveBeenCalledWith({
2222
step: 0,
2323
maxStep: max,
2424
message: "My prefix [0.0 MB of 4.0 MB]",
2525
});
26-
expect(progressSpy).toBeCalledWith({
26+
expect(progressSpy).toHaveBeenCalledWith({
2727
step: firstStep,
2828
maxStep: max,
2929
message: "My prefix [1.6 MB of 4.0 MB]",
3030
});
31-
expect(progressSpy).toBeCalledWith({
31+
expect(progressSpy).toHaveBeenCalledWith({
3232
step: firstStep + secondStep,
3333
maxStep: max,
3434
message: "My prefix [3.6 MB of 4.0 MB]",
@@ -51,7 +51,7 @@ describe("helpers", () => {
5151
expect(mockReadable.on).not.toHaveBeenCalled();
5252

5353
expect(progressSpy).toBeCalledTimes(1);
54-
expect(progressSpy).toBeCalledWith({
54+
expect(progressSpy).toHaveBeenCalledWith({
5555
step: 1,
5656
maxStep: 2,
5757
message: "My prefix (Size unknown)",

extensions/ql-vscode/test/vscode-tests/no-workspace/language-support/ast-viewer/ast-builder.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ describe("AstBuilder", () => {
5555

5656
const bqrsPath = path.normalize("/a/b/c/results.bqrs");
5757
const options = { entities: ["id", "url", "string"] };
58-
expect(mockCli.bqrsDecode).toBeCalledWith(bqrsPath, "nodes", options);
59-
expect(mockCli.bqrsDecode).toBeCalledWith(bqrsPath, "edges", options);
60-
expect(mockCli.bqrsDecode).toBeCalledWith(
58+
expect(mockCli.bqrsDecode).toHaveBeenCalledWith(bqrsPath, "nodes", options);
59+
expect(mockCli.bqrsDecode).toHaveBeenCalledWith(bqrsPath, "edges", options);
60+
expect(mockCli.bqrsDecode).toHaveBeenCalledWith(
6161
bqrsPath,
6262
"graphProperties",
6363
options,

extensions/ql-vscode/test/vscode-tests/no-workspace/language-support/ast-viewer/ast-viewer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("AstViewer", () => {
8686
const mockEvent = createMockEvent(selectionRange, fileUri);
8787
(viewer as any).updateTreeSelection(mockEvent);
8888
if (expectedSelection) {
89-
expect(revealMock).toBeCalledWith(expectedSelection);
89+
expect(revealMock).toHaveBeenCalledWith(expectedSelection);
9090
} else {
9191
expect(revealMock).not.toHaveBeenCalled();
9292
}

extensions/ql-vscode/test/vscode-tests/no-workspace/local-queries/query-resolver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("qlpackOfDatabase", () => {
4949
dbschemePack: "my-qlpack",
5050
dbschemePackIsLibraryPack: false,
5151
});
52-
expect(getPrimaryDbschemeSpy).toBeCalledWith("/path/to/database");
52+
expect(getPrimaryDbschemeSpy).toHaveBeenCalledWith("/path/to/database");
5353
});
5454
});
5555

0 commit comments

Comments
 (0)