Skip to content

Commit

Permalink
Merge pull request #82 from exercism/jie-unique-comments
Browse files Browse the repository at this point in the history
Remove duplicate comments
  • Loading branch information
jiegillet authored Nov 28, 2023
2 parents f677f24 + 52c5e49 commit 43fb354
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Comment.elm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ aggregateComments : List Comment -> Summary
aggregateComments comments =
let
sortedComments =
List.sortBy commentTypeShowOrder comments
comments
|> List.Extra.unique
|> List.sortBy commentTypeShowOrder

( message, extraComments ) =
case List.map .commentType comments |> List.Extra.minimumBy commentTypeSummaryOrder of
Expand Down
11 changes: 9 additions & 2 deletions tests/CommentTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ aggregateCommentsTest =
, test "order of comments in summary is fixed" <|
\() ->
Expect.equal
(Comment.aggregateComments [ essential, informative, celebratory, actionable, informative ])
(Comment.aggregateComments [ essential, informative, celebratory, actionable ])
(Summary "Check the comments for things to fix.\u{202F}🛠 "
[ celebratory, essential, actionable, informative, informative, Comment.feedbackComment ]
[ celebratory, essential, actionable, informative, Comment.feedbackComment ]
)
, test "secondary order is alphabetical, but feedback is always last" <|
\() ->
Expand All @@ -148,6 +148,13 @@ aggregateCommentsTest =
, Comment.feedbackComment
]
)
, test "duplicate comments are removed" <|
\() ->
Expect.equal
(Comment.aggregateComments [ essential, essential, celebratory, celebratory ])
(Summary "Check the comments for things to fix.\u{202F}🛠 "
[ celebratory, essential, Comment.feedbackComment ]
)
]


Expand Down

0 comments on commit 43fb354

Please sign in to comment.