-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show error messages for nested mixins which can not be extracted
- Loading branch information
Showing
11 changed files
with
501 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import quasiClassifier from '../lib/quasiClassifier.cjs'; | ||
import { describe, it, expect } from "vitest"; | ||
|
||
describe('quasiClassifier', () => { | ||
it('should classify empty quasi', () => { | ||
expect(quasiClassifier('', [])).toEqual({ | ||
empty: true, | ||
unknownSelector: false, | ||
insideCssValue: false, | ||
currentNestingScopes: [], | ||
}); | ||
}); | ||
it("should recognize a comment as empty", () => { | ||
expect(quasiClassifier("/* comment */", [])).toEqual({ | ||
empty: true, | ||
unknownSelector: false, | ||
insideCssValue: false, | ||
currentNestingScopes: [], | ||
}); | ||
}); | ||
it("should find incomplete css - unknownSelector", () => { | ||
expect(quasiClassifier("{ color: blue;", [])).toEqual({ | ||
empty: false, | ||
unknownSelector: true, | ||
insideCssValue: false, | ||
currentNestingScopes: [], | ||
}); | ||
}); | ||
it("should find incomplete css - insideCssValue", () => { | ||
expect(quasiClassifier("color: ", [ | ||
".foo" | ||
])).toEqual({ | ||
empty: false, | ||
unknownSelector: false, | ||
insideCssValue: true, | ||
currentNestingScopes: [".foo"], | ||
}); | ||
}); | ||
it("should find incomplete css - insideCssValue after a media query", () => { | ||
expect(quasiClassifier("} .foo { color: ", [ | ||
"@media (min-width: 640px)" | ||
])).toEqual({ | ||
empty: false, | ||
unknownSelector: false, | ||
insideCssValue: true, | ||
currentNestingScopes: [".foo"], | ||
}); | ||
}); | ||
it("should find incomplete css - insideCssValue in a multi value", () => { | ||
expect(quasiClassifier("} .foo { transition: 200ms ", [ | ||
"@media (min-width: 640px)" | ||
])).toEqual({ | ||
empty: false, | ||
unknownSelector: false, | ||
insideCssValue: true, | ||
currentNestingScopes: [".foo"], | ||
}); | ||
}); | ||
it("should find nesting scopes", () => { | ||
expect(quasiClassifier(` | ||
.foo { | ||
.bar { | ||
@supports (display: grid) { | ||
`, [ | ||
"@media (min-width: 640px)" | ||
])).toEqual({ | ||
empty: false, | ||
unknownSelector: false, | ||
insideCssValue: false, | ||
currentNestingScopes: [ | ||
"@media (min-width: 640px)", | ||
".foo", | ||
".bar", | ||
"@supports (display: grid)", | ||
], | ||
}); | ||
}); | ||
it("should find nesting scopes with properties", () => { | ||
expect(quasiClassifier(` | ||
.foo { | ||
color: purple; | ||
.x { | ||
color: green; | ||
} | ||
.bar { | ||
color: orange; | ||
@supports (display: grid) { | ||
color: blue; | ||
`, [ | ||
"@media (min-width: 640px)" | ||
])).toEqual({ | ||
empty: false, | ||
unknownSelector: false, | ||
insideCssValue: false, | ||
currentNestingScopes: [ | ||
"@media (min-width: 640px)", | ||
".foo", | ||
".bar", | ||
"@supports (display: grid)", | ||
], | ||
}); | ||
}); | ||
|
||
it("should find nesting scopes with properties and closing nestings", () => { | ||
expect(quasiClassifier(` | ||
.foo { | ||
/* }}}}} */ | ||
color: purple; | ||
.x { | ||
color: green; | ||
} | ||
.bar { | ||
:before { | ||
content: '{'; | ||
} | ||
color: orange; | ||
@supports (display: grid) { | ||
color: blue; | ||
} | ||
} | ||
`, [ | ||
"@media (min-width: 640px)" | ||
])).toEqual({ | ||
empty: false, | ||
unknownSelector: false, | ||
insideCssValue: false, | ||
currentNestingScopes: [ | ||
"@media (min-width: 640px)", | ||
".foo", | ||
], | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.