From a52f369e56874dc3dede2139832d7ac950fe4bd1 Mon Sep 17 00:00:00 2001 From: linzhe141 <1572213544@qq.com> Date: Thu, 12 Sep 2024 17:00:44 +0800 Subject: [PATCH] chore: update test --- .../__tests__/compileStyle.spec.ts | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/compiler-sfc/__tests__/compileStyle.spec.ts b/packages/compiler-sfc/__tests__/compileStyle.spec.ts index fbcbc2cc4c0..b76414364dc 100644 --- a/packages/compiler-sfc/__tests__/compileStyle.spec.ts +++ b/packages/compiler-sfc/__tests__/compileStyle.spec.ts @@ -42,26 +42,35 @@ describe('SFC scoped CSS', () => { }) test('nesting selector', () => { + expect(compileScoped(`h1 { color: red; .foo { color: red; } }`)).toMatch( + `h1 {\n&[data-v-test] { color: red;\n}\n.foo[data-v-test] { color: red;`, + ) + }) + + test('nesting selector with atrule and comment', () => { expect( compileScoped( - 'h1 {\n' + - ' color: red;\n' + - ' /**background-color: pink; */\n' + - ' @media only screen and (max-width: 800px) {\n' + - ' background-color: green;\n' + - ' }\n' + - ' .foo { color: red; }\n' + - '}', + `h1 { +color: red; +/*background-color: pink;*/ +@media only screen and (max-width: 800px) { + background-color: green; + .bar { color: white } +} +.foo { color: red; } +}`, ), ).toMatch( `h1 { &[data-v-test] { - color: red; - /**background-color: pink; */ +color: red +/*background-color: pink;*/ } @media only screen and (max-width: 800px) { &[data-v-test] { - background-color: green; + background-color: green +} +.bar[data-v-test] { color: white } } .foo[data-v-test] { color: red;