test(format): select_wrap respects commas setting

This commit is contained in:
Hein
2026-10-06 14:53:13 +02:00
parent c51e8e2da4
commit e6c4e8b2c3
+16
View File
@@ -694,3 +694,19 @@ func TestJoinWrap(t *testing.T) {
t.Errorf("when_long long should equal always")
}
}
func TestSelectWrapBrokenHonoursCommaStyle(t *testing.T) {
src := "select a, b, c from t"
st := config.Default()
st.SelectWrap = config.WrapWhenLong
st.LineWidth = 8
st.Commas = config.CommaTrailing
got := File(parser.Parse(src), st)
if !strings.Contains(got, " a,\n") || strings.Contains(got, "\n ,b") {
t.Errorf("trailing commas expected when broken:\n%s", got)
}
st.Commas = config.CommaLeading
if got := File(parser.Parse(src), st); !strings.Contains(got, "\n ,b") {
t.Errorf("leading commas expected when broken:\n%s", got)
}
}