refactor: make test resets more explicit

This commit is contained in:
Eden Zimbelman
2026-02-04 00:29:08 -08:00
parent c0f43820e1
commit 4760897243
+13 -17
View File
@@ -89,29 +89,25 @@ export class Mock {
* Testing interface that removes internal state from existing mocks. * Testing interface that removes internal state from existing mocks.
*/ */
reset() { reset() {
// Clear lookup tables this._isDebug = false;
this.inputs = {};
this.booleanInputs = {};
// Reset axios mock
this.axios.post.mock.resetCalls(); this.axios.post.mock.resetCalls();
this.axios.post._promise = undefined; this.axios.post._promise = undefined;
this.booleanInputs = {};
// Reset apiCall mock
this.calls.mock.resetCalls(); this.calls.mock.resetCalls();
this.calls._resolvesWith = undefined; this.calls._resolvesWith = undefined;
this.calls._rejectsWith = undefined; this.calls._rejectsWith = undefined;
this.core.debug.mock.resetCalls();
// Reset core mocks this.core.error.mock.resetCalls();
for (const fn of Object.values(this.core)) { this.core.getBooleanInput.mock.resetCalls();
fn.mock?.resetCalls(); this.core.getInput.mock.resetCalls();
} this.core.info.mock.resetCalls();
this._isDebug = false; this.core.isDebug.mock.resetCalls();
this.core.setFailed.mock.resetCalls();
// Reset webapi this.core.setOutput.mock.resetCalls();
this.core.setSecret.mock.resetCalls();
this.core.warning.mock.resetCalls();
this.inputs = {};
this.webapi = {}; this.webapi = {};
// Clear environment variables
process.env.SLACK_TOKEN = ""; process.env.SLACK_TOKEN = "";
process.env.SLACK_WEBHOOK_URL = ""; process.env.SLACK_WEBHOOK_URL = "";
} }