Skip to content

Commit 90fe5bc

Browse files
committed
Test appearance modifiers and overlay
1 parent e960a14 commit 90fe5bc

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests/EvaluatorTests.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ struct ModifierTests {
180180
let flag = node.modifiers.first { $0.kind == "disabled" }
181181
#expect(flag?.args["value"] == .bool(true))
182182
}
183+
184+
@Test("Border emits its color and width")
185+
func border() {
186+
let node = ViewHost(Text("x").border(.blue, width: 2)).evaluate()
187+
let border = node.modifiers.first { $0.kind == "border" }
188+
#expect(border?.args["color"] == Color.blue.propValue)
189+
#expect(border?.args["width"] == .double(2))
190+
}
191+
192+
@Test("clipShape emits the shape kind")
193+
func clipShape() {
194+
let node = ViewHost(Text("x").clipShape(Circle())).evaluate()
195+
#expect(node.modifiers.contains { $0.kind == "clipShape" && $0.args["shape"] == .string("circle") })
196+
}
197+
198+
@Test("shadow emits its radius")
199+
func shadow() {
200+
let node = ViewHost(Text("x").shadow(radius: 6)).evaluate()
201+
#expect(node.modifiers.first { $0.kind == "shadow" }?.args["radius"] == .double(6))
202+
}
183203
}
184204

185205
// MARK: - Graphics
@@ -217,4 +237,15 @@ struct GraphicsTests {
217237
#expect(node.type == "Image")
218238
#expect(node.props["systemName"] == .string("star.fill"))
219239
}
240+
241+
@Test("Overlay emits base and overlay children with alignment")
242+
func overlay() {
243+
let node = ViewHost(Color.blue.overlay(alignment: .bottomTrailing) { Text("badge") }).evaluate()
244+
#expect(node.type == "Overlay")
245+
#expect(node.children.count == 2)
246+
#expect(node.children[0].type == "Color")
247+
#expect(firstTextString(node.children[1]) == "badge")
248+
#expect(node.props["horizontal"] == .string("trailing"))
249+
#expect(node.props["vertical"] == .string("bottom"))
250+
}
220251
}

0 commit comments

Comments
 (0)