From ebd3e43c89e6e0338fa286a5c57ceeb4dca94b2c Mon Sep 17 00:00:00 2001 From: Maytham <44939173+Maytha8@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:14:44 +0800 Subject: [PATCH] chore: add test for preserveUnusedSelector compile option --- .../preserve-unused-selector/_config.js | 30 +++++++++++++++++++ .../preserve-unused-selector/expected.css | 1 + .../preserve-unused-selector/expected.html | 1 + .../preserve-unused-selector/input.svelte | 11 +++++++ 4 files changed, 43 insertions(+) create mode 100644 packages/svelte/test/css/samples/preserve-unused-selector/_config.js create mode 100644 packages/svelte/test/css/samples/preserve-unused-selector/expected.css create mode 100644 packages/svelte/test/css/samples/preserve-unused-selector/expected.html create mode 100644 packages/svelte/test/css/samples/preserve-unused-selector/input.svelte diff --git a/packages/svelte/test/css/samples/preserve-unused-selector/_config.js b/packages/svelte/test/css/samples/preserve-unused-selector/_config.js new file mode 100644 index 000000000000..8bf5058a9813 --- /dev/null +++ b/packages/svelte/test/css/samples/preserve-unused-selector/_config.js @@ -0,0 +1,30 @@ +export default { + compileOptions: { + preserveUnusedSelectors: true + }, + warnings: [ + { + filename: 'SvelteComponent.svelte', + code: 'css-unused-selector', + message: 'Unused CSS selector ".bar"', + start: { + line: 8, + column: 1, + character: 60 + }, + end: { + line: 8, + column: 5, + character: 64 + }, + pos: 60, + frame: ` + 6: } + 7: + 8: .bar { + ^ + 9: color: blue; + 10: }` + } + ] +}; diff --git a/packages/svelte/test/css/samples/preserve-unused-selector/expected.css b/packages/svelte/test/css/samples/preserve-unused-selector/expected.css new file mode 100644 index 000000000000..5633dd783fdd --- /dev/null +++ b/packages/svelte/test/css/samples/preserve-unused-selector/expected.css @@ -0,0 +1 @@ +.foo.svelte-xyz{color:red}.bar{color:blue} \ No newline at end of file diff --git a/packages/svelte/test/css/samples/preserve-unused-selector/expected.html b/packages/svelte/test/css/samples/preserve-unused-selector/expected.html new file mode 100644 index 000000000000..cfad41216efe --- /dev/null +++ b/packages/svelte/test/css/samples/preserve-unused-selector/expected.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/packages/svelte/test/css/samples/preserve-unused-selector/input.svelte b/packages/svelte/test/css/samples/preserve-unused-selector/input.svelte new file mode 100644 index 000000000000..1d62e3a67577 --- /dev/null +++ b/packages/svelte/test/css/samples/preserve-unused-selector/input.svelte @@ -0,0 +1,11 @@ + + + \ No newline at end of file