Skip to content

Commit

Permalink
chore: use fake timers to speed the slow unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsetton committed Aug 9, 2023
1 parent cd4a6c5 commit bc54b34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ describe("Command: Configure - AWS profile setup helper test", () => {
sinon.stub(ui, "addNewCredentials").callsArgWith(0, null, TEST_CREDENTIALS);
sinon.stub(awsProfileHandler, "addProfile");
sinon.stub(profileHelper, "setupProfile");
sinon.useFakeTimers().tickAsync(CONSTANTS.CONFIGURATION.OPEN_BROWSER_DELAY);

// call
proxyHelper.setupAwsProfile({askProfile: TEST_PROFILE, needBrowser: true}, (err, awsProfile) => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/controller/hosted-skill-controller/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ describe("Controller test - hosted skill controller test", () => {
const stubTestFunc = sinon.stub(httpClient, "request"); // stub getSkillStatus smapi request
stubTestFunc.onCall(0).callsArgWith(3, null, TEST_STATUS_RESPONSE_0);
stubTestFunc.onCall(1).callsArgWith(3, null, TEST_STATUS_RESPONSE_1);
sinon.useFakeTimers().tickAsync(CONSTANTS.CONFIGURATION.RETRY.MAX_RETRY_INTERVAL);
// call
hostedSkillController.checkSkillStatus(TEST_SKILL_ID, (err, res) => {
expect(err).equal(null);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/controller/skill-metadata-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ describe("Controller test - skill metadata controller test", () => {

it("| poll status retries with getImportStatus warnings, expects warnings logged once", (done) => {
// setup
sinon.useFakeTimers().tickAsync(CONSTANTS.CONFIGURATION.RETRY.MAX_RETRY_INTERVAL);
requestStub
.onCall(0)
.callsArgWith(3, null, smapiImportStatusResponseWithWarningsInProgress)
Expand Down Expand Up @@ -1373,6 +1374,7 @@ describe("Controller test - skill metadata controller test", () => {

it("| poll import status with multiple retries, expect callback with correct response", (done) => {
// setup
sinon.useFakeTimers().tickAsync(CONSTANTS.CONFIGURATION.RETRY.MAX_RETRY_INTERVAL);
requestStub
.onCall(0)
.callsArgWith(3, null, smapiImportStatusResponseInProgress)
Expand Down Expand Up @@ -1424,6 +1426,7 @@ describe("Controller test - skill metadata controller test", () => {

it("| poll import status with getSkillStatus build failures", (done) => {
// setup
sinon.useFakeTimers().tickAsync(CONSTANTS.CONFIGURATION.RETRY.MAX_RETRY_INTERVAL);
requestStub
.onCall(0)
.callsArgWith(3, null, smapiImportStatusResponseInProgress)
Expand All @@ -1445,6 +1448,7 @@ describe("Controller test - skill metadata controller test", () => {

it("| poll status smapi calls return success, expect GetSkillStatus calls", (done) => {
// setup
sinon.useFakeTimers().tickAsync(CONSTANTS.CONFIGURATION.RETRY.MAX_RETRY_INTERVAL);
requestStub
.onCall(0)
.callsArgWith(3, null, smapiImportStatusResponseInProgress)
Expand All @@ -1465,6 +1469,7 @@ describe("Controller test - skill metadata controller test", () => {

it("| poll status smapi calls return empty SkillID, expect no GetSkillStatus calls", (done) => {
// setup
sinon.useFakeTimers().tickAsync(CONSTANTS.CONFIGURATION.RETRY.MAX_RETRY_INTERVAL);
requestStub
.onCall(0)
.callsArgWith(3, null, smapiImportStatusResponse200EmptySkillID)
Expand Down

0 comments on commit bc54b34

Please sign in to comment.