Skip to content

Commit

Permalink
add all tests for previously committed fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thysultan committed Aug 21, 2024
1 parent 014c446 commit 8c9f0ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 17 additions & 1 deletion test/Parser.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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(`
Expand Down
6 changes: 5 additions & 1 deletion test/Prefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(''))
Expand Down Expand Up @@ -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(''))
Expand Down

0 comments on commit 8c9f0ca

Please sign in to comment.