From 8c9f0cae6999db3dcf172392a73165ccdceb45c7 Mon Sep 17 00:00:00 2001 From: Sultan <810601+thysultan@users.noreply.github.com> Date: Wed, 21 Aug 2024 21:55:58 +0300 Subject: [PATCH] add all tests for previously committed fixes --- test/Parser.js | 18 +++++++++++++++++- test/Prefixer.js | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/test/Parser.js b/test/Parser.js index 91876cf..c717bb1 100644 --- a/test/Parser.js +++ b/test/Parser.js @@ -1,6 +1,6 @@ import {compile, serialize, stringify} from "../index.js" -const stylis = string => serialize(compile(`.user{${string}}`), stringify) +const stylis = (declarations, selectors = '.user') => serialize(compile(`${selectors}{${declarations}}`), stringify) describe('Parser', () => { test('unnested', () => { @@ -142,6 +142,22 @@ describe('Parser', () => { ).to.equal(`.user [href="https://css-tricks.com?a=1&b=2"]{color:red;}`) }) + test('& no-op', () => { + expect( + stylis(` + color:red; + `, '&') + ).to.equal(`&{color:red;}`) + }) + + test('noop removal of empty variables', () => { + expect( + stylis(` + --tw-brightness:/*!*/; + `, '&') + ).to.equal(`&{--tw-brightness:;}`) + }) + test('& in first selector within a comma-separated list', () => { expect( stylis(` diff --git a/test/Prefixer.js b/test/Prefixer.js index ffb361d..4988608 100644 --- a/test/Prefixer.js +++ b/test/Prefixer.js @@ -25,7 +25,7 @@ describe('Prefixer', () => { expect(prefix(`justify-content:flex-end;`, 15)).to.equal([`-webkit-box-pack:end;`, `-ms-flex-pack:end;`, `-webkit-justify-content:flex-end;`, `justify-content:flex-end;`].join('')) expect(prefix(`justify-content:flex-start;`, 15)).to.equal([`-webkit-box-pack:start;`, `-ms-flex-pack:start;`, `-webkit-justify-content:flex-start;`, `justify-content:flex-start;`].join('')) expect(prefix(`justify-content:justify;`, 15)).to.equal([`-webkit-box-pack:justify;`, `-ms-flex-pack:justify;`, `-webkit-justify-content:justify;`, `justify-content:justify;`].join('')) - expect(prefix(`justify-content:space-between;`, 15)).to.equal([`-webkit-box-pack:justify;`, `-webkit-justify-content:space-between;`, `justify-content:space-between;`].join('')) + expect(prefix(`justify-content:space-between;`, 15)).to.equal([`-webkit-box-pack:justify;`, '-ms-flex-pack:space-between;', `-webkit-justify-content:space-between;`, `justify-content:space-between;`].join('')) expect(prefix(`justify-items:center;`, 13)).to.equal([`justify-items:center;`].join('')) expect(prefix(`order:flex;`, 5)).to.equal([`-webkit-order:flex;`, `-ms-flex-order:flex;`, `order:flex;`].join('')) expect(prefix(`flex-direction:column;`, 14)).to.equal([`-webkit-flex-direction:column;`, `-ms-flex-direction:column;`, `flex-direction:column;`].join('')) @@ -177,6 +177,10 @@ describe('Prefixer', () => { expect(prefix(`background-clip:text;`, 15)).to.equal([`-webkit-background-clip:text;`, `background-clip:text;`].join('')) }) + test('backdrop-filter', () => { + expect(prefix(`backdrop-filter:none;`, 15)).to.equal([`-webkit-backdrop-filter:none;`, `backdrop-filter:none;`].join('')) + }) + test('margin-inline', () => { expect(prefix(`margin-inline-start:20px;`, 19)).to.equal([`-webkit-margin-start:20px;`, `margin-inline-start:20px;`].join('')) expect(prefix(`margin-inline-end:20px;`, 17)).to.equal([`-webkit-margin-end:20px;`, `margin-inline-end:20px;`].join(''))