Skip to content

Commit 6522717

Browse files
committed
Test Map region and marker emission
1 parent 6d215bf commit 6522717

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests/EvaluatorTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,29 @@ struct GraphicsTests {
238238
#expect(node.props["systemName"] == .string("star.fill"))
239239
}
240240

241+
@Test("Map emits its region and marker children")
242+
func map() {
243+
struct Screen: View {
244+
@State var region = MKCoordinateRegion(
245+
center: CLLocationCoordinate2D(latitude: -12.046, longitude: -77.043),
246+
span: MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
247+
)
248+
var body: some View {
249+
Map(coordinateRegion: $region, markers: [
250+
MapMarker("Plaza", coordinate: CLLocationCoordinate2D(latitude: -12.045, longitude: -77.030)),
251+
])
252+
}
253+
}
254+
let node = ViewHost(Screen()).evaluate()
255+
#expect(node.type == "Map")
256+
#expect(node.props["centerLatitude"] == .double(-12.046))
257+
#expect(node.props["spanLongitude"] == .double(0.1))
258+
#expect(node.children.count == 1)
259+
#expect(node.children[0].type == "MapMarker")
260+
#expect(node.children[0].props["title"] == .string("Plaza"))
261+
#expect(node.children[0].props["latitude"] == .double(-12.045))
262+
}
263+
241264
@Test("Overlay emits base and overlay children with alignment")
242265
func overlay() {
243266
let node = ViewHost(Color.blue.overlay(alignment: .bottomTrailing) { Text("badge") }).evaluate()

0 commit comments

Comments
 (0)