Skip to content

Commit

Permalink
fix: test cov
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Sep 21, 2023
1 parent 6da1c31 commit 34e3863
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,32 @@ class SearchKnownUserUseCaseTest {

}

@Test
fun givenAnInputStartingWithAtSymbolAndDomainPresent_whenSearchingUsers_thenSearchBySanitizedHandle() = runTest {
// given
val handlePartOfQuery = "somehandle"
val handleSearchQuery = "@$handlePartOfQuery@bella.wire.link"
val (arrangement, searchKnownUsersUseCase) = Arrangement()
.withSuccessFullSelfUserRetrieve()
.withSearchByHandle(handleSearchQuery)
.arrange()

// when
searchKnownUsersUseCase(handleSearchQuery)

// then
verify(arrangement.searchUserRepository)
.suspendFunction(arrangement.searchUserRepository::searchKnownUsersByHandle)
.with(eq(handlePartOfQuery), anything())
.wasInvoked(exactly = once)

verify(arrangement.searchUserRepository)
.suspendFunction(arrangement.searchUserRepository::searchKnownUsersByNameOrHandleOrEmail)
.with(anything(), anything())
.wasNotInvoked()
}


private class Arrangement {

@Mock
Expand Down Expand Up @@ -292,7 +318,7 @@ class SearchKnownUserUseCaseTest {
given(searchUserRepository)
.suspendFunction(searchUserRepository::searchKnownUsersByHandle)
.whenInvokedWith(
if (searchQuery == null) any() else eq(searchQuery.removePrefix("@")),
if (searchQuery == null) any() else eq(searchQuery.substringAfter("@").substringBeforeLast("@")),
if (searchUsersOptions == null) any() else eq(searchUsersOptions)
)
.thenReturn(
Expand Down

0 comments on commit 34e3863

Please sign in to comment.