From f80515bfb353f04c0191b2a1936a72a3ef1314ae Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Fri, 18 Oct 2024 11:14:54 +0200 Subject: [PATCH] increase test coverage --- plugin-packs/postcss-bundler/test/_tape.mjs | 6 ++++++ .../test/conditional-layer-before-external.css | 1 + .../conditional-layer-before-external.expect.css | 14 ++++++++++++++ .../test/imports/layer-before-external.css | 8 ++++++++ .../postcss-bundler/test/layer-before-external.css | 8 ++++++++ .../test/layer-before-external.expect.css | 7 +++++++ 6 files changed, 44 insertions(+) create mode 100644 plugin-packs/postcss-bundler/test/conditional-layer-before-external.css create mode 100644 plugin-packs/postcss-bundler/test/conditional-layer-before-external.expect.css create mode 100644 plugin-packs/postcss-bundler/test/imports/layer-before-external.css create mode 100644 plugin-packs/postcss-bundler/test/layer-before-external.css create mode 100644 plugin-packs/postcss-bundler/test/layer-before-external.expect.css diff --git a/plugin-packs/postcss-bundler/test/_tape.mjs b/plugin-packs/postcss-bundler/test/_tape.mjs index 64a686d21..7d48dda51 100644 --- a/plugin-packs/postcss-bundler/test/_tape.mjs +++ b/plugin-packs/postcss-bundler/test/_tape.mjs @@ -15,6 +15,9 @@ const testCases = { message: 'errors on mismatched charset', exception: /Incompatible @charset statements/, }, + 'conditional-layer-before-external': { + message: 'correctly handles conditional stylesheets containing layer statements before external resources', + }, 'does-not-exist-1': { message: 'throws on files that don\'t exist', exception: /Failed to find 'imports\/does-not-exist.css'/, @@ -27,6 +30,9 @@ const testCases = { message: 'ignores incorrect syntax', warnings: 4, }, + 'layer-before-external': { + message: 'correctly handles layer statements before external resources', + }, 'regexp': { message: 'regexp sanity checks', warnings: 2, diff --git a/plugin-packs/postcss-bundler/test/conditional-layer-before-external.css b/plugin-packs/postcss-bundler/test/conditional-layer-before-external.css new file mode 100644 index 000000000..37189a5ce --- /dev/null +++ b/plugin-packs/postcss-bundler/test/conditional-layer-before-external.css @@ -0,0 +1 @@ +@import "imports/layer-before-external.css" (min-width: 300px); diff --git a/plugin-packs/postcss-bundler/test/conditional-layer-before-external.expect.css b/plugin-packs/postcss-bundler/test/conditional-layer-before-external.expect.css new file mode 100644 index 000000000..146deb2f6 --- /dev/null +++ b/plugin-packs/postcss-bundler/test/conditional-layer-before-external.expect.css @@ -0,0 +1,14 @@ +/* imports/layer-before-external.css */ + +@import 'data:text/css;base64,QGxheWVyIHJlc2V0LCBib290c3RyYXA=' (min-width: 300px); + +@import 'data:text/css;base64,QGltcG9ydCB1cmwoJ2h0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vYm9vdHN0cmFwQDUuMy4wL2Rpc3QvY3NzL2Jvb3RzdHJhcC5jc3MnKSAobWluLXdpZHRoOiAzMDBweCk=' layer(bootstrap); + +@media (min-width: 300px){ + +@layer reset { + h1 { + margin-top: 100px; + } +} +} diff --git a/plugin-packs/postcss-bundler/test/imports/layer-before-external.css b/plugin-packs/postcss-bundler/test/imports/layer-before-external.css new file mode 100644 index 000000000..f45a824e2 --- /dev/null +++ b/plugin-packs/postcss-bundler/test/imports/layer-before-external.css @@ -0,0 +1,8 @@ +@layer reset, bootstrap; +@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.css') layer(bootstrap); + +@layer reset { + h1 { + margin-top: 100px; + } +} diff --git a/plugin-packs/postcss-bundler/test/layer-before-external.css b/plugin-packs/postcss-bundler/test/layer-before-external.css new file mode 100644 index 000000000..f45a824e2 --- /dev/null +++ b/plugin-packs/postcss-bundler/test/layer-before-external.css @@ -0,0 +1,8 @@ +@layer reset, bootstrap; +@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.css') layer(bootstrap); + +@layer reset { + h1 { + margin-top: 100px; + } +} diff --git a/plugin-packs/postcss-bundler/test/layer-before-external.expect.css b/plugin-packs/postcss-bundler/test/layer-before-external.expect.css new file mode 100644 index 000000000..6b76c9777 --- /dev/null +++ b/plugin-packs/postcss-bundler/test/layer-before-external.expect.css @@ -0,0 +1,7 @@ +@layer reset, bootstrap; +@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.css') layer(bootstrap); +@layer reset { + h1 { + margin-top: 100px; + } +}