From 655a161d0f96dbacb8de6921b840643369e98fcc Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 25 Nov 2022 10:52:47 +0800 Subject: [PATCH] Add tests for multiple comments (#13890) Close https://github.com/prettier/prettier/issues/3105 --- .../comments/__snapshots__/jsfmt.spec.js.snap | 49 +++++++++++++++++++ tests/format/js/comments/multi-comments-2.js | 6 +++ 2 files changed, 55 insertions(+) create mode 100644 tests/format/js/comments/multi-comments-2.js diff --git a/tests/format/js/comments/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/comments/__snapshots__/jsfmt.spec.js.snap index 7078a9076e6b..9c21079b109f 100644 --- a/tests/format/js/comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/comments/__snapshots__/jsfmt.spec.js.snap @@ -3808,6 +3808,55 @@ y; ================================================================================ `; +exports[`multi-comments-2.js - {"semi":false} format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 +semi: false + | printWidth +=====================================input====================================== + const x = 0; + + /* istanbul ignore if */ // debug case currently not triggered + if (true) { + x; + } + +=====================================output===================================== +const x = 0 + +/* istanbul ignore if */ // debug case currently not triggered +if (true) { + x +} + +================================================================================ +`; + +exports[`multi-comments-2.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== + const x = 0; + + /* istanbul ignore if */ // debug case currently not triggered + if (true) { + x; + } + +=====================================output===================================== +const x = 0; + +/* istanbul ignore if */ // debug case currently not triggered +if (true) { + x; +} + +================================================================================ +`; + exports[`multi-comments-on-same-line.js - {"semi":false} format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] diff --git a/tests/format/js/comments/multi-comments-2.js b/tests/format/js/comments/multi-comments-2.js new file mode 100644 index 000000000000..a6e34e549a6d --- /dev/null +++ b/tests/format/js/comments/multi-comments-2.js @@ -0,0 +1,6 @@ + const x = 0; + + /* istanbul ignore if */ // debug case currently not triggered + if (true) { + x; + }