Skip to content

Commit b9a0d6d

Browse files
committed
Add tests to verify options are passed
1 parent 76e2a83 commit b9a0d6d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

core-kotlin/src/test/java/com/amplifyframework/kotlin/geo/KotlinGeoFacadeTest.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import com.amplifyframework.geo.GeoException
2121
import com.amplifyframework.geo.models.Coordinates
2222
import com.amplifyframework.geo.models.MapStyle
2323
import com.amplifyframework.geo.models.MapStyleDescriptor
24+
import com.amplifyframework.geo.options.GeoSearchByCoordinatesOptions
25+
import com.amplifyframework.geo.options.GeoSearchByTextOptions
26+
import com.amplifyframework.geo.options.GetMapStyleDescriptorOptions
2427
import com.amplifyframework.geo.result.GeoSearchResult
2528
import io.mockk.every
2629
import io.mockk.mockk
@@ -91,6 +94,18 @@ internal class KotlinGeoFacadeTest {
9194
assertSame(descriptor, result)
9295
}
9396

97+
@Test
98+
fun `returns map style descriptor with options`() = runBlocking {
99+
val descriptor = MapStyleDescriptor("")
100+
val options = GetMapStyleDescriptorOptions.builder().mapName("map").build()
101+
every { delegate.getMapStyleDescriptor(options, any(), any()) } answers {
102+
val callback = secondArg<Consumer<MapStyleDescriptor>>()
103+
callback.accept(descriptor)
104+
}
105+
val result = geo.getMapStyleDescriptor(options)
106+
assertSame(descriptor, result)
107+
}
108+
94109
@Test(expected = GeoException::class)
95110
fun `throws map style descriptor error`(): Unit = runBlocking {
96111
val error = GeoException("message", "suggestion")
@@ -113,6 +128,19 @@ internal class KotlinGeoFacadeTest {
113128
assertSame(searchResult, result)
114129
}
115130

131+
@Test
132+
fun `returns search by text result with options`() = runBlocking {
133+
val query = "query"
134+
val options = GeoSearchByTextOptions.builder().maxResults(4).build()
135+
val searchResult = GeoSearchResult.withPlaces(emptyList())
136+
every { delegate.searchByText(query, options, any(), any()) } answers {
137+
val callback = thirdArg<Consumer<GeoSearchResult>>()
138+
callback.accept(searchResult)
139+
}
140+
val result = geo.searchByText(query, options)
141+
assertSame(searchResult, result)
142+
}
143+
116144
@Test(expected = GeoException::class)
117145
fun `throws search by text error`(): Unit = runBlocking {
118146
val query = "query"
@@ -136,6 +164,19 @@ internal class KotlinGeoFacadeTest {
136164
assertSame(searchResult, result)
137165
}
138166

167+
@Test
168+
fun `returns search by coordinates result with options`() = runBlocking {
169+
val position = Coordinates()
170+
val options = GeoSearchByCoordinatesOptions.builder().maxResults(3).build()
171+
val searchResult = GeoSearchResult.withPlaces(emptyList())
172+
every { delegate.searchByCoordinates(position, options, any(), any()) } answers {
173+
val callback = thirdArg<Consumer<GeoSearchResult>>()
174+
callback.accept(searchResult)
175+
}
176+
val result = geo.searchByCoordinates(position, options)
177+
assertSame(searchResult, result)
178+
}
179+
139180
@Test(expected = GeoException::class)
140181
fun `throws search by coordinates error`(): Unit = runBlocking {
141182
val position = Coordinates()

0 commit comments

Comments
 (0)