@@ -880,3 +880,89 @@ describe('md-themable directive', function() {
880
880
expect ( el . hasClass ( 'md-default-theme' ) ) . toBe ( true ) ;
881
881
} ) ) ;
882
882
} ) ;
883
+
884
+ describe ( '$mdThemeProvider with custom styles that include nested rules' , function ( ) {
885
+ it ( 'appends the custom styles taking into account nesting' , function ( ) {
886
+ module ( 'material.core' , function ( $mdThemingProvider ) {
887
+ $mdThemingProvider . generateThemesOnDemand ( false ) ;
888
+ var styles =
889
+ "@media (min-width: 0) and (max-width: 700px) {\n\n"
890
+ + " .md-THEME_NAME-theme .layout-row {\n"
891
+ + " background-color: {{primary-500}};\n"
892
+ + " }\n\n"
893
+ + " .md-THEME_NAME-theme .layout-column {\n"
894
+ + " color: blue;\n"
895
+ + " font-weight: bold;\n"
896
+ + " }\n"
897
+ + "}\n" ;
898
+
899
+ $mdThemingProvider . registerStyles ( styles ) ;
900
+ $mdThemingProvider . theme ( 'register-custom-nested-styles' ) ;
901
+ } ) ;
902
+
903
+ inject ( function ( $MD_THEME_CSS ) {
904
+ // Verify that $MD_THEME_CSS is still set to '/**/' in the test environment.
905
+ // Check angular-material-mocks.js for $MD_THEME_CSS latest value if this test starts to fail.
906
+ expect ( $MD_THEME_CSS ) . toBe ( '/**/' ) ;
907
+ } ) ;
908
+
909
+ var compiledStyles =
910
+ "@media (min-width: 0) and (max-width: 700px) {\n\n"
911
+ + " .md-register-custom-nested-styles-theme .layout-row {\n"
912
+ + " background-color: rgb(63,81,181);\n"
913
+ + " }\n\n"
914
+ + " .md-register-custom-nested-styles-theme .layout-column {\n"
915
+ + " color: blue;\n"
916
+ + " font-weight: bold;\n"
917
+ + " }\n"
918
+ + "}" ;
919
+
920
+ // Find the string containing nested rules in the head tag.
921
+ expect ( document . head . innerHTML ) . toContain ( compiledStyles ) ;
922
+ } ) ;
923
+ } ) ;
924
+
925
+ describe ( '$mdThemeProvider with custom styles that include multiple nested rules' , function ( ) {
926
+ it ( 'appends the custom styles taking into account multiple nesting' , function ( ) {
927
+ module ( 'material.core' , function ( $mdThemingProvider ) {
928
+ $mdThemingProvider . generateThemesOnDemand ( false ) ;
929
+ var styles =
930
+ "@supports (display: bar) {\n\n"
931
+ + " @media (min-width: 0) and (max-width: 700px) {\n\n"
932
+ + " .md-THEME_NAME-theme .layout-row {\n"
933
+ + " background-color: {{primary-500}};\n"
934
+ + " }\n\n"
935
+ + " .md-THEME_NAME-theme .layout-column {\n"
936
+ + " color: blue;\n"
937
+ + " font-weight: bold;\n"
938
+ + " }\n"
939
+ + " }\n"
940
+ + "}\n" ;
941
+
942
+ $mdThemingProvider . registerStyles ( styles ) ;
943
+ $mdThemingProvider . theme ( 'register-custom-multiple-nested-styles' ) ;
944
+ } ) ;
945
+
946
+ inject ( function ( $MD_THEME_CSS ) {
947
+ // Verify that $MD_THEME_CSS is still set to '/**/' in the test environment.
948
+ // Check angular-material-mocks.js for $MD_THEME_CSS latest value if this test starts to fail.
949
+ expect ( $MD_THEME_CSS ) . toBe ( '/**/' ) ;
950
+ } ) ;
951
+
952
+ var compiledStyles =
953
+ "@supports (display: bar) {\n\n"
954
+ + " @media (min-width: 0) and (max-width: 700px) {\n\n"
955
+ + " .md-register-custom-multiple-nested-styles-theme .layout-row {\n"
956
+ + " background-color: rgb(63,81,181);\n"
957
+ + " }\n\n"
958
+ + " .md-register-custom-multiple-nested-styles-theme .layout-column {\n"
959
+ + " color: blue;\n"
960
+ + " font-weight: bold;\n"
961
+ + " }\n"
962
+ + " }\n"
963
+ + "}" ;
964
+
965
+ // Find the string containing nested rules in the head tag.
966
+ expect ( document . head . innerHTML ) . toContain ( compiledStyles ) ;
967
+ } ) ;
968
+ } ) ;
0 commit comments