@@ -1925,4 +1925,103 @@ mod tests {
19251925 sheet. update_styles ( & output. styles , "index.tsx" , true ) ;
19261926 assert_debug_snapshot ! ( sheet. create_css( None , true ) . split( "*/" ) . nth( 1 ) . unwrap( ) ) ;
19271927 }
1928+
1929+ #[ test]
1930+ fn test_update_styles_with_typography ( ) {
1931+ use extractor:: extract_style:: extract_style_value:: ExtractStyleValue ;
1932+
1933+ let mut sheet = StyleSheet :: default ( ) ;
1934+ let mut styles = HashSet :: new ( ) ;
1935+ styles. insert ( ExtractStyleValue :: Typography ( "$heading" . to_string ( ) ) ) ;
1936+ let ( collected, updated) = sheet. update_styles ( & styles, "index.tsx" , true ) ;
1937+ // Typography doesn't collect or update
1938+ assert ! ( !collected) ;
1939+ assert ! ( !updated) ;
1940+ }
1941+
1942+ #[ test]
1943+ fn test_global_props_with_breakpoints ( ) {
1944+ let mut sheet = StyleSheet :: default ( ) ;
1945+ // Add global style at level 1 (with breakpoint)
1946+ sheet. add_property (
1947+ "a" ,
1948+ "color" ,
1949+ 1 , // level 1 means it should be wrapped in @media
1950+ "red" ,
1951+ Some ( & StyleSelector :: Global (
1952+ "body" . to_string ( ) ,
1953+ "test.tsx" . to_string ( ) ,
1954+ ) ) ,
1955+ Some ( 0 ) ,
1956+ None ,
1957+ ) ;
1958+ let css = sheet. create_css ( None , false ) ;
1959+ assert ! ( css. contains( "@media" ) ) ;
1960+ assert ! ( css. contains( "body" ) ) ;
1961+ assert_debug_snapshot ! ( css. split( "*/" ) . nth( 1 ) . unwrap( ) ) ;
1962+ }
1963+
1964+ #[ test]
1965+ fn test_at_rules_with_breakpoints ( ) {
1966+ let mut sheet = StyleSheet :: default ( ) ;
1967+ // Add @supports with breakpoint (level 1)
1968+ sheet. add_property (
1969+ "a" ,
1970+ "display" ,
1971+ 1 ,
1972+ "grid" ,
1973+ Some ( & StyleSelector :: At {
1974+ kind : AtRuleKind :: Supports ,
1975+ query : "(display: grid)" . to_string ( ) ,
1976+ selector : None ,
1977+ } ) ,
1978+ Some ( 0 ) ,
1979+ None ,
1980+ ) ;
1981+ let css = sheet. create_css ( None , false ) ;
1982+ assert ! ( css. contains( "@media" ) ) ;
1983+ assert ! ( css. contains( "@supports" ) ) ;
1984+ assert_debug_snapshot ! ( css. split( "*/" ) . nth( 1 ) . unwrap( ) ) ;
1985+ }
1986+
1987+ #[ test]
1988+ fn test_container_with_breakpoints ( ) {
1989+ let mut sheet = StyleSheet :: default ( ) ;
1990+ // Add @container with breakpoint (level 1)
1991+ sheet. add_property (
1992+ "a" ,
1993+ "width" ,
1994+ 1 ,
1995+ "100%" ,
1996+ Some ( & StyleSelector :: At {
1997+ kind : AtRuleKind :: Container ,
1998+ query : "(min-width: 400px)" . to_string ( ) ,
1999+ selector : None ,
2000+ } ) ,
2001+ Some ( 0 ) ,
2002+ None ,
2003+ ) ;
2004+ let css = sheet. create_css ( None , false ) ;
2005+ assert ! ( css. contains( "@media" ) ) ;
2006+ assert ! ( css. contains( "@container" ) ) ;
2007+ assert_debug_snapshot ! ( css. split( "*/" ) . nth( 1 ) . unwrap( ) ) ;
2008+ }
2009+
2010+ #[ test]
2011+ fn test_theme_layer_in_css ( ) {
2012+ let mut sheet = StyleSheet :: default ( ) ;
2013+ let mut theme = Theme :: default ( ) ;
2014+ let mut color_theme = ColorTheme :: default ( ) ;
2015+ color_theme. add_color ( "primary" , "#000" ) ;
2016+ theme. add_color_theme ( "default" , color_theme) ;
2017+ sheet. set_theme ( theme) ;
2018+
2019+ // Add some regular styles to trigger layer output
2020+ sheet. add_property ( "a" , "color" , 0 , "blue" , None , Some ( 0 ) , None ) ;
2021+
2022+ let css = sheet. create_css ( None , false ) ;
2023+ assert ! ( css. contains( "@layer" ) ) ;
2024+ assert ! ( css. contains( "@layer t{" ) ) ;
2025+ assert_debug_snapshot ! ( css. split( "*/" ) . nth( 1 ) . unwrap( ) ) ;
2026+ }
19282027}
0 commit comments