Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aallam committed May 16, 2024
1 parent 573c1ef commit 79014c3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
4 changes: 3 additions & 1 deletion instantsearch/src/commonTest/kotlin/searcher/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ fun TestSearcherSingle(
indexName: IndexName,
insights: ClientInsights = ClientInsights(client.applicationID, client.apiKey),
coroutineScope: CoroutineScope = TestCoroutineScope,
isAutoSendingHitsViewEvents: Boolean = false,
) = HitsSearcher(
client = client,
insights = insights,
indexName = indexName,
isDisjunctiveFacetingEnabled = false,
coroutineScope = coroutineScope
coroutineScope = coroutineScope,
isAutoSendingHitsViewEvents = isAutoSendingHitsViewEvents,
)

fun TestSearcherForFacets(client: ClientSearch, indexName: IndexName, attribute: Attribute) = FacetsSearcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)
searcher.searchAsync().join()
userToken.startsWith("anonymous-").shouldBeTrue()
fetchedObjectIDs shouldEqual listOf("\"obj1\"", "\"obj2\"", "\"obj3\"")
Expand Down Expand Up @@ -131,7 +137,13 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)

searcher.searchAsync().join()
eventsCount shouldEqual 2
Expand Down Expand Up @@ -163,7 +175,13 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)
searcher.isAutoSendingHitsViewEvents = false
searcher.searchAsync().join()
calledInsights.shouldBeFalse()
Expand Down Expand Up @@ -197,11 +215,16 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)
searcher.userToken = UserToken("my-user-token");
searcher.searchAsync().join()

userToken shouldEqual "my-user-token"
}

}

0 comments on commit 79014c3

Please sign in to comment.