Skip to content

Commit 9c7b42f

Browse files
committed
Test sheet detent emission
1 parent ae84726 commit 9c7b42f

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests/NavigationTests.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,34 @@ struct NavigationTests {
226226
#expect(host.callbacks.callback(for: tap) != nil)
227227
}
228228

229+
@Test("A sheet carries its detents, and none by default")
230+
func sheetDetents() {
231+
struct Screen: View {
232+
@State var shown = true
233+
var body: some View {
234+
Button("Show") { shown = true }
235+
.sheet(isPresented: $shown) {
236+
Text("body").presentationDetents([.medium])
237+
}
238+
}
239+
}
240+
let node = ViewHost(Screen()).evaluate()
241+
let sheet = node.children.first { $0.type == "Sheet" }
242+
#expect(sheet?.props["detents"] == .array([.string("medium")]))
243+
244+
// no detents declared: the interpreter reads that as a full-height sheet
245+
struct Plain: View {
246+
@State var shown = true
247+
var body: some View {
248+
Button("Show") { shown = true }
249+
.sheet(isPresented: $shown) { Text("body") }
250+
}
251+
}
252+
let plain = ViewHost(Plain()).evaluate()
253+
let plainSheet = plain.children.first { $0.type == "Sheet" }
254+
#expect(plainSheet?.props["detents"] == .array([]))
255+
}
256+
229257
@Test("TabView emits tabs with their item labels and selection")
230258
func tabs() {
231259
struct Screen: View {

0 commit comments

Comments
 (0)