Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(review): fix tests for review router #683

Merged
merged 2 commits into from
Apr 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/routes/v2/authenticated/__tests__/review.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ describe("Review Requests Router", () => {
})

describe("compareDiff", () => {
beforeEach(() => {
// NOTE: Skip preconditions check for unmigrated site
seaerchin marked this conversation as resolved.
Show resolved Hide resolved
mockCollaboratorsService.list.mockResolvedValueOnce([{}])
})
it("should return 200 with the list of changed files", async () => {
// Arrange
const mockFilesChanged = ["file1", "file2"]
Expand All @@ -144,7 +148,6 @@ describe("Review Requests Router", () => {
mockFilesChanged
)
mockSitesService.getBySiteName.mockResolvedValueOnce(true)

// Act
const response = await request(app).get("/mockSite/review/compare")

Expand Down Expand Up @@ -317,6 +320,10 @@ describe("Review Requests Router", () => {
})

describe("listReviews", () => {
beforeEach(() => {
// NOTE: Skip preconditions check for unmigrated site
mockCollaboratorsService.list.mockResolvedValueOnce([{}])
})
it("should return 200 with the list of reviews", async () => {
// Arrange
const mockReviews = ["review1", "review2"]
Expand All @@ -343,6 +350,7 @@ describe("Review Requests Router", () => {
// Arrange
mockSitesService.getBySiteName.mockResolvedValueOnce(null)
mockGithubService.getRepoInfo.mockRejectedValueOnce(false)
mockIdentityUsersService.getSiteMember.mockResolvedValueOnce({})

// Act
const response = await request(app).get("/mockSite/review/summary")
Expand Down Expand Up @@ -502,6 +510,11 @@ describe("Review Requests Router", () => {
})

describe("getReviewRequest", () => {
beforeEach(() => {
// NOTE: Skip preconditions check for unmigrated site
mockCollaboratorsService.list.mockResolvedValueOnce([{}])
})

it("should return 200 with the full review request", async () => {
// Arrange
const mockReviewRequest = "review request"
Expand Down Expand Up @@ -897,6 +910,10 @@ describe("Review Requests Router", () => {
})

describe("getComments", () => {
beforeEach(() => {
// NOTE: Skip preconditions check for unmigrated site
mockCollaboratorsService.list.mockResolvedValueOnce([{}])
})
it("should return 200 with the comments for a review request", async () => {
// Arrange
const mockComments = ["comment1", "comment2"]
Expand Down