@@ -750,6 +750,70 @@ def test_grid_template_invalid(rule):
750
750
assert_invalid (f'grid-template: { rule } ' )
751
751
752
752
753
+ @assert_no_logs
754
+ @pytest .mark .parametrize ('rule, result' , (
755
+ ('none' , {
756
+ 'template_rows' : 'none' , 'template_columns' : 'none' ,
757
+ 'template_areas' : 'none' ,
758
+ 'auto_rows' : ('auto' ,), 'auto_columns' : ('auto' ,),
759
+ 'auto_flow' : ('row' ,),
760
+ }),
761
+ ('subgrid / [outer-edge] 20px [main-start]' , {
762
+ 'template_rows' : ('subgrid' , ()),
763
+ 'template_columns' : (('outer-edge' ,), (20 , 'px' ), ('main-start' ,)),
764
+ 'template_areas' : 'none' ,
765
+ 'auto_rows' : ('auto' ,), 'auto_columns' : ('auto' ,),
766
+ 'auto_flow' : ('row' ,),
767
+ }),
768
+ ('repeat(2, [e] 40px) repeat(5, auto) / subgrid [a] repeat(auto-fill, [b])' , {
769
+ 'template_rows' : (
770
+ (), ('repeat()' , 2 , (('e' ,), (40 , 'px' ), ())), (),
771
+ ('repeat()' , 5 , ((), 'auto' , ())), ()),
772
+ 'template_columns' : ('subgrid' , (('a' ,), ('repeat()' , 'auto-fill' , (('b' ,),)))),
773
+ 'template_areas' : 'none' ,
774
+ 'auto_rows' : ('auto' ,), 'auto_columns' : ('auto' ,),
775
+ 'auto_flow' : ('row' ,),
776
+ }),
777
+ ('auto-flow 1fr / 100px' , {
778
+ 'template_rows' : 'none' , 'template_columns' : ((), (100 , 'px' ), ()),
779
+ 'template_areas' : 'none' ,
780
+ 'auto_rows' : ((1 , 'fr' ),), 'auto_columns' : ('auto' ,),
781
+ 'auto_flow' : ('row' ,),
782
+ }),
783
+ ('none / dense auto-flow 1fr' , {
784
+ 'template_rows' : 'none' , 'template_columns' : 'none' ,
785
+ 'template_areas' : 'none' ,
786
+ 'auto_rows' : ('auto' ,), 'auto_columns' : ((1 , 'fr' ),),
787
+ 'auto_flow' : ('column' , 'dense' ),
788
+ }),
789
+ # TODO: support last grid-template syntax
790
+ # ('[a b] "x y y" [c] [d] "x y y" 1fr [e] / auto 2fr auto', {
791
+ # }),
792
+ # ('[a b c] "x x x" 2fr', {
793
+ # }),
794
+ ))
795
+ def test_grid (rule , result ):
796
+ assert expand_to_dict (f'grid: { rule } ' ) == dict (
797
+ (f'grid_{ key } ' , value ) for key , value in result .items ())
798
+
799
+
800
+ @assert_no_logs
801
+ @pytest .mark .parametrize ('rule' , (
802
+ 'none none' ,
803
+ 'auto' ,
804
+ 'subgrid / subgrid / subgrid' ,
805
+ '[a] 1px [b] / none /' ,
806
+ '[a] 1px [b] // none' ,
807
+ '[a] 1px [b] none' ,
808
+ 'none / auto-flow 1fr dense' ,
809
+ 'none / dense 1fr auto-flow' ,
810
+ '100px auto-flow / none' ,
811
+ 'dense 100px / auto-flow 1fr'
812
+ ))
813
+ def test_grid_invalid (rule ):
814
+ assert_invalid (f'grid: { rule } ' )
815
+
816
+
753
817
@assert_no_logs
754
818
@pytest .mark .parametrize ('rule, result' , (
755
819
('page-break-after: left' , {'break_after' : 'left' }),
0 commit comments