From fd57e2d9a630a2ba0d229419e11f39abd97f88bf Mon Sep 17 00:00:00 2001
From: Jarred Sumner <jarred@jarredsumner.com>
Date: Thu, 4 Nov 2021 15:27:29 -0700
Subject: [JSX] Match esbuild behavior for multiline JSX string literals

---
 integration/snippets/jsx-spacing.jsx | 60 +++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 28 deletions(-)

(limited to 'integration/snippets/jsx-spacing.jsx')

diff --git a/integration/snippets/jsx-spacing.jsx b/integration/snippets/jsx-spacing.jsx
index 73e31ebaa..5feab1830 100644
--- a/integration/snippets/jsx-spacing.jsx
+++ b/integration/snippets/jsx-spacing.jsx
@@ -1,36 +1,40 @@
 import * as ReactDOM from "react-dom/server";
 
-const Tester = ({ description }) => {
-  console.assert(
-    description ===
-      "foo\nbar \n\nbaz\n\nthis\ntest\n\nchecks\nnewlines\nare\ngood\nyeah\n\n",
-    "Expected description to be 'foo\\nbar \\n\\nbaz\\n\\nthis\\ntest\\n\\nchecks\\nnewlines\\nare\\ngood\\nyeah\\n\\n' but was '" +
-      description +
-      "'"
+const ReturnDescriptionAsString = ({ description }) => description;
+
+export function test() {
+  const _bun = ReactDOM.renderToString(
+    <ReturnDescriptionAsString
+      description="line1
+line2 trailing space 
+
+line4 no trailing space 'single quote' \t\f\v\uF000 `template string`
+
+line6 no trailing space
+line7 trailing newline that ${terminates} the string literal
+"
+    ></ReturnDescriptionAsString>
   );
 
-  return description;
-};
+  // convert HTML entities to unicode
+  const el = document.createElement("textarea");
+  el.innerHTML = _bun;
+  const bun = el.value;
 
-export function test() {
-  const foo = ReactDOM.renderToString(
-    <Tester
-      description="foo
-  bar 
-  
-  baz
-  
-  this
-  test
-  
-  checks
-  newlines
-  are
-  good
-  yeah
-  
-  "
-    ></Tester>
+  const esbuild =
+    "line1\nline2 trailing space \n\nline4 no trailing space 'single quote' \\t\\f\\v\\uF000 `template string`\n\nline6 no trailing space\nline7 trailing newline that ${terminates} the string literal\n";
+
+  console.assert(
+    bun === esbuild,
+    `strings did not match: ${JSON.stringify(
+      {
+        received: bun,
+        expected: esbuild,
+      },
+      null,
+      2
+    )}`
   );
+
   testDone(import.meta.url);
 }
-- 
cgit v1.2.3

