Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758package social.grain
import androidx.test.ext.junit.runners.AndroidJUnit4import kotlinx.serialization.json.jsonPrimitiveimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertNullimport org.junit.Testimport org.junit.runner.RunWithimport social.grain.data.location.Coordinateimport social.grain.feature.explore.LocationPinimport social.grain.feature.explore.pinBoundsimport social.grain.feature.explore.placeFeaturesimport social.grain.ui.components.localityOf
/** The pins as the map wants them: GeoJSON points, and a box around them. */@RunWith(AndroidJUnit4::class)class PlaceFeaturesTest {
private val lisbon = LocationPin("Lisbon, PT", "85390cb7fffffff", 3, Coordinate(38.72, -9.14)) private val porto = LocationPin("Porto, PT", "853913d3fffffff", 1, Coordinate(41.15, -8.61))
@Test fun eachPinBecomesAPointCarryingWhatATapNeeds() { val features = placeFeatures(listOf(lisbon, porto))
assertEquals(2, features.features.size) val first = features.features.first() assertEquals(-9.14, first.geometry.longitude, 1e-9) assertEquals(38.72, first.geometry.latitude, 1e-9) assertEquals("Lisbon, PT", first.properties["name"]?.jsonPrimitive?.content) assertEquals("85390cb7fffffff", first.properties["h3"]?.jsonPrimitive?.content) assertEquals("3", first.properties["count"]?.jsonPrimitive?.content) }
@Test fun theBoundsFrameEveryPin() { val bounds = pinBounds(listOf(lisbon, porto))!!
assertEquals(-9.14, bounds.west, 1e-9) assertEquals(38.72, bounds.south, 1e-9) assertEquals(-8.61, bounds.east, 1e-9) assertEquals(41.15, bounds.north, 1e-9) }
@Test fun theMapLabelIsTheLocalityAlone() { assertEquals("Nazaré", localityOf("Nazaré, Leiria, PT")) assertEquals("Lisbon", localityOf("Lisbon, PT")) assertEquals("Portugal", localityOf("Portugal")) assertEquals(", PT", localityOf(", PT")) }
@Test fun nothingToFrameIsNoBoundsRatherThanAnEmptyBox() { assertNull(pinBounds(emptyList())) }}