+ `
+ const output = formatter.format(input)
+ expect(output).toEqual(input)
+ })
+
+ describe("no whitespace introduction on single-line case statements", () => {
+ test("short case/when stays on one line without whitespace", () => {
+ const input = `<% case x %><% when 1 %>One<% when 2 %>Two<% else %>Other<% end %>`
+ const output = formatter.format(input)
+ expect(output).toEqual(input)
+ })
+
+ test("short case/when with ERB output stays on one line - no whitespace", () => {
+ const input = `<% case type %><% when :ok %><%= msg %><% else %>Error<% end %>`
+ const output = formatter.format(input)
+ expect(output).toEqual(input)
+ })
+
+ test("short case/when with only text stays on one line - no whitespace", () => {
+ const input = `<% case status %><% when 'ok' %>OK<% else %>Fail<% end %>`
+ const output = formatter.format(input)
+ expect(output).toEqual(input)
+ })
+
+ test("short case/in stays on one line - no whitespace", () => {
+ const input = `<% case val %><% in 1 %>A<% in 2 %>B<% else %>C<% end %>`
+ const output = formatter.format(input)
+ expect(output).toEqual(input)
+ })
+
+ test("short case with symbols stays on one line - no whitespace", () => {
+ const input = `<% case role %><% when :admin %>Admin<% when :user %>User<% end %>`
+ const output = formatter.format(input)
+ expect(output).toEqual(input)
+ })
+
+ test("short case with ERB output stays on one line - no whitespace", () => {
+ const input = `<% case a %><% when 1 %><%= x %><% when 2 %><%= y %><% end %>`
+ const output = formatter.format(input)
+ expect(output).toEqual(input)
+ })
+ })
})
diff --git a/javascript/packages/formatter/test/erb/erb.test.ts b/javascript/packages/formatter/test/erb/erb.test.ts
index e63ffb3c3..1dff621d8 100644
--- a/javascript/packages/formatter/test/erb/erb.test.ts
+++ b/javascript/packages/formatter/test/erb/erb.test.ts
@@ -795,100 +795,102 @@ describe("@herb-tools/formatter", () => {
`
- const expected = dedent`
-