Skip to content

Commit edf3167

Browse files
committed
Test text-styling modifier emission
1 parent 4b28145 commit edf3167

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests/EvaluatorTests.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,42 @@ struct ModifierTests {
108108
#expect(frame?.args["width"] == .double(100))
109109
#expect(frame?.args["height"] == .double(50))
110110
}
111+
112+
@Test("Named font emits its style")
113+
func fontStyle() {
114+
let node = ViewHost(Text("x").font(.headline)).evaluate()
115+
let font = node.modifiers.first { $0.kind == "font" }
116+
#expect(font?.args["style"] == .string("headline"))
117+
#expect(font?.args["size"] == nil)
118+
}
119+
120+
@Test("System font emits size and weight")
121+
func systemFont() {
122+
let node = ViewHost(Text("x").font(.system(size: 24, weight: .heavy))).evaluate()
123+
let font = node.modifiers.first { $0.kind == "font" }
124+
#expect(font?.args["size"] == .double(24))
125+
#expect(font?.args["weight"] == .string("heavy"))
126+
}
127+
128+
@Test("foregroundColor emits an argb color")
129+
func foregroundColor() {
130+
let node = ViewHost(Text("x").foregroundColor(.red)).evaluate()
131+
let color = node.modifiers.first { $0.kind == "foregroundColor" }
132+
#expect(color?.args["color"] == Color.red.propValue)
133+
}
134+
135+
@Test("bold and italic emit their kinds")
136+
func boldItalic() {
137+
let node = ViewHost(Text("x").bold().italic()).evaluate()
138+
let weight = node.modifiers.first { $0.kind == "fontWeight" }
139+
#expect(weight?.args["weight"] == .string("bold"))
140+
#expect(node.modifiers.contains { $0.kind == "italic" })
141+
}
142+
143+
@Test("lineLimit emits its count")
144+
func lineLimit() {
145+
let node = ViewHost(Text("x").lineLimit(2)).evaluate()
146+
let limit = node.modifiers.first { $0.kind == "lineLimit" }
147+
#expect(limit?.args["count"] == .int(2))
148+
}
111149
}

0 commit comments

Comments
 (0)