Improve tests for JSX quotes (#19856)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-08-15 17:30:50 +08:00
1 parent acb755b040
commit bee1399282
7 files changed
+425 -4865

No files matched your search

File diff suppressed because it is too large. Load diff
File renamed without changes.
+1 -16
View File
@@ -1,16 +1 @@
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: false,
jsxSingleQuote: false,
});
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: false,
jsxSingleQuote: true,
});
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: true,
jsxSingleQuote: false,
});
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: true,
jsxSingleQuote: true,
});
runFormatTest(import.meta, ["babel", "typescript", "flow"]);
File renamed without changes.
@@ -0,0 +1,389 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`quotes.js - {"singleQuote":false,"jsxSingleQuote":false} format 1`] = `
====================================options=====================================
jsxSingleQuote: false
parsers: ["babel", "typescript", "flow"]
singleQuote: false
printWidth: 80 (default) |
=====================================input======================================
<div id="&quot;'<>&amp;quot;" />;
<div id='"&#39;<>&amp;quot;' />;
<div id={'\\'"&quot;<>&amp;quot;'} />;
<div id='123' />;
<div id='&#39;&quot;' />;
<div id={'\\'\\"\\\\\\''} />;
<div
single='foo'
single2={'foo'}
double="bar"
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={'\\''}
singleEscaped2='&apos;'
doubleEscaped={"\\""}
doubleEscaped2="&quot;"
singleBothEscaped={'\\'"'}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={'\\' "'}
singleBoth3='&apos; &apos; "'
doubleBoth="&quot; '"
doubleBoth2={"\\" '"}
doubleBoth3="&quot; &apos; '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '}
</p>
=====================================output=====================================
<div id="&quot;'<>&amp;quot;" />;
<div id='"&#39;<>&amp;quot;' />;
<div id={"'\\"&quot;<>&amp;quot;"} />;
<div id="123" />;
<div id='&#39;"' />;
<div id={"'\\"\\\\'"} />;
<div
single="foo"
single2={"foo"}
double="bar"
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={"'\\""}
singleBothEscaped2="'&quot;"
singleBoth="' &quot;"
singleBoth2={"' \\""}
singleBoth3="' ' &quot;"
doubleBoth="&quot; '"
doubleBoth2={"\\" '"}
doubleBoth3="&quot; ' '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{" "}{" "}
</p>;
================================================================================
`;
exports[`quotes.js - {"singleQuote":false,"jsxSingleQuote":true} format 1`] = `
====================================options=====================================
jsxSingleQuote: true
parsers: ["babel", "typescript", "flow"]
singleQuote: false
printWidth: 80 (default) |
=====================================input======================================
<div id="&quot;'<>&amp;quot;" />;
<div id='"&#39;<>&amp;quot;' />;
<div id={'\\'"&quot;<>&amp;quot;'} />;
<div id='123' />;
<div id='&#39;&quot;' />;
<div id={'\\'\\"\\\\\\''} />;
<div
single='foo'
single2={'foo'}
double="bar"
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={'\\''}
singleEscaped2='&apos;'
doubleEscaped={"\\""}
doubleEscaped2="&quot;"
singleBothEscaped={'\\'"'}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={'\\' "'}
singleBoth3='&apos; &apos; "'
doubleBoth="&quot; '"
doubleBoth2={"\\" '"}
doubleBoth3="&quot; &apos; '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '}
</p>
=====================================output=====================================
<div id='"&apos;<>&amp;quot;' />;
<div id='"&#39;<>&amp;quot;' />;
<div id={"'\\"&quot;<>&amp;quot;"} />;
<div id='123' />;
<div id='&#39;"' />;
<div id={"'\\"\\\\'"} />;
<div
single='foo'
single2={"foo"}
double='bar'
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={"'\\""}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={"' \\""}
singleBoth3="' ' &quot;"
doubleBoth='" &apos;'
doubleBoth2={"\\" '"}
doubleBoth3="&quot; ' '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{" "}{" "}
</p>;
================================================================================
`;
exports[`quotes.js - {"singleQuote":true,"jsxSingleQuote":false} format 1`] = `
====================================options=====================================
jsxSingleQuote: false
parsers: ["babel", "typescript", "flow"]
singleQuote: true
printWidth: 80 (default) |
=====================================input======================================
<div id="&quot;'<>&amp;quot;" />;
<div id='"&#39;<>&amp;quot;' />;
<div id={'\\'"&quot;<>&amp;quot;'} />;
<div id='123' />;
<div id='&#39;&quot;' />;
<div id={'\\'\\"\\\\\\''} />;
<div
single='foo'
single2={'foo'}
double="bar"
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={'\\''}
singleEscaped2='&apos;'
doubleEscaped={"\\""}
doubleEscaped2="&quot;"
singleBothEscaped={'\\'"'}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={'\\' "'}
singleBoth3='&apos; &apos; "'
doubleBoth="&quot; '"
doubleBoth2={"\\" '"}
doubleBoth3="&quot; &apos; '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '}
</p>
=====================================output=====================================
<div id="&quot;'<>&amp;quot;" />;
<div id='"&#39;<>&amp;quot;' />;
<div id={'\\'"&quot;<>&amp;quot;'} />;
<div id="123" />;
<div id='&#39;"' />;
<div id={"'\\"\\\\'"} />;
<div
single="foo"
single2={'foo'}
double="bar"
double2={'bar'}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={'\\'"'}
singleBothEscaped2="'&quot;"
singleBoth="' &quot;"
singleBoth2={'\\' "'}
singleBoth3="' ' &quot;"
doubleBoth="&quot; '"
doubleBoth2={'" \\''}
doubleBoth3="&quot; ' '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '}
</p>;
================================================================================
`;
exports[`quotes.js - {"singleQuote":true,"jsxSingleQuote":true} format 1`] = `
====================================options=====================================
jsxSingleQuote: true
parsers: ["babel", "typescript", "flow"]
singleQuote: true
printWidth: 80 (default) |
=====================================input======================================
<div id="&quot;'<>&amp;quot;" />;
<div id='"&#39;<>&amp;quot;' />;
<div id={'\\'"&quot;<>&amp;quot;'} />;
<div id='123' />;
<div id='&#39;&quot;' />;
<div id={'\\'\\"\\\\\\''} />;
<div
single='foo'
single2={'foo'}
double="bar"
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={'\\''}
singleEscaped2='&apos;'
doubleEscaped={"\\""}
doubleEscaped2="&quot;"
singleBothEscaped={'\\'"'}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={'\\' "'}
singleBoth3='&apos; &apos; "'
doubleBoth="&quot; '"
doubleBoth2={"\\" '"}
doubleBoth3="&quot; &apos; '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '}
</p>
=====================================output=====================================
<div id='"&apos;<>&amp;quot;' />;
<div id='"&#39;<>&amp;quot;' />;
<div id={'\\'"&quot;<>&amp;quot;'} />;
<div id='123' />;
<div id='&#39;"' />;
<div id={"'\\"\\\\'"} />;
<div
single='foo'
single2={'foo'}
double='bar'
double2={'bar'}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={'\\'"'}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={'\\' "'}
singleBoth3="' ' &quot;"
doubleBoth='" &apos;'
doubleBoth2={'" \\''}
doubleBoth3="&quot; ' '"
/>;
<p>
GitHub Desktop has encountered an unrecoverable error and will need to 1231231
restart. This has been reported to the team, but if youencounter this121312331
repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '}
</p>;
================================================================================
`;
+16
View File
@@ -0,0 +1,16 @@
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: false,
jsxSingleQuote: false,
});
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: false,
jsxSingleQuote: true,
});
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: true,
jsxSingleQuote: false,
});
runFormatTest(import.meta, ["babel", "typescript", "flow"], {
singleQuote: true,
jsxSingleQuote: true,
});
File renamed without changes.