Skip to content

Commit

Permalink
test: add additional tests for getFirstReviewToLastReview
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-michaud authored and hectcastro committed Apr 11, 2022
1 parent 82cb2e1 commit 44db53c
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions cmd/ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,82 @@ func Test_getFirstReviewToLastReview(t *testing.T) {
st.Assert(t, uiWithWeekends.getFirstReviewToLastReview("Batman", reviews), "1h0m")
}

func Test_getFirstReviewToLastReview_AuthorReviewLast(t *testing.T) {
var reviews = Reviews{
Nodes: ReviewNodes{
{
Author: Author{
Login: "Joker",
},
CreatedAt: "2022-04-06T16:11:09Z",
State: "CHANGES_REQUESTED",
},
{
Author: Author{
Login: "Joker",
},
CreatedAt: "2022-04-06T17:11:09Z",
State: "APPROVED",
},
{
Author: Author{
Login: "Batman",
},
CreatedAt: "2022-04-06T18:11:09Z",
State: "COMMENTED",
},
},
}

uiWithWeekends := &UI{
Calendar: &cal.BusinessCalendar{
WorkdayFunc: WorkdayAllDays,
WorkdayStartFunc: WorkdayStart,
WorkdayEndFunc: WorkdayEnd,
},
}

st.Assert(t, uiWithWeekends.getFirstReviewToLastReview("Batman", reviews), "1h0m")
}

func Test_getFirstReviewToLastReview_ReviewerReviewCommentLast(t *testing.T) {
var reviews = Reviews{
Nodes: ReviewNodes{
{
Author: Author{
Login: "Joker",
},
CreatedAt: "2022-04-06T16:11:09Z",
State: "CHANGES_REQUESTED",
},
{
Author: Author{
Login: "Joker",
},
CreatedAt: "2022-04-06T17:11:09Z",
State: "APPROVED",
},
{
Author: Author{
Login: "Joker",
},
CreatedAt: "2022-04-06T18:11:09Z",
State: "COMMENTED",
},
},
}

uiWithWeekends := &UI{
Calendar: &cal.BusinessCalendar{
WorkdayFunc: WorkdayAllDays,
WorkdayStartFunc: WorkdayStart,
WorkdayEndFunc: WorkdayEnd,
},
}

st.Assert(t, uiWithWeekends.getFirstReviewToLastReview("Batman", reviews), "1h0m")
}

func Test_getFirstApprovalToMerge(t *testing.T) {
var reviews = Reviews{
Nodes: ReviewNodes{
Expand Down

0 comments on commit 44db53c

Please sign in to comment.