Skip to content

Commit 558eb19

Browse files
committed
Remove unnecessary calls to mockReset
1 parent 31b64d2 commit 558eb19

8 files changed

Lines changed: 33 additions & 44 deletions

extensions/ql-vscode/src/vscode-tests/cli-integration/databases.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ describe("Databases", () => {
2929
jest.spyOn(window, "showInformationMessage").mockResolvedValue(undefined);
3030

3131
beforeEach(async () => {
32-
inputBoxStub.mockReset().mockResolvedValue(undefined);
33-
progressCallback.mockReset();
32+
inputBoxStub.mockResolvedValue(undefined);
3433

3534
const extension = await extensions
3635
.getExtension<CodeQLExtensionInterface | Record<string, never>>(

extensions/ql-vscode/src/vscode-tests/cli-integration/packaging.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ describe("Packaging commands", () => {
2929
);
3030

3131
beforeEach(async () => {
32-
progress.mockReset();
33-
quickPickSpy.mockReset().mockResolvedValue(undefined);
34-
inputBoxSpy.mockReset().mockResolvedValue(undefined);
35-
showAndLogErrorMessageSpy.mockReset().mockResolvedValue(undefined);
36-
showAndLogInformationMessageSpy.mockReset().mockResolvedValue(undefined);
32+
quickPickSpy.mockResolvedValue(undefined);
33+
inputBoxSpy.mockResolvedValue(undefined);
34+
showAndLogErrorMessageSpy.mockResolvedValue(undefined);
35+
showAndLogInformationMessageSpy.mockResolvedValue(undefined);
3736

3837
const extension = await extensions
3938
.getExtension<CodeQLExtensionInterface | Record<string, never>>(

extensions/ql-vscode/src/vscode-tests/cli-integration/queries.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ describeWithCodeQL()("Queries", () => {
6464
safeDel(qlFile);
6565
safeDel(qlpackFile);
6666

67-
progress.mockReset();
6867
token = {} as CancellationToken;
6968

7069
// Add a database, but make sure the database manager is empty first

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/remote-queries-manager.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ describe("Remote queries", () => {
8686

8787
cancellationTokenSource = new CancellationTokenSource();
8888

89-
progress.mockReset();
90-
9189
// Should not have asked for a language
9290
showQuickPickSpy
93-
.mockReset()
9491
.mockResolvedValueOnce({
9592
repositories: ["github/vscode-codeql"],
9693
} as unknown as QuickPickItem)
@@ -102,7 +99,7 @@ describe("Remote queries", () => {
10299
full_name: "github/vscode-codeql",
103100
private: false,
104101
};
105-
getRepositoryFromNwoStub.mockReset().mockResolvedValue(dummyRepository);
102+
getRepositoryFromNwoStub.mockResolvedValue(dummyRepository);
106103

107104
// always run in the vscode-codeql repo
108105
await setRemoteControllerRepo("github/vscode-codeql");
@@ -137,7 +134,7 @@ describe("Remote queries", () => {
137134
const executeCommandSpy = jest.spyOn(commands, "executeCommand");
138135

139136
beforeEach(() => {
140-
mockSubmitRemoteQueries.mockReset().mockResolvedValue({
137+
mockSubmitRemoteQueries.mockResolvedValue({
141138
workflow_run_id: 20,
142139
repositories_queried: ["octodemo/hello-world-1"],
143140
});

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ describe("Variant Analysis Manager", () => {
136136
beforeEach(async () => {
137137
writeFileStub.mockRestore();
138138

139-
progress.mockReset();
140139
// Should not have asked for a language
141140
showQuickPickSpy
142-
.mockReset()
141+
143142
.mockResolvedValueOnce({
144143
repositories: ["github/vscode-codeql"],
145144
} as unknown as QuickPickItem)
@@ -155,10 +154,10 @@ describe("Variant Analysis Manager", () => {
155154
full_name: "github/vscode-codeql",
156155
private: false,
157156
};
158-
mockGetRepositoryFromNwo.mockReset().mockResolvedValue(dummyRepository);
157+
mockGetRepositoryFromNwo.mockResolvedValue(dummyRepository);
159158

160159
mockApiResponse = createMockApiResponse("in_progress");
161-
mockSubmitVariantAnalysis.mockReset().mockResolvedValue(mockApiResponse);
160+
mockSubmitVariantAnalysis.mockResolvedValue(mockApiResponse);
162161

163162
// always run in the vscode-codeql repo
164163
await setRemoteControllerRepo("github/vscode-codeql");
@@ -266,7 +265,7 @@ describe("Variant Analysis Manager", () => {
266265
describe("when the directory does not exist", () => {
267266
beforeEach(() => {
268267
const originalFs = jest.requireActual<typeof fs>("fs-extras");
269-
pathExistsStub.mockReset().mockImplementation((...args) => {
268+
pathExistsStub.mockImplementation((...args) => {
270269
if (
271270
args[0] === path.join(storagePath, variantAnalysis.id.toString())
272271
) {
@@ -292,7 +291,7 @@ describe("Variant Analysis Manager", () => {
292291
describe("when the directory exists", () => {
293292
beforeEach(() => {
294293
const originalFs = jest.requireActual<typeof fs>("fs-extras");
295-
pathExistsStub.mockReset().mockImplementation((...args) => {
294+
pathExistsStub.mockImplementation((...args) => {
296295
if (
297296
args[0] === path.join(storagePath, variantAnalysis.id.toString())
298297
) {
@@ -443,8 +442,8 @@ describe("Variant Analysis Manager", () => {
443442
);
444443
arrayBuffer = fs.readFileSync(sourceFilePath).buffer;
445444

446-
getVariantAnalysisRepoStub.mockReset();
447-
getVariantAnalysisRepoResultStub.mockReset();
445+
getVariantAnalysisRepoStub;
446+
getVariantAnalysisRepoResultStub;
448447
});
449448

450449
describe("when the artifact_url is missing", () => {
@@ -658,7 +657,7 @@ describe("Variant Analysis Manager", () => {
658657
// the methods are called.
659658

660659
const originalFs = jest.requireActual<typeof fs>("fs-extras");
661-
pathExistsStub.mockReset().mockImplementation((...args) => {
660+
pathExistsStub.mockImplementation((...args) => {
662661
if (
663662
args[0] === path.join(storagePath, variantAnalysis.id.toString())
664663
) {
@@ -774,8 +773,8 @@ describe("Variant Analysis Manager", () => {
774773

775774
beforeEach(async () => {
776775
dummyVariantAnalysis = createMockVariantAnalysis({});
777-
removeAnalysisResultsStub.mockReset().mockReturnValue(undefined);
778-
removeStorageStub.mockReset().mockReturnValue(undefined);
776+
removeAnalysisResultsStub.mockReturnValue(undefined);
777+
removeStorageStub.mockReturnValue(undefined);
779778
});
780779

781780
it("should remove variant analysis", async () => {
@@ -804,12 +803,12 @@ describe("Variant Analysis Manager", () => {
804803
beforeEach(() => {
805804
variantAnalysis = createMockVariantAnalysis({});
806805

807-
variantAnalysisRemovedSpy.mockReset();
806+
variantAnalysisRemovedSpy;
808807
variantAnalysisManager.onVariantAnalysisRemoved(
809808
variantAnalysisRemovedSpy,
810809
);
811810

812-
executeCommandSpy.mockReset().mockResolvedValue(undefined);
811+
executeCommandSpy.mockResolvedValue(undefined);
813812
});
814813

815814
describe("when variant analysis record doesn't exist", () => {
@@ -900,7 +899,7 @@ describe("Variant Analysis Manager", () => {
900899
beforeEach(async () => {
901900
variantAnalysis = createMockVariantAnalysis({});
902901

903-
mockCancelVariantAnalysis.mockReset().mockResolvedValue(undefined);
902+
mockCancelVariantAnalysis.mockResolvedValue(undefined);
904903

905904
variantAnalysisStorageLocation =
906905
variantAnalysisManager.getVariantAnalysisStorageLocation(
@@ -1003,7 +1002,7 @@ describe("Variant Analysis Manager", () => {
10031002
await createTimestampFile(variantAnalysisStorageLocation);
10041003
await variantAnalysisManager.rehydrateVariantAnalysis(variantAnalysis);
10051004

1006-
writeTextStub.mockReset();
1005+
writeTextStub;
10071006
jest.spyOn(env, "clipboard", "get").mockReturnValue({
10081007
readText: jest.fn(),
10091008
writeText: writeTextStub,

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/variant-analysis-monitor.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ describe("Variant Analysis Monitor", () => {
7272
.spyOn(variantAnalysisManager, "autoDownloadVariantAnalysisResult")
7373
.mockResolvedValue(undefined);
7474

75-
mockGetVariantAnalysis
76-
.mockReset()
77-
.mockRejectedValue(new Error("Not mocked"));
75+
mockGetVariantAnalysis.mockRejectedValue(new Error("Not mocked"));
7876

7977
limitNumberOfAttemptsToMonitor();
8078
});

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/variant-analysis-results-manager.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,14 @@ describe(VariantAnalysisResultsManager.name, () => {
112112
);
113113
arrayBuffer = fs.readFileSync(sourceFilePath).buffer;
114114

115-
getVariantAnalysisRepoResultStub
116-
.mockReset()
117-
.mockImplementation(
118-
(_credentials: Credentials, downloadUrl: string) => {
119-
if (downloadUrl === dummyRepoTask.artifactUrl) {
120-
return Promise.resolve(arrayBuffer);
121-
}
122-
return Promise.reject(new Error("Unexpected artifact URL"));
123-
},
124-
);
115+
getVariantAnalysisRepoResultStub.mockImplementation(
116+
(_credentials: Credentials, downloadUrl: string) => {
117+
if (downloadUrl === dummyRepoTask.artifactUrl) {
118+
return Promise.resolve(arrayBuffer);
119+
}
120+
return Promise.reject(new Error("Unexpected artifact URL"));
121+
},
122+
);
125123
});
126124

127125
it("should call the API to download the results", async () => {

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/variant-analysis-submission-integration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ describe("Variant Analysis Submission Integration", () => {
5050

5151
await config.setRemoteControllerRepo("github/vscode-codeql");
5252

53-
quickPickSpy.mockReset().mockResolvedValue(undefined);
54-
inputBoxSpy.mockReset().mockResolvedValue(undefined);
53+
quickPickSpy.mockResolvedValue(undefined);
54+
inputBoxSpy.mockResolvedValue(undefined);
5555

5656
executeCommandSpy.mockRestore();
57-
showErrorMessageSpy.mockReset().mockResolvedValue(undefined);
57+
showErrorMessageSpy.mockResolvedValue(undefined);
5858

5959
await extensions
6060
.getExtension<CodeQLExtensionInterface | Record<string, never>>(

0 commit comments

Comments
 (0)