Skip to content

Commit

Permalink
extend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Veneman committed Dec 13, 2023
1 parent 7b55ea2 commit 876bb0e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 139 deletions.
52 changes: 45 additions & 7 deletions test/rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Rules("formats Raw rule prelude", () => {
assert.equal(actual, expected);
});

Rules('formats nested rules with selectors containing & and more', () => {
Rules('formats nested rules with selectors starting with', () => {
let actual = format(`
selector {
& > item {
Expand All @@ -151,28 +151,66 @@ Rules('formats nested rules with selectors containing & and more', () => {
assert.equal(actual, expected);
})

Rules("formats nested rules with a selector starting with & and containing an attribute selector", () => {
Rules("formats nested rules with a selector starting with &", () => {
let actual = format(`
selector {
& [data-theme] { color: red; }
& a { color: red; }
}
`)
let expected = `selector {
& [data-theme] {
& a {
color: red;
}
}`;
assert.equal(actual, expected);
})

Rules("formats nested rules with a selector starting with & and containing an attribute selector", () => {
Rules("formats nested rules with a selector with a &", () => {
let actual = format(`
selector {
[data-theme] & { color:red }
a & { color:red }
}
`)
let expected = `selector {
[data-theme] & {
a & {
color: red;
}
}`;
assert.equal(actual, expected);
})

Rules("formats nested rules with a selector without a &", () => {
let actual = format(`
selector {
a { color:red }
}
`)
let expected = `selector {
a {
color: red;
}
}`;
assert.equal(actual, expected);
})

Rules("formats nested rules with a selector starting with a selector combinator", () => {
let actual = format(`
selector {
> a { color:red }
~ a { color:red }
+ a { color:red }
}
`)
let expected = `selector {
> a {
color: red;
}
~ a {
color: red;
}
+ a {
color: red;
}
}`;
Expand Down
132 changes: 0 additions & 132 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,136 +51,4 @@ html {
assert.equal(actual, expected);
});

Stylesheet("css nesting chaos", () => {
let actual = format(`
/**
* Comment!
*/
no-layer-1, no-layer-2 { color: red; font-size: 1rem; COLOR: green; }
@layer components, deep;
@layer base { layer-base { color: green; } }
@layer { @layer named { anon-named { line-height: 1 } }}
@media (min-width: 1000px) {
@layer desktop { layer-desktop { color: blue; } }
@layer { layer-anon, no-2 { line-height: 1; } }
@layer test {}
@supports (min-width: 1px) {
@layer deep { layer-deep {} }
}
}
test { line-height: 1}
@layer components {
@layer alert {}
@layer table {
@layer tbody, thead;
layer-components-table { color: yellow; }
@layer tbody { tbody { border: 1px solid; background: red; } }
@media (min-width: 30em) {
@supports (display: grid) {
@layer thead { thead { border: 1px solid; } }
}
}
}
}
@layer components.breadcrumb { layer-components-breadcrumb { } }
@font-face {
font-family: "Test";
src: url(some-url.woff2);
}
;;;;;;;;;;;;;;;;;;;
`);
let expected = `no-layer-1,
no-layer-2 {
color: red;
font-size: 1rem;
color: green;
}
@layer components, deep;
@layer base {
layer-base {
color: green;
}
}
@layer {
@layer named {
anon-named {
line-height: 1;
}
}
}
@media (min-width: 1000px) {
@layer desktop {
layer-desktop {
color: blue;
}
}
@layer {
layer-anon,
no-2 {
line-height: 1;
}
}
@layer test {}
@supports (min-width: 1px) {
@layer deep {
layer-deep {}
}
}
}
test {
line-height: 1;
}
@layer components {
@layer alert {}
@layer table {
@layer tbody, thead;
layer-components-table {
color: yellow;
}
@layer tbody {
tbody {
border: 1px solid;
background: red;
}
}
@media (min-width: 30em) {
@supports (display: grid) {
@layer thead {
thead {
border: 1px solid;
}
}
}
}
}
}
@layer components.breadcrumb {
layer-components-breadcrumb {}
}
@font-face {
font-family: "Test";
src: url(some-url.woff2);
}
;;;;;;;;;;;;;;;;;;;`;
assert.equal(actual, expected);
});

Stylesheet.run();

0 comments on commit 876bb0e

Please sign in to comment.