diff --git a/src/services/db/__tests__/GitFileCommitService.spec.ts b/src/services/db/__tests__/GitFileCommitService.spec.ts index f2558f3a6..4ea4fd100 100644 --- a/src/services/db/__tests__/GitFileCommitService.spec.ts +++ b/src/services/db/__tests__/GitFileCommitService.spec.ts @@ -110,7 +110,9 @@ describe("GitFileCommitService", () => { const pushSpy = jest .spyOn(gitFileCommitService, "pushToGithub") .mockResolvedValue() - + jest + .spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo") + .mockReturnValue(true) // Act const result = await gitFileCommitService.create(sessionData, { content, @@ -126,9 +128,18 @@ describe("GitFileCommitService", () => { content, directoryName, fileName, - isMedia ? "base64" : "utf-8", + "utf-8", STAGING_BRANCH ) + expect(createSpy).toHaveBeenCalledWith( + sessionData.siteName, + sessionData.isomerUserId, + content, + directoryName, + fileName, + "utf-8", + STAGING_LITE_BRANCH + ) expect(pushSpy).toHaveBeenCalledWith(sessionData, expect.any(Boolean)) expect(result).toEqual({ sha: "new-sha" }) }) @@ -189,6 +200,10 @@ describe("GitFileCommitService", () => { .spyOn(gitFileCommitService, "pushToGithub") .mockResolvedValue() + jest + .spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo") + .mockReturnValue(true) + // Act const result = await gitFileCommitService.update(sessionData, { fileContent, @@ -209,6 +224,15 @@ describe("GitFileCommitService", () => { sessionData.isomerUserId, STAGING_BRANCH ) + + expect(updateSpy).toHaveBeenCalledWith( + sessionData.siteName, + filePath, + fileContent, + sha, + sessionData.isomerUserId, + STAGING_LITE_BRANCH + ) expect(pushSpy).toHaveBeenCalledWith(sessionData, expect.any(Boolean)) expect(result).toEqual({ newSha: "new-sha" }) }) @@ -268,6 +292,10 @@ describe("GitFileCommitService", () => { .spyOn(gitFileCommitService, "pushToGithub") .mockResolvedValue() + jest + .spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo") + .mockReturnValue(true) + // Act await gitFileCommitService.deleteDirectory(sessionData, { directoryName, @@ -282,6 +310,14 @@ describe("GitFileCommitService", () => { true, STAGING_BRANCH ) + expect(deleteSpy).toHaveBeenCalledWith( + sessionData.siteName, + directoryName, + "", + sessionData.isomerUserId, + true, + STAGING_LITE_BRANCH + ) expect(pushSpy).toHaveBeenCalledWith(sessionData, expect.any(Boolean)) }) @@ -331,6 +367,9 @@ describe("GitFileCommitService", () => { const pushSpy = jest .spyOn(gitFileCommitService, "pushToGithub") .mockResolvedValue() + jest + .spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo") + .mockReturnValue(true) // Act await gitFileCommitService.delete(sessionData, { @@ -351,6 +390,14 @@ describe("GitFileCommitService", () => { false, STAGING_BRANCH ) + expect(deleteSpy).toHaveBeenCalledWith( + sessionData.siteName, + filePath, + sha, + sessionData.isomerUserId, + false, + STAGING_LITE_BRANCH + ) expect(pushSpy).toHaveBeenCalledWith(sessionData, expect.any(Boolean)) }) @@ -407,6 +454,9 @@ describe("GitFileCommitService", () => { const pushSpy = jest .spyOn(gitFileCommitService, "pushToGithub") .mockResolvedValue() + jest + .spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo") + .mockReturnValue(true) // Act const result = await gitFileCommitService.renameSinglePath( @@ -426,6 +476,14 @@ describe("GitFileCommitService", () => { STAGING_BRANCH, message ) + expect(renameSpy).toHaveBeenCalledWith( + sessionData.siteName, + oldPath, + newPath, + sessionData.isomerUserId, + STAGING_LITE_BRANCH, + message + ) expect(pushSpy).toHaveBeenCalledWith(sessionData, expect.any(Boolean)) expect(result).toEqual({ newSha: "new-sha" }) }) @@ -484,6 +542,9 @@ describe("GitFileCommitService", () => { const pushSpy = jest .spyOn(gitFileCommitService, "pushToGithub") .mockResolvedValue() + jest + .spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo") + .mockReturnValue(true) // Act const result = await gitFileCommitService.moveFiles( @@ -505,6 +566,15 @@ describe("GitFileCommitService", () => { STAGING_BRANCH, message ) + expect(moveFilesSpy).toHaveBeenCalledWith( + sessionData.siteName, + oldPath, + newPath, + sessionData.isomerUserId, + targetFiles, + STAGING_LITE_BRANCH, + message + ) expect(pushSpy).toHaveBeenCalledWith(sessionData, expect.any(Boolean)) expect(result).toEqual({ newSha: "new-sha" }) })