Skip to content

Commit

Permalink
Untitled commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kishore03109 committed Dec 6, 2023
1 parent c0ec6f5 commit 46c7528
Showing 1 changed file with 72 additions and 2 deletions.
74 changes: 72 additions & 2 deletions src/services/db/__tests__/GitFileCommitService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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" })
})
Expand Down Expand Up @@ -189,6 +200,10 @@ describe("GitFileCommitService", () => {
.spyOn(gitFileCommitService, "pushToGithub")
.mockResolvedValue()

jest
.spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo")
.mockReturnValue(true)

// Act
const result = await gitFileCommitService.update(sessionData, {
fileContent,
Expand All @@ -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" })
})
Expand Down Expand Up @@ -268,6 +292,10 @@ describe("GitFileCommitService", () => {
.spyOn(gitFileCommitService, "pushToGithub")
.mockResolvedValue()

jest
.spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo")
.mockReturnValue(true)

// Act
await gitFileCommitService.deleteDirectory(sessionData, {
directoryName,
Expand All @@ -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))
})

Expand Down Expand Up @@ -331,6 +367,9 @@ describe("GitFileCommitService", () => {
const pushSpy = jest
.spyOn(gitFileCommitService, "pushToGithub")
.mockResolvedValue()
jest
.spyOn(gbUtils, "isReduceBuildTimesWhitelistedRepo")
.mockReturnValue(true)

// Act
await gitFileCommitService.delete(sessionData, {
Expand All @@ -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))
})

Expand Down Expand Up @@ -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(
Expand All @@ -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" })
})
Expand Down Expand Up @@ -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(
Expand All @@ -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" })
})
Expand Down

0 comments on commit 46c7528

Please sign in to comment.