stylance crate tests loading real css modules.
This commit is contained in:
parent
39ef856af8
commit
8eb717604f
|
@ -0,0 +1,52 @@
|
||||||
|
use stylance::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test() {
|
||||||
|
import_crate_style!(style, "tests/style.module.scss");
|
||||||
|
|
||||||
|
assert_eq!(style::style1, "style1-a331da9");
|
||||||
|
assert_eq!(style::style2, "style2-a331da9");
|
||||||
|
assert_eq!(style::style3, "style3-a331da9");
|
||||||
|
assert_eq!(style::style4, "style4-a331da9");
|
||||||
|
assert_eq!(style::style5, "style5-a331da9");
|
||||||
|
assert_eq!(style::style6, "style6-a331da9");
|
||||||
|
|
||||||
|
assert_eq!(style::style_with_dashes, "style-with-dashes-a331da9");
|
||||||
|
assert_eq!(style::nested_style, "nested-style-a331da9");
|
||||||
|
|
||||||
|
mod some_module {
|
||||||
|
stylance::import_crate_style!(pub style, "tests/style.module.scss");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(some_module::style::style1, "style1-a331da9");
|
||||||
|
|
||||||
|
import_crate_style!(style2, "tests/style2.module.scss");
|
||||||
|
assert_eq!(style2::style1, "style1-58ea9e3");
|
||||||
|
assert_eq!(style2::different_style, "different-style-58ea9e3");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "nightly")]
|
||||||
|
#[test]
|
||||||
|
fn test_nightly() {
|
||||||
|
import_style!(style, "style.module.scss");
|
||||||
|
|
||||||
|
assert_eq!(style::style1, "style1-a331da9");
|
||||||
|
assert_eq!(style::style2, "style2-a331da9");
|
||||||
|
assert_eq!(style::style3, "style3-a331da9");
|
||||||
|
assert_eq!(style::style4, "style4-a331da9");
|
||||||
|
assert_eq!(style::style5, "style5-a331da9");
|
||||||
|
assert_eq!(style::style6, "style6-a331da9");
|
||||||
|
|
||||||
|
assert_eq!(style::style_with_dashes, "style-with-dashes-a331da9");
|
||||||
|
assert_eq!(style::nested_style, "nested-style-a331da9");
|
||||||
|
|
||||||
|
mod some_module {
|
||||||
|
stylance::import_style!(pub style, "style.module.scss");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(some_module::style::style1, "style1-a331da9");
|
||||||
|
|
||||||
|
import_style!(style2, "style2.module.scss");
|
||||||
|
assert_eq!(style2::style1, "style1-58ea9e3");
|
||||||
|
assert_eq!(style2::different_style, "different-style-58ea9e3");
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
@charset "utf-8";
|
||||||
|
|
||||||
|
// Line comment
|
||||||
|
|
||||||
|
/* block comment
|
||||||
|
.class {
|
||||||
|
{ // Invalid syntax inside the comment to ensure this isn't parsed.
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.style1.style2[value="thing"] {
|
||||||
|
color: red; // line comment after declaration
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.style-with-dashes {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.style3 {
|
||||||
|
background-color: #87ceeb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "Trickster";
|
||||||
|
src:
|
||||||
|
local("Trickster"),
|
||||||
|
url("trickster-COLRv1.otf") format("opentype") tech(color-COLRv1),
|
||||||
|
url("trickster-outline.otf") format("opentype"),
|
||||||
|
url("trickster-outline.woff") format("woff");
|
||||||
|
}
|
||||||
|
|
||||||
|
.style4 {
|
||||||
|
.nested-style {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
// scss style nested media query with declarations inside
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.global-class) {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.style5 // comment in between selector
|
||||||
|
|
||||||
|
.style6
|
||||||
|
|
||||||
|
/* comment in between selector */
|
||||||
|
.style7 {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.style1 {
|
||||||
|
// Repeated style
|
||||||
|
color: blue;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
.style1 {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.different-style {
|
||||||
|
color: red;
|
||||||
|
}
|
Loading…
Reference in New Issue